testX_mult = [] testY_mult = [] for p in range(len(cons_pred)): if cons_pred[p] == 1: testX_mult.append(testX[p]) testY_mult.append(multtestY[p]) print("Obtained multi-class training data") testX_mult = array(testX_mult) testY_mult = array(testY_mult) print("Creating and Training Multi-Classification Models Now ...") history, g_mult_prediction = multi_models.gru_multi( trainX_mult, trainY_mult, valX_mult, valY_mult, testX_mult, testY_mult, e) history, l_mult_prediction = multi_models.lstm_multi( trainX_mult, trainY_mult, valX_mult, valY_mult, testX_mult, testY_mult, e) history, b_mult_prediction = multi_models.blstm_multi( trainX_mult, trainY_mult, valX_mult, valY_mult, testX_mult, testY_mult, e) """f_mes = f1_score(testY_mult,g_mult_prediction,average='weighted') #gfile.write("F-Score: "+str(f_mes)+'\n') afile.write("GRU F-Score: "+str(f_mes)+'\n') f_mes = f1_score(testY_mult,l_mult_prediction,average='weighted') print(f_mes) #lfile.write("F-Score: "+str(f_mes)+'\n') afile.write("LSTM F-Score: "+str(f_mes)+'\n')
testX.append(padded_docs[ts]) testY.append(labels[ts]) # VALIDATION DATA valsize = len(trainX) - math.floor(0.2 * len(trainX)) valX = array(trainX[valsize:len(trainX)]) valY = array(trainY[valsize:len(trainX)]) trainX = array(trainX[:valsize]) trainY = array(trainY[:valsize]) testX = array(testX) testY = array(testY) ##GRU MODEL print("Creating and Training GRU Model ...") history, pred = multi_models.gru_multi(trainX, trainY, valX, valY, testX, testY, e) #del pred f_mes = f1_score(testY, pred, average='weighted') a_mes = accuracy_score(testY, pred) p_mes = precision_score(testY, pred, average='weighted') r_mes = recall_score(testY, pred, average='weighted') rcount = 0 racism_count = 0 scount = 0 sexism_count = 0 nbcount = 0 non_bully_count = 0 for x in range(len(testX)): if testY[x] == 1: