Skip to content

Commit

Permalink
Merge pull request dennybritz#44 from PayscaleNateW/save-classificati…
Browse files Browse the repository at this point in the history
…ons-to-csv

Save classifications to csv
  • Loading branch information
dennybritz authored Nov 5, 2016
2 parents 0b48d34 + 50691c8 commit c008eba
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 c008eba

Please sign in to comment.