how to feed multi-array data to a model?
As you can see below the object n3w_coin
has a method called forecast_coin()
which returns a data frame that has 5 columns after removing date_time , i split the data with train_test_split
and then normalize it with sc
, after converting the 2D array to a 3D array that i would like to pass to the model to train on but i am having a little bit of trouble figuring out how to feed the normalized_x_train
to the model
my goal is to feed every sub-array inside normalized_x_train
to the model
I get the following error IndexError: tuple index out of range
please explain why and what is wrong with my approach
df = pd.DataFrame(n3w_coin.forecast_coin()) x_sth = np.array(df.drop(['date_time'],1)) y_sth = np.array(df.drop(['date_time'],1)) sc = MinMaxScaler(feature_range=(0,1)) X_train, X_test, y_train, y_test = train_test_split(x_sth,y_sth, test_size=0.2, shuffle=False) print (X_train) normalized_x_train = sc.fit_transform(X_train) normalized_y_train = sc.fit_transform(y_train) print (normalized_x_train) ### converting to a 3D array to feed the model normalized_x_train = np.reshape(normalized_x_train, (400 , 5 ,1 )) print (normalized_x_train.shape) print (normalized_x_train) model = Sequential() model.add(LSTM(units = 100, return_sequences = True, input_shape=(normalized_x_train.shape[5],1))) model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy']) model.fit(normalized_x_train, normalized_y_train, epochs=100, batch_size=400 )