Skip to content

Commit

Permalink
Save the evaluations to a csv, in case the user wants to inspect, ana…
Browse files Browse the repository at this point in the history
…lyze, or otherwise use the classifications generated by the neural net
  • Loading branch information
PayscaleNateW committed Nov 4, 2016
1 parent 6ad8ba2 commit 50691c8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import data_helpers
from text_cnn import TextCNN
from tensorflow.contrib import learn
import csv

# Parameters
# ==================================================
Expand Down Expand Up @@ -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)

0 comments on commit 50691c8

Please sign in to comment.