コード例 #1
0
def main():
    pk=80
    for pk in [80, 200, 500, 1024]:
        proj_test, labels = load_pca_proj(K=pk)
        shuffle_in_unison(proj_test, labels)
        for k in [1,2,3,4,5,6,7,8,9,15,20,25,30]:
            knn = KNeighborsClassifier(n_neighbors=k)
            scores = cross_validation.cross_val_score(knn, proj_test, labels, cv=10)
            print "K: " + str(k)
            print "PK: " + str(pk)
            print scores
            print np.mean(scores)
            print np.var(scores)
コード例 #2
0
def main():
    N_TREE = 1001
    k = 200
    rfc = RandomForestClassifier(n_estimators=N_TREE, criterion="entropy", max_features="auto")
    RandomForestClassifier
    proj_test, labels = load_pca_proj(K=k)
    shuffle_in_unison(proj_test, labels)
    scores = cross_validation.cross_val_score(rfc, proj_test, labels, cv=10)
    pt = load_pca_test(K=k)
    rfc.fit(proj_test, labels)
    pred = rfc.predict(pt)
    write_results(pred, "../rfc_res.csv")
    print scores
    print np.mean(scores)
    print np.var(scores)
コード例 #3
0
def main():
    N_TREE = 1001
    k = 200 
    rfc = RandomForestClassifier(n_estimators=N_TREE, criterion='entropy', max_features="auto")
    RandomForestClassifier
    proj_test, labels = load_pca_proj(K=k)
    shuffle_in_unison(proj_test, labels)
    scores = cross_validation.cross_val_score(rfc, proj_test, labels, cv=10)
    pt = load_pca_test(K=k)
    rfc.fit(proj_test, labels)
    pred = rfc.predict(pt)
    write_results(pred, '../rfc_res.csv')
    print scores
    print np.mean(scores)
    print np.var(scores)
コード例 #4
0
def main():
    pk = 80
    for pk in [80, 200, 500, 1024]:
        proj_test, labels = load_pca_proj(K=pk)
        shuffle_in_unison(proj_test, labels)
        for k in [1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 20, 25, 30]:
            knn = KNeighborsClassifier(n_neighbors=k)
            scores = cross_validation.cross_val_score(knn,
                                                      proj_test,
                                                      labels,
                                                      cv=10)
            print "K: " + str(k)
            print "PK: " + str(pk)
            print scores
            print np.mean(scores)
            print np.var(scores)
コード例 #5
0
def main():
    k=500
      #images, labels = load_labeled_training(flatten=True)
   #images = standardize(images)
   #shuffle_in_unison(images, labels)
   #for k in [100,500,1024]:
      #proj_test, labels = load_pca_proj(K=k)
      #shuffle_in_unison(proj_test, labels)
      #for ker in ['linear', 'sigmoid', 'rbf']:
           #svc = SVC(kernel=ker)
           #scores = cross_validation.cross_val_score(svc, proj_test, labels, cv=10)
           #print "Kernel: " + ker
           #print "K: " + str(k)
           #print scores
           #print np.mean(scores)
           #print np.var(scores)
    proj_test, labels = load_pca_proj(K=k)
    shuffle_in_unison(proj_test, labels)
    svc = SVC()
    scores = cross_validation.cross_val_score(svc, proj_test, labels, cv=10)
    pt = load_pca_hidden(K=k)
    svc.fit(proj_test, labels)
    pred = svc.predict(pt)
    write_results(pred, '../svm_res.csv')
コード例 #6
0
def main():
    k = 500
    #images, labels = load_labeled_training(flatten=True)
    #images = standardize(images)
    #shuffle_in_unison(images, labels)
    #for k in [100,500,1024]:
    #proj_test, labels = load_pca_proj(K=k)
    #shuffle_in_unison(proj_test, labels)
    #for ker in ['linear', 'sigmoid', 'rbf']:
    #svc = SVC(kernel=ker)
    #scores = cross_validation.cross_val_score(svc, proj_test, labels, cv=10)
    #print "Kernel: " + ker
    #print "K: " + str(k)
    #print scores
    #print np.mean(scores)
    #print np.var(scores)
    proj_test, labels = load_pca_proj(K=k)
    shuffle_in_unison(proj_test, labels)
    svc = SVC()
    scores = cross_validation.cross_val_score(svc, proj_test, labels, cv=10)
    pt = load_pca_hidden(K=k)
    svc.fit(proj_test, labels)
    pred = svc.predict(pt)
    write_results(pred, '../svm_res.csv')