Example #1
0
def main():

    # CID is used to run on the department cluster

    CID = opts.cluster

    if (opts.load != 'none'): CID = opts.load

    X_train, X_test, Y_train, Y_test, enc = f.get_data()

    model = bulid_model(
        X_train, X_test, Y_train, Y_test, CID, fromfile=opts.load)

    newData = X_test.reshape(X_test.shape[0], 1, 100, 20)

    Y_score = model.predict_proba(X_test)

    roc.roc_plot(
        Y_test, Y_score, 2, filepath=os.path.join('figures', CID + 'roc.jpg'),title="CNN 2D AVG pool")

    Y_de = decode_y(Y_test, features=enc.active_features_)
    Y_pred = model.predict(X_test)
    Y_depred = decode_y(Y_pred, features=enc.active_features_)
    print(classification_report(Y_de, Y_depred))

    return
Example #2
0
def main():

    CID = opts.cluster

    if (opts.load != 'none'): CID = opts.load

    X_train, X_test, Y_train, Y_test, X, X2, X3, enc = f.get_data_pro(
        testsize=0.2)

    model = bulid_model(X_train,
                        X_test,
                        Y_train,
                        Y_test,
                        X,
                        X2,
                        X3,
                        CID,
                        fromfile=opts.load)

    newData = X_test.reshape(X_test.shape[0], 1, 100, 20)

    Y_score = model.predict_proba(X_test)

    roc.roc_plot(Y_test,
                 Y_score,
                 2,
                 filepath=os.path.join('figures',
                                       CID + opts.title + 'roc.svg'),
                 fmt='svg',
                 title=opts.title)

    Y_de = decode_y(Y_test, features=enc.active_features_)
    Y_pred = model.predict(X_test)
    Y_depred = decode_y(Y_pred, features=enc.active_features_)
    print(classification_report(Y_de, Y_depred))

    return
Example #3
0
     SGDClassifier(loss='log',
                   random_state=42,
                   shuffle=True,
                   alpha=0.0001 * 0.75,
                   penalty='l1',
                   max_iter=20)),
])

_ = clf2.fit(train_data, train_target)
predicted = clf2.predict(test_data)
proba = clf2.predict_proba(test_data)
ohenc = OneHotEncoder()
Y2 = ohenc.fit_transform(test_target.reshape(-1, 1)).toarray()
roc.roc_plot(Y2,
             proba,
             2,
             filepath=os.path.join('figures', 'tradSGD' + 'roc.svg'),
             title='Logistic',
             fmt='svg')

print(metrics.classification_report(
    test_target,
    predicted,
))

print(accuracy_score(test_target, predicted))
"""

try SVC

"""