I have a dataset with four input. here I am trying to predict X1 input in next time period using lstm model.
Here I put x_train 80% and x_test 20% . In x_test first input some of rows are with 0 values.
What I want is I want to read that 0 value separately. I tried and it didn't work for me. Can anyone help me to solve this problem. Here my code:
data=data.values scaler_x = preprocessing.MinMaxScaler(feature_range =(0, 1)) x = np.array(x).reshape ((len(x),4 )) x = scaler_x.fit_transform(x) scaler_y = preprocessing.MinMaxScaler(feature_range =(0, 1)) y = np.array(y).reshape ((len(y), 1)) y = scaler_y.fit_transform(y) train_end = 80 x_train=x[0: train_end ,] x_test=x[train_end : ,] y_train=y[0: train_end] y_test=y[train_end :] x_train=x_train.reshape(x_train.shape +(1,)) x_test=x_test.reshape(x_test.shape + (1,))
After writing code for lstm I tried to predict value for x_test. Before that I want to specify that rows with 0 values.
x_test_n = np.flip(x_test_n, axis=0) curr_frame = x_test_n
Then it just read first row with four input together. What I want is to read first input with 0 values.
Image for what I got:
What I want to read
After changing the code:
pred= for index, row in x_test_n.iterrows(): if index_row, index_col = np.where(x_test_n == 0) x_test_n.iloc[index] = pred[-1] row['X_test_n'] = pred[-1] pred1 = model.predict(x_test_n) pred.append(pred1)
It gave me an error:
if index_row, index_col = np.where(x_test_n == 0)