Exemplo n.º 1
0
        'kNN': KNN(),
        'Naive Bayes': Naive_Bayes(),
        'Random Forest': RandomForest(),
        'SVM': SVM(),
        'Gradient Boosting': GradientBoost()
    }

    for model in models:
        for aug in [True, False]:
            if aug:
                models[model].fit(X_aug_t, y_aug_t)
                name = model + " (aug)"
            else:
                models[model].fit(X_train_t, y_train_t)
                name = model
            y_pred = models[model].predict(X_test_t)

            acc = accuracy_score(y_test_t, y_pred)
            roc = roc_auc_score(y_test_t, y_pred)
            f1 = f1_score(y_test_t, y_pred)

            print('%s accuracy: %s' % (name, round(acc, 4)))
            print('%s AUC: %s' % (name, round(roc, 4)))
            print('%s F1: %s' % (name, round(f1, 4)))

            if not args.no_export:
                export_results(name=name, acc=acc, roc=roc, f1=f1)

# data_glove = Dataset('glove')
# X_train_g, X_test_g, y_train_g, y_test_g = train_test_split(data.X, data.y)
Exemplo n.º 2
0
    from sklearn.metrics import accuracy_score, roc_auc_score, f1_score
    from sklearn.model_selection import train_test_split
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("-x",
                        "--export-results",
                        dest="export",
                        action='store_true',
                        help="Exports results to results.csv")
    args = parser.parse_args()

    data = Dataset('twitter')
    X_train, X_test, y_train, y_test = train_test_split(data.X, data.y)

    grad_boost = GradientBoost()
    grad_boost.fit(X_train, y_train)
    y_pred = grad_boost.predict(X_test)

    print(y_pred)
    acc = accuracy_score(y_test, y_pred)
    roc = roc_auc_score(y_test, y_pred)
    f1 = f1_score(y_test, y_pred)

    print('TF-IDF + xgb accuracy:', round(acc, 4))
    print('TF-IDF + xgb AUC:', round(roc, 4))
    print('TF-IDF + xgb F1:', round(f1, 4))

    if args.export:
        export_results(acc=acc, roc=roc, f1=f1)
Exemplo n.º 3
0
    from sklearn.metrics import accuracy_score, roc_auc_score, f1_score
    from sklearn.model_selection import train_test_split
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("-x",
                        "--export-results",
                        dest="export",
                        action='store_true',
                        help="Exports results to results.csv")
    args = parser.parse_args()

    data = Dataset('twitter')
    X_train, X_test, y_train, y_test = train_test_split(data.X, data.y)

    dummy = Dummy()
    dummy.fit(X_train, y_train)

    y_pred = dummy.predict(X_test)

    acc = accuracy_score(y_test, y_pred)
    roc = roc_auc_score(y_test, y_pred)
    f1 = f1_score(y_test, y_pred)

    print('Dummy accuracy:', round(acc, 4))
    print('Dummy AUC:', round(roc, 4))
    print('Dummy F1:', round(f1, 4))

    if args.export:
        export_results(name='Dummy', acc=acc, roc=roc, f1=f1)