-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpredict_ABCDEFG_train_extratrees_simple.py
57 lines (41 loc) · 1.84 KB
/
predict_ABCDEFG_train_extratrees_simple.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
import sys
sys.path.append("lib")
from AllStateDataLoader import AllStateDataLoader
from AllStatePredictor import AllStatePredictor
from sklearn import linear_model
from sklearn import grid_search
import numpy as np
def score(y_predict, y_real):
n = float(y_predict.shape[0])
n_ok = float(np.sum(y_predict == y_real))
return (n_ok/n)
l = AllStateDataLoader()
p = AllStatePredictor()
# # X_2 = l.get_X_train("2", "")
# y_2 = l.get_y("2", "ABCDEFG")
# y_2_predict = p.predict_simple("2", "logistic", "ABCDEFG", kind="train")
# # X_3 = l.get_X_train("3", "")
# y_3 = l.get_y("3", "ABCDEFG")
# y_3_predict = p.predict_simple("3", "logistic", "ABCDEFG", kind="train")
# # X_all = l.get_X_train("all", "")
# y_all = l.get_y("all", "ABCDEFG")
# y_all_predict = p.predict_simple("all", "logistic", "ABCDEFG", kind="train")
# print "score 2 logistic : %.4f" % (score(y_2, y_2_predict))
# print "score 3 logistic : %.4f" % (score(y_3, y_3_predict))
# print "score all logistic : %.4f" % (score(y_all, y_all_predict))
# X_2 = l.get_X_train("2", "")
y_2 = l.get_y("2", "ABCDEFG")
y_2_predict = p.predict_simple("2", "extratrees", "ABCDEFG", kind="train")
# X_3 = l.get_X_train("3", "")
y_3 = l.get_y("3", "ABCDEFG")
y_3_predict = p.predict_simple("3", "extratrees", "ABCDEFG", kind="train")
# X_4 = l.get_X_train("4", "")
y_4 = l.get_y("4", "ABCDEFG")
y_4_predict = p.predict_simple("4", "extratrees", "ABCDEFG", kind="train")
# X_all = l.get_X_train("all", "")
y_all = l.get_y("all", "ABCDEFG")
y_all_predict = p.predict_simple("all", "extratrees", "ABCDEFG", kind="train")
print "score 2 extratrees simple : %.4f" % (score(y_2, y_2_predict))
print "score 3 extratrees simple : %.4f" % (score(y_3, y_3_predict))
print "score 4 extratrees simple : %.4f" % (score(y_4, y_4_predict))
print "score all extratrees simple : %.4f" % (score(y_all, y_all_predict))