Python 미세먼지 팁들

sudo apt-get install python-pip python-dev python-virtualenv

 pip install 하기

댓글

  1. ROC curve source:

    X, y = shuffle(X, y, random_state=0)
    clasifier = linear_model.LogisticRegression(class_weight = "balanced")
    clasifier.fit(X,y)
    fig, ax1 = plt.subplots(figsize=(12, 8))
    mean_tpr = 0.0
    mean_fpr = linspace(0, 1, 100)

    skf = StratifiedKFold(n_splits=n_folds, shuffle=True, random_state=999)

    for i, (train_index, test_index) in enumerate(skf.split(X,y)):
    # calculate the probability of each class assuming it to be positive
    probas_ = classifier.fit(X[train_index], y[train_index]).predict_proba(X[test_index])
    # Compute ROC curve and area under the curve
    fpr, tpr, thresholds = roc_curve(y[test_index], probas_[:, 1], pos_label=1)
    mean_tpr += interp(mean_fpr, fpr, tpr)
    mean_tpr[0] = 0.0
    roc_auc = auc(fpr, tpr)

    plt.plot(fpr, tpr, lw=1, label='ROC fold %d (area = %0.2f)' % (i+1, roc_auc))

    plt.plot([0, 1], [0, 1], '--', color=(0.6, 0.6, 0.6), label='Random', lw=2)


    mean_tpr /= n_folds
    mean_tpr[-1] = 1.0
    mean_auc = auc(mean_fpr, mean_tpr)

    plt.plot(mean_fpr, mean_tpr, 'k--',
    label='Mean ROC (area = %0.2f)' % mean_auc, lw=3)
    plt.xlim([-0.05, 1.05])
    plt.ylim([-0.05, 1.05])
    plt.xlabel('False Positive Rate (1- specificity)', fontsize=18)
    plt.ylabel('True Positive Rate (sensitivity)', fontsize=18)

    답글삭제
  2. ip address to integer

    def IP2Int(ip):
    o = map(int, ip.split('.'))
    res = (16777216 * o[0]) + (65536 * o[1]) + (256 * o[2]) + o[3]
    return res


    def Int2IP(ipnum):
    o1 = int(ipnum / 16777216) % 256
    o2 = int(ipnum / 65536) % 256
    o3 = int(ipnum / 256) % 256
    o4 = int(ipnum) % 256
    return '%(o1)s.%(o2)s.%(o3)s.%(o4)s' % locals()

    # Example
    print('192.168.0.1 -> %s' % IP2Int('192.168.0.1'))
    print('3232235521 -> %s' % Int2IP(3232235521))

    답글삭제
  3. python control for KSP

    https://mods.curse.com/ksp-mods/kerbal/220219-krpc-control-the-game-using-c-c-java-lua-python

    답글삭제
    답글
    1. https://www.youtube.com/watch?v=hXyx_Q9kyjg

      삭제
  4. with open("test.txt", "a") as myfile:
    myfile.write("appended text")

    파일에 어팬드 하기

    답글삭제

댓글 쓰기

이 블로그의 인기 게시물

파이썬으로 Homomorphic Filtering 하기

파이썬으로 2D FFT/iFFT 하기: numpy 버전