if not os.path.exists(data_dir): data_dir = '../data' print(os.listdir(data_dir)) marcap_dir = os.path.join(data_dir, 'marcap') marcap_data = os.path.join(marcap_dir, 'data') os.listdir(marcap_data) train_start = pd.to_datetime('2000-01-01') train_end = pd.to_datetime('2020-06-30') test_start = pd.to_datetime('2020-08-01') test_end = pd.to_datetime('2020-10-31') train_start, test_end # 삼성전기 code '009150' df_sem = read_marcap(train_start, test_end, ['009150'], marcap_data) df_sem.drop(df_sem[df_sem['Marcap'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Amount'] == 0].index, inplace=True) df_sem['LogMarcap'] = np.log(df_sem['Marcap']) df_sem['LogAmount'] = np.log(df_sem['Amount']) df_sem n_seq = 10 x_cols = ['LogMarcap', 'LogAmount', 'Open', 'High', 'Low', 'Close'] y_col = 'LogMarcap' train_inputs, train_labels, test_inputs, test_labels, scaler_dic = load_datas_scaled( df_sem, x_cols, y_col, train_start, train_end, test_start, test_end, n_seq) train_inputs.shape, train_labels.shape, test_inputs.shape, test_labels.shape model = build_model_rnn(n_seq, len(x_cols))
'028260', # 삼성물산 '032830', # 삼성생명 '034730', # SK '035420', # NAVER '051900', # LG생활건강 '051910', # LG화학 '055550', # 신한지주 '068270', # 셀트리온 '096770', # SK에너지 '105560', # KB금융 '207940', # 삼성바이오로직스 ] code_to_id = {code: i for i, code in enumerate(codes)} # 삼성전기 code '009150' df_sem = read_marcap(train_start, test_end, codes, marcap_data) df_sem.drop(df_sem[df_sem['Marcap'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Amount'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Open'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['High'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Low'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Close'] == 0].index, inplace=True) df_sem.drop(df_sem[df_sem['Volume'] == 0].index, inplace=True) df_sem['LogMarcap'] = np.log(df_sem['Marcap']) df_sem['LogAmount'] = np.log(df_sem['Amount']) df_sem['LogOpen'] = np.log(df_sem['Open']) df_sem['LogHigh'] = np.log(df_sem['High']) df_sem['LogLow'] = np.log(df_sem['Low']) df_sem['LogClose'] = np.log(df_sem['Close']) df_sem['LogVolume'] = np.log(df_sem['Volume'])