diff --git a/.gitignore b/.gitignore index 0478d6eb..44c1c23a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ *.pyc result.txt extracted_features* -acc_results.txt -auc_results.txt +*results.txt .* diff --git a/main.py b/main.py index 8f469fd3..1adfbf22 100644 --- a/main.py +++ b/main.py @@ -177,11 +177,13 @@ def loop_dataset(g_list, classifier, sample_idxes, optimizer=None, bsize=cmd_arg # np.savetxt('test_scores.txt', all_scores) # output test predictions - if not classifier.regression: + if not classifier.regression and cmd_args.printAUC: all_targets = np.array(all_targets) fpr, tpr, _ = metrics.roc_curve(all_targets, all_scores, pos_label=1) auc = metrics.auc(fpr, tpr) avg_loss = np.concatenate((avg_loss, [auc])) + else: + avg_loss = np.concatenate((avg_loss, [0.0])) return avg_loss @@ -223,11 +225,11 @@ def loop_dataset(g_list, classifier, sample_idxes, optimizer=None, bsize=cmd_arg test_loss[2] = 0.0 print('\033[93maverage test of epoch %d: loss %.5f acc %.5f auc %.5f\033[0m' % (epoch, test_loss[0], test_loss[1], test_loss[2])) - with open('acc_results.txt', 'a+') as f: + with open(cmd_args.data + '_acc_results.txt', 'a+') as f: f.write(str(test_loss[1]) + '\n') if cmd_args.printAUC: - with open('auc_results.txt', 'a+') as f: + with open(cmd_args.data + '_auc_results.txt', 'a+') as f: f.write(str(test_loss[2]) + '\n') if cmd_args.extract_features: diff --git a/run_DGCNN.sh b/run_DGCNN.sh index f38fc75f..f07babe2 100755 --- a/run_DGCNN.sh +++ b/run_DGCNN.sh @@ -91,9 +91,9 @@ if [ ${fold} == 0 ]; then echo "End of cross-validation" echo "The total running time is $[stop - start] seconds." echo "The accuracy results for ${DATA} are as follows:" - cat acc_results.txt - echo "Average accuracy is" - tail -10 acc_results.txt | awk '{ sum += $1; n++ } END { if (n > 0) print sum / n; }' + tail -10 ${DATA}_acc_results.txt + echo "Average accuracy and std are" + tail -10 ${DATA}_acc_results.txt | awk '{ sum += $1; sum2 += $1*$1; n++ } END { if (n > 0) print sum / n; print sqrt(sum2 / n - (sum/n) * (sum/n)); }' else CUDA_VISIBLE_DEVICES=${GPU} python main.py \ -seed 1 \