From 50691c8cac95e8a12dfe623beed7844049d2f32b Mon Sep 17 00:00:00 2001 From: Nathaniel Weinstein Date: Fri, 4 Nov 2016 01:45:39 -0700 Subject: [PATCH] Save the evaluations to a csv, in case the user wants to inspect, analyze, or otherwise use the classifications generated by the neural net --- eval.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eval.py b/eval.py index 98dc214b0..e8670151c 100755 --- a/eval.py +++ b/eval.py @@ -8,6 +8,7 @@ import data_helpers from text_cnn import TextCNN from tensorflow.contrib import learn +import csv # Parameters # ================================================== @@ -85,3 +86,10 @@ correct_predictions = float(sum(all_predictions == y_test)) print("Total number of test examples: {}".format(len(y_test))) print("Accuracy: {:g}".format(correct_predictions/float(len(y_test)))) + +# Save the evaluation to a csv +predictions_human_readable = np.column_stack((np.array(x_raw), all_predictions)) +out_path = os.path.join(FLAGS.checkpoint_dir, "..", "prediction.csv") +print("Saving evaluation to {0}".format(out_path)) +with open(out_path, 'w') as f: + csv.writer(f).writerows(predictions_human_readable) \ No newline at end of file