Esempio n. 1
0
def tpo_cv_cnnvar():
    maxlen = 200
    nb_words = 6500
    embd_dim = 100

    folds = range(1, 11)
    trains = ['data/tpov4/train_'+str(fold)+'.csv' for fold in folds]
    tests = ['data/tpov4/test_'+str(fold)+'.csv' for fold in folds]
    pairs = zip(trains, tests)

    accs = []
    for (train, test) in pairs:
        print(train + '=>' + test)
        X_train, Y_train, X_test, Y_test, nb_classes = load_csvs(train, test,
                                                             nb_words, maxlen, embd_type='self', w2v=None)

        acc = cnn_var_selfembd(X_train, Y_train, X_test, Y_test, nb_classes,
                             maxlen, nb_words, embd_dim,
                             50, 32, 25, 'rmsprop')
        accs.append(acc)
    acc_cv = np.mean(accs)
    print('after 10-fold cv:' + str(acc_cv))
Esempio n. 2
0
def asap_cv_cnnvar():
    maxlen = 75
    nb_words = 4500
    embd_dim = 50

    folds = (1,2,3,4,5,6,7,8,9,10)
    trains = ['data/asap2/train'+str(fold)+'.csv' for fold in folds]
    tests = ['data/asap2/test'+str(fold)+'.csv' for fold in folds]
    pairs = zip(trains, tests)

    kappas = []
    for (train, test) in pairs:
        print(train + '=>' + test)
        X_train, Y_train, X_test, Y_test, nb_classes = load_csvs(train, test,
                                                             nb_words, maxlen, embd_type='self', w2v=None)

        kappa = cnn_var_selfembd(X_train, Y_train, X_test, Y_test, nb_classes,
                             maxlen, nb_words, embd_dim,
                             50, 32, 30, 'rmsprop')
        kappas.append(kappa)
    kappa_cv = metrics.mean_quadratic_weighted_kappa(kappas)

    print('after 10-fold cv:' + str(kappa_cv))