dataframe['Date'] = pd.to_datetime(dataframe['Date']) df_relevant = DLmodels.relevant_stocks(stock,main_df, cor) df_relevant.index = pd.to_datetime(df_relevant.index) dataframe = dataframe.merge(df_relevant, how='inner', on='Date') dataframe = dataframe.merge(datagrouped, how='inner', on='Date') dataset = DLmodels.clean_dataset(dataframe.drop(['Date'], axis=1)).values scaler = StandardScaler() dataset = scaler.fit_transform(dataset) scaler_filename = 'scalers/Standard_daily_' + stock + '_' + interval + '.save' pickle.dump(scaler, open(scaler_filename, 'wb')) scaler = MinMaxScaler(feature_range=[0,1]) dataset = scaler.fit_transform(dataset) scaler_filename = 'scalers/MinMax_daily_' + stock + '_' + interval + '.save' pickle.dump(scaler, open(scaler_filename, 'wb')) X, y = DLmodels.split_sequences(dataset[:-samples_test], n_steps_in, n_steps_out) n_features = X.shape[2] y = y[:,:,-1:] DLmodels.model_LSTM('daily_'+stock, X, y, interval, n_steps_in, n_steps_out, epochs, save, update, verbose) DLmodels.model_BidirectionalLSTM('daily_'+stock, X, y, interval, n_steps_in, n_steps_out, epochs, save, update, verbose) DLmodels.model_convLSTM1D('daily_'+stock, X, y, interval, n_steps_in, n_steps_out, epochs, save, update, verbose) DLmodels.model_ConvLSTM2D('daily_'+stock, X, y, interval, n_steps_in, n_steps_out, epochs, save, update, verbose)
df_target['Date'] = pd.to_datetime(df_target['Date']) dataframe = df_target dataframe = dataframe.merge(df_trend_stock_en_us, how="inner", on="Date") dataframe = dataframe.merge(df_trend_stock_pt_br, how="inner", on="Date") dataset = dataframe.drop(['Date'], axis=1).dropna().ffill().values scaler = StandardScaler() dataset = scaler.fit_transform(dataset) scaler_filename = 'scalers/complete_' + stock + '_complete_' + interval + '.save' scaler = pickle.load(open(scaler_filename, 'rb')) dataset = scaler.fit_transform(dataset) X, y = DLmodels.split_sequences(dataset, n_steps_in, n_steps_out) X = X[:, :, :] n_features = X.shape[2] y = y[:, :, -1:] for ML_tech in ML_Techniques: if ML_tech == 'lr': (predictions, accuracy) = DLmodels.stock_forecasting(dataframe, n_steps_out) if ML_tech == 'lrLog': (predictions, accuracy) = DLmodels.stock_forecastingLog(dataframe, n_steps_out) if ML_tech == 'conv': predictions = DLmodels.predict_conv1D(