Commit 01e0840d by Pamela Osuna

pr and mc

parent ed4a4a69
......@@ -156,6 +156,8 @@ def run_kfold(X_train, X_test, y_train, y_test, params):
total_acc = 0
total_auc = 0
cm_tab = []
pr_tab = []
bs, ep = m.choose_batch_epochs(b,e)
......@@ -171,19 +173,25 @@ def run_kfold(X_train, X_test, y_train, y_test, params):
# calculate area under the curve
y_pred = model.predict(X_test, batch_size = bs)
fpr, tpr, auc = ra.roc_auc(N_CLASSES, y_test, y_pred)
y_pred = model.predict(X_test[i], batch_size = bs)
fpr, tpr, auc = ra.roc_auc(N_CLASSES, y_test[i], y_pred)
total_auc += auc
print("Area under the curve:", auc)
# confusion matrix
cm_tab.append(confusion_matrix(y_test[i].argmax(axis=1), y_pred.argmax(axis=1)))
#pr curve (1 for each class)
#average of acc, auc, cm, pr
total_acc = total_acc/(N_SPLITS)
total_auc = total_acc/(N_SPLITS)
cm = sum([cm_tab[j] for j in range(N_SPLITS)])/5
print("Average accuracy: ", total_acc)
print("Average area under the curve: ", total_auc)
# confusion matrix
cm = confusion_matrix(y_test.argmax(axis=1), y_pred.argmax(axis=1))
return total_acc, total_auc, cm
return total_acc, total_auc, cm_tab, pr_tab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment