-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathQ4_Single_Cur.py
More file actions
32 lines (23 loc) · 952 Bytes
/
Copy pathQ4_Single_Cur.py
File metadata and controls
32 lines (23 loc) · 952 Bytes
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
import DC
import numpy as np
import datetime
import pymysql
from sklearn import svm
from sklearn import tree
from sklearn import ensemble
import DC_Single
import tushare as ts
if __name__ == '__main__':
ans = ts.get_today_all()
print(ans)
start_dt = (datetime.datetime.now() - datetime.timedelta(days=366)).strftime('%Y-%m-%d')
end_dt = (datetime.datetime.now() - datetime.timedelta(days=1)).strftime('%Y-%m-%d')
dc = DC_Single.data_collect2('600000',start_dt,end_dt)
train = dc.data_train
target = dc.data_target
test_case = [dc.test_case]
w = 5*(len(target)/dc.cnt_pos)
model = svm.SVC(class_weight={1:w})
model.fit(train,target)
ans2 = model.predict(test_case)
print(' ANS : ' + str(ans2[0]) + 'POS_CNT : ' + str(len([x for x in target if x == 1.00])) + ' of total : ' + str(len(target)) + ' start_dt : ' + str(start_dt) + ' end_dt : ' + str(end_dt))