-
Notifications
You must be signed in to change notification settings - Fork 18
/
run_DBN.py
53 lines (47 loc) · 1.73 KB
/
run_DBN.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
# coding: utf-8
from dataset.Nikkei import Nikkei
from yoshihara.PredictPrices.DBN import DBN, train_DBN
from dataset.xor import xor
params = {
'dataset_type' : 'chi2_selected',
'STEP3' : {
'brandcode' : '0101'
},
'STEP4' : {
'hidden_layers_sizes' : [2500],
'pretrain' : {
'batch_size' : 20,
'learning_rate' : 0.01,
'epochs' : 50
},
'finetune' : {
'batch_size' :10,
'learning_rate' : 1.25,
'epochs' :50
}
}
}
######################################################
### STEP 3: 指定された銘柄の株価と記事データを組み合わせる ###
######################################################
def unify_stockprices(dataset):
print 'STEP 3 start...'
dataset.unify_stockprices(dataset.raw_data[params['STEP3']['brandcode']])
##########################################
### STEP 4: 指定された銘柄の株価を予測する ###
##########################################
def predict(dataset):
print 'STEP 4 start...'
train_DBN(dataset=dataset,
hidden_layers_sizes=params['STEP4']['hidden_layers_sizes'],
pretrain_lr=params['STEP4']['pretrain']['learning_rate'],
pretrain_batch_size=params['STEP4']['pretrain']['batch_size'],
pretrain_epochs=params['STEP4']['pretrain']['epochs'],
finetune_lr=params['STEP4']['finetune']['learning_rate'],
finetune_batch_size=params['STEP4']['finetune']['batch_size'],
finetune_epochs=params['STEP4']['finetune']['epochs']
)
if __name__ == '__main__':
dataset = Nikkei(dataset_type=params['dataset_type'], brandcode=params['STEP3']['brandcode'])
unify_stockprices(dataset)
predict(dataset)