-
Notifications
You must be signed in to change notification settings - Fork 0
/
System.py
117 lines (83 loc) · 3.66 KB
/
System.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import pandas as pd
import numpy as np
import warnings
import os
from config import *
from sklearn.preprocessing import MinMaxScaler, MaxAbsScaler, StandardScaler
from preprocessing.transform_data.transformer import PowerTransformer
import math
"""
MASTER CONTROLLER FILE AND CLASS
alter to change which model combination to run and how
"""
studio_params = {'username': username, 'api_key': api_key}
#os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' # or any {'0', '1', '2'}
#warnings.filterwarnings("ignore")
np.set_printoptions(edgeitems=100, linewidth=1000)
np.set_printoptions(formatter={'float': lambda x: "{0:0.4f}".format(x)})
pd.set_option("display.max_rows", None)
pd.set_option("display.max_columns", None)
pd.set_option("display.max_colwidth", None)
pd.set_option('display.width', None)
market_etfs = ['SPY', 'QQQ', 'IWM', 'DIA']
#market_etfs = ['SPY', 'QQQ']
#market_etfs = ['QQQ']
train_index_df = pd.read_csv('C:/Users/wrenp/COMPS Workspace/inputData/dataFiles/train_index.csv', index_col='Date')
test_index_df = pd.read_csv('C:/Users/wrenp/COMPS Workspace/inputData/dataFiles/test_index.csv', index_col='Date')
forecast_out = 1
train_index = pd.to_datetime(train_index_df.index.values, format='%Y/%m/%d')
test_index = pd.to_datetime(test_index_df.index.values, format='%Y/%m/%d')
######################################################
class SystemComponents:
def __init__(self, feature_space='', feature_engineering='', processor='', distribution=None):
self.input_list = ['OHLC', 'OHLCTAMV']
#self.input_list = ['OHLCTAMV']
self.feature_engineering_list = ['Pearson', 'Spearman', 'MutualInfo', 'PCA']
#self.feature_engineering_list = ['Spearman', 'MutualInfo', 'PCA']
#self.feature_engineering_list = ['PCA', 'SAE']
#self.feature_engineering_list = ['PCA']
#self.feature_engineering_list = ['SAE']
self.model_type = None
f_e = []
self.processor_list = ['', 'SS', 'MMS', 'PT']
#self.processor_list = ['SS', 'MMS', 'PT']
#self.processor_list = ['', 'MMS', 'PT']
#self.processor_list = ['MMS', 'PT'] # cannot use no raw data with SVR
#self.processor_list = ['', 'PT'] # MMS does nothing for LR-OLS
#self.processor_list = ['PT']
#self.processor_list = ['']
self.feature_space = feature_space
self.feature_engineering = feature_engineering
self.processor = processor
self.p = None
self.distribution_list = [None, 'normal']
self.distribution = distribution
self.fitted_processor = None
self.selected_features = None
self.fitted_pca = None
def get_processor(self):
if self.processor == '':
return None
if self.processor == 'SS':
return StandardScaler()
if self.processor == 'MMS':
return MinMaxScaler()
elif self.processor == 'PT':
return PowerTransformer()
run_list = ['basic', 'derived', 'custom']
run = run_list[2]
dimension = 32
include_pred_errors = True
create_plot = False
show_plot = True
save_plot = False
etf_to_save = market_etfs[0]
######################################################
if include_pred_errors:
errors = pd.DataFrame(np.zeros((len(market_etfs), 6)), columns=["ME", "MAE", "MAPE", "RMSE", "Prediction %", 'Pred Incr %'],
index=market_etfs)
else:
errors = pd.DataFrame(np.zeros((len(market_etfs), 4)), columns=["MSE", "MAPE", "sMAPE", "r2"], index=market_etfs)
errors.index.name = 'Market'
classifier_errors = pd.DataFrame(np.zeros((len(market_etfs), 5)), columns=["Accuracy", "Precision", "Recall", "f1", "fbeta"],
index=market_etfs)