def test_ted(): nb_words = 7500 maxlen = 20 embd_dim = 100 X_train, Y_train, X_test, Y_test, nb_classes = load_ted(nb_words, maxlen, 'self') cnn1d_selfembd(X_train, Y_train, X_test, Y_test, nb_classes, maxlen, nb_words, embd_dim, 100, 5, 50, 20, 'rmsprop')
def test_asap(): nb_words = 2900 maxlen = 75 embd_dim = 50 X_train, Y_train, X_test, Y_test, nb_classes = load_asap(nb_words, maxlen, 'self') cnn1d_selfembd(X_train, Y_train, X_test, Y_test, nb_classes, maxlen, nb_words, embd_dim, 100, 5, 50, 20, 'rmsprop')
def argu_cv(): maxlen = 40 nb_words = 8000 embd_dim = 100 folds = ['VC048263', 'VC048408', 'VC084849', 'VC084851', 'VC084853', 'VC101537', 'VC101541', 'VC140094', 'VC207640', 'VC248479'] trains = ['data/Argu/csv/generic_' + str(fold) + '_training.csv' for fold in folds] tests = ['data/Argu/csv/generic_' + str(fold) + '_testing.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 = cnn1d_selfembd(X_train, Y_train, X_test, Y_test, nb_classes, maxlen, nb_words, embd_dim, 100, 5, 50, 20, 'rmsprop') accs.append(acc) acc_cv = np.mean(accs) print('after 10-fold cv:' + str(acc_cv))
def pun_cv(): maxlen = 20 nb_words = 8000 embd_dim = 100 folds = range(1,11) trains = ['data/pun_of_day/train'+str(fold)+'.csv' for fold in folds] tests = ['data/pun_of_day/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 = cnn1d_selfembd(X_train, Y_train, X_test, Y_test, nb_classes, maxlen, nb_words, embd_dim, 100, 5, 50, 20, 'rmsprop') accs.append(acc) acc_cv = np.mean(accs) print('after 10-fold cv:' + str(acc_cv))
def asap_cv(): 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 = cnn1d_selfembd(X_train, Y_train, X_test, Y_test, nb_classes, maxlen, nb_words, embd_dim, 100, 5, 50, 20, 'rmsprop') kappas.append(kappa) kappa_cv = metrics.mean_quadratic_weighted_kappa(kappas) # TODO add other metrics. print('after 10-fold cv:' + str(kappa_cv))