From 1a3d52cf5edeb40e30005eee893c0ef036a04687 Mon Sep 17 00:00:00 2001
From: schoenwandt <schoenwandt@cl.uni-heidelberg.de>
Date: Thu, 8 Feb 2018 17:46:25 +0100
Subject: [PATCH] added eval_results.py to get the best scores for the
 evaluation measures

---
 src/eval_results.py | 55 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
 create mode 100644 src/eval_results.py

diff --git a/src/eval_results.py b/src/eval_results.py
new file mode 100644
index 0000000..51f25a8
--- /dev/null
+++ b/src/eval_results.py
@@ -0,0 +1,55 @@
+import csv
+from operator import itemgetter
+import sys
+
+"""
+Returns the best evaluation scores for a "cv_results_*_*_*.csv" file
+Needs the file name as command line argument
+"""
+
+def replace(name):
+	if name == "DecisionTreeClassifier":
+		return "Tree"
+	elif name == "LogisticRegression":
+		return "LogR."
+	else:
+		return name
+
+if __name__ == '__main__':
+		
+	file = open(sys.argv[1], "r")
+
+	reader = csv.reader(file)
+
+	results = [x for x in reader][1:]
+
+	sorted_by_acc = sorted(results, key=itemgetter(2), reverse=True)
+	sorted_by_prec = sorted(results, key=itemgetter(3), reverse=True)
+	sorted_by_rec = sorted(results, key=itemgetter(4), reverse=True)
+	sorted_by_f1 = sorted(results, key=itemgetter(5), reverse=True)
+
+
+	print("Top 5 Accuracy:")
+	for i in range(5):
+		print("{}\t{}\t{}".format(sorted_by_acc[i][2], replace(sorted_by_acc[i][0]), sorted_by_acc[i][1]))
+
+	print("\nTop 5 Precision:")
+	for i in range(5):
+		print("{}\t{}\t{}".format(sorted_by_prec[i][3], replace(sorted_by_prec[i][0]), sorted_by_prec[i][1]))
+
+	print("\nTop 5 Recall:")
+	for i in range(5):
+		print("{}\t{}\t{}".format(sorted_by_rec[i][4], replace(sorted_by_rec[i][0]), sorted_by_rec[i][1]))
+
+	print("\nTop 10 F1:")
+	for i in range(10):
+		print("{}\t{}\t{}".format(sorted_by_f1[i][5], replace(sorted_by_f1[i][0]), sorted_by_f1[i][1]))
+		features = sorted_by_f1[i][1].strip("[]").strip().split(",")
+
+
+	print("\nTop F1-scores without f7:")
+	for i in range(200):
+		if "f7" not in sorted_by_f1[i][1] and "f4" not in sorted_by_f1[i][1]:
+			print("{}\t{}\t{}".format(sorted_by_f1[i][5], replace(sorted_by_f1[i][0]), sorted_by_f1[i][1]))
+
+
-- 
GitLab