-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
60 lines (26 loc) · 1.23 KB
/
run.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
# -*- coding: utf-8 -*-
import os
import numpy as np
import _pickle as cPickle
import xgboost as xgb
from src import submisson as sub
def main():
train_files = [file for file in os.listdir("results/train/") if 'ep' in file and '6' not in file]
test_files = [file for file in os.listdir("results/test/") if 'ep' in file and '6' not in file]
print("Training on {}".format(train_files))
train = []
for file in train_files:
train.append(cPickle.load(open("results/train/{}".format(file), "rb")))
print("Predicting on {}".format(test_files))
test = []
for file in test_files:
test.append(cPickle.load(open("results/test/{}".format(file), "rb")))
train = np.hstack(train)
test = np.hstack(test)
y = np.array(train.shape[0]//2 * [0] + train.shape[0]//2 * [1])
model = xgb.XGBClassifier().fit(train, y)
y_pred = model.predict(test)
y_pred = 2*y_pred - 1
sub.create_submission(np.arange(1,test.shape[0]+1),y_pred, 'final_pred')
if __name__ == '__main__':
main()