-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean_csvs.py
125 lines (115 loc) · 2.55 KB
/
clean_csvs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import csv
from pathlib import Path
CSV_DIR = Path.cwd() / "results"
# List of columns for results csvs
cols = [
"description",
"min_user_ratings",
"min_book_ratings",
"vectoriser",
"vectoriser_params",
"cf_algo",
"cf_params",
"content_algo",
"content_params",
"hybrid_algo",
"hybrid_params",
"time_taken",
"fold",
"cf_accuracy",
"cf_f1",
"content_accuracy",
"content_f1",
"hybrid_accuracy",
"hybrid_f1",
"cf_tp",
"cf_tn",
"cf_fp",
"cf_fn",
"cf_precision",
"cf_recall",
"content_tp",
"content_tn",
"content_fp",
"content_fn",
"content_precision",
"content_recall",
"hybrid_tp",
"hybrid_tn",
"hybrid_fp",
"hybrid_fn",
"hybrid_precision",
"hybrid_recall",
]
# List of columns for results csvs that include separate style vectors
cols_style = [
"description",
"min_user_ratings",
"min_book_ratings",
"vectoriser",
"vectoriser_params",
"cf_algo",
"cf_params",
"content_algo",
"content_params",
"hybrid_algo",
"hybrid_params",
"time_taken",
"fold",
"cf_accuracy",
"cf_f1",
"content_accuracy",
"content_f1",
"style_accuracy",
"style_f1",
"hybrid_accuracy",
"hybrid_f1",
"cf_tp",
"cf_tn",
"cf_fp",
"cf_fn",
"cf_precision",
"cf_recall",
"content_tp",
"content_tn",
"content_fp",
"content_fn",
"content_precision",
"content_recall",
"style_tp",
"style_tn",
"style_fp",
"style_fn",
"style_precision",
"style_recall",
"hybrid_tp",
"hybrid_tn",
"hybrid_fp",
"hybrid_fn",
"hybrid_precision",
"hybrid_recall",
]
def new_file(name, style):
"""Makes a csv of headers with a specified filename
Returns nothing but creates a csv file
Parameters
----------
name (str):
Filename to use for the file - added to the invariant CSV_DIR
path specified at the start of this script
style (bool):
Whether this csv should include the extra columns for separate style vectors
"""
with open(CSV_DIR / name, "w") as f:
writer = csv.writer(f)
if style:
writer.writerow(cols_style)
else:
writer.writerow(cols)
# Create the standard 6 csv files
new_file("averaged_results.csv", False)
new_file("main_results.csv", False)
new_file("test_set_results.csv", False)
new_file("3_vector_averaged_results.csv", True)
new_file("3_vector_main_results.csv", True)
new_file("3_vector_test_set_results.csv", True)