ececet commited on
Commit
c52228e
1 Parent(s): 2e30233
figs/CatBoostRegressor_BoW_0.01_0.99_False.png ADDED
figs/CatBoostRegressor_BoW_0.01_0.99_True.png ADDED
figs/CatBoostRegressor_TF-IDF_0.01_0.99_False.png ADDED
figs/CatBoostRegressor_TF-IDF_0.01_0.99_True.png ADDED
figs/Lasso_BoW_0.01_0.99_False.png ADDED
figs/Lasso_BoW_0.01_0.99_True.png ADDED
figs/Lasso_BoW_0.15_0.85_False.png ADDED
figs/Lasso_BoW_0.2_0.8_False.png ADDED
figs/Lasso_TF-IDF_0.01_0.99_False.png ADDED
figs/Lasso_TF-IDF_0.01_0.99_True.png ADDED
figs/Lasso_TF-IDF_0.15_0.85_False.png ADDED
figs/Lasso_TF-IDF_0.2_0.8_False.png ADDED
figs/Linear regression_BoW_0.01_0.99_False.png ADDED
figs/Linear regression_BoW_0.01_0.99_True.png ADDED
figs/Linear regression_TF-IDF_0.01_0.99_False.png ADDED
figs/Linear regression_TF-IDF_0.01_0.99_True.png ADDED
figs/SGD Regressor_BoW_0.01_0.99_False.png ADDED
figs/SGD Regressor_BoW_0.01_0.99_True.png ADDED
figs/SGD Regressor_TF-IDF_0.01_0.99_False.png ADDED
figs/SGD Regressor_TF-IDF_0.01_0.99_True.png ADDED
oversampled_True_catboost_reg_0.01_0.99.txt CHANGED
The diff for this file is too large to render. See raw diff
 
plots.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import pandas as pd
4
+ import seaborn as sns
5
+
6
+ sns.set_theme()
7
+
8
+ def read_results(filename):
9
+ with open(filename, "r") as f:
10
+ lines = f.readlines()
11
+
12
+ preds_values = []
13
+ actual_values = []
14
+ mae_values = []
15
+
16
+ for line in lines:
17
+ if line.startswith("Preds:"):
18
+ preds = line.replace("[", "")
19
+ preds = preds.replace("]", "")
20
+ preds = preds.strip("Preds:")
21
+ preds = preds.strip()
22
+ preds = preds.split(",")
23
+ preds = [p.strip() for p in preds]
24
+ preds = np.asarray([float(p) for p in preds])
25
+ preds_values.append(preds)
26
+
27
+ if line.startswith("Actual:"):
28
+ actual = line.replace("[", "")
29
+ actual = actual.replace("]", "")
30
+ actual = actual.strip("Actual values:")
31
+ actual = actual.strip()
32
+ actual = actual.split(",")
33
+ actual = [a.strip() for a in actual]
34
+ actual = np.asarray([float(a) for a in actual])
35
+ actual_values.append(actual)
36
+
37
+ if line.startswith("MAE"):
38
+ mae = float(line.split()[-1])
39
+ mae_values.append(mae)
40
+ return preds_values, actual_values, mae_values
41
+
42
+
43
+ def plot_distribution(preds_values, actual_values, mae_values, model_name, threshold, oversampled):
44
+ for i in range(2):
45
+ if i == 0:
46
+ input_type = "BoW"
47
+ else:
48
+ input_type = "TF-IDF"
49
+ preds = preds_values[i]
50
+ actual = actual_values[i]
51
+ mae = mae_values[i]
52
+
53
+ res = pd.DataFrame()
54
+ res["Prediction"] = preds
55
+ res["Actual"] = actual
56
+
57
+ sns.displot(res, kind="kde")
58
+ plt.xlabel("Home standard score")
59
+ plt.title(f"Model: {model_name}, Input type: {input_type}, MAE: {mae}, Threshold:{threshold}",
60
+ fontsize = 10)
61
+ plt.ylim(-0.03, 2.5)
62
+ plt.tight_layout()
63
+ plt.savefig(f"figs/{model_name}_{input_type}_{threshold[0]}_{threshold[1]}_{oversampled}.png")
64
+ plt.close()
65
+
66
+
67
+ if __name__ == "__main__":
68
+ preds_values, actual_values, mae_values = read_results("linear_models/lasso_0.01_0.99.txt")
69
+ plot_distribution(preds_values, actual_values, mae_values, "Lasso", [0.01, 0.99], False)
70
+
71
+ preds_values, actual_values, mae_values = read_results("linear_models/lin_reg_0.01_0.99.txt")
72
+ plot_distribution(preds_values, actual_values, mae_values, "Linear regression", [0.01, 0.99], False)
73
+
74
+ preds_values, actual_values, mae_values = read_results("linear_models/sgd_reg_0.01_0.99.txt")
75
+ plot_distribution(preds_values, actual_values, mae_values, "SGD Regressor", [0.01, 0.99], False)
76
+
77
+ preds_values, actual_values, mae_values = read_results("oversampled_False_catboost_reg_0.01_0.99.txt")
78
+ plot_distribution(preds_values, actual_values, mae_values, "CatBoostRegressor", [0.01, 0.99], False)
79
+
80
+ preds_values, actual_values, mae_values = read_results("linear_models/lasso_0.2_0.8.txt")
81
+ plot_distribution(preds_values, actual_values, mae_values, "Lasso", [0.2, 0.8], False)
82
+
83
+ preds_values, actual_values, mae_values = read_results("linear_models/oversampled_lin_reg_0.01_0.99.txt")
84
+ plot_distribution(preds_values, actual_values, mae_values, "Linear regression", [0.01, 0.99], True)
85
+
86
+ preds_values, actual_values, mae_values = read_results("linear_models/oversampled_lasso_0.01_0.99.txt")
87
+ plot_distribution(preds_values, actual_values, mae_values, "Lasso", [0.01, 0.99], True)
88
+
89
+ preds_values, actual_values, mae_values = read_results("linear_models/oversampled_sgd_reg_0.01_0.99.txt")
90
+ plot_distribution(preds_values, actual_values, mae_values, "SGD Regressor", [0.01, 0.99], True)
91
+
92
+ preds_values, actual_values, mae_values = read_results("oversampled_True_catboost_reg_0.01_0.99.txt")
93
+ plot_distribution(preds_values, actual_values, mae_values, "CatBoostRegressor", [0.01, 0.99], True)
94
+
95
+ preds_values, actual_values, mae_values = read_results("linear_models/oversampled_lasso_0.15_0.85.txt")
96
+ plot_distribution(preds_values, actual_values, mae_values, "Lasso", [0.15, 0.85], False)
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+