Ad

Inputing 5 Row Data,classifiying(predicting) 6th Row In Keras LSTM

I want to input 5 row of a dataset to LSTM and classify 6th row of Y. I made the input by reshaping the data:

X = X.reshape(6000,5,5)

But how can I predict Y of 6th row? What shape Y should have? I read a lot and search a lot on Google,but honestly I couldn't understand the code because they customize their data before using them.

My full code:

import pandas as pd
from sklearn.preprocessing import LabelEncoder,MinMaxScaler
from keras.layers import Dense,RNN,LSTM,Activation,Dropout,SimpleRNN,Bidirectional
from keras.optimizers import RMSprop,Adam
from keras.wrappers.scikit_learn import KerasClassifier
from keras.models import Sequential
from sklearn.model_selection import train_test_split
import numpy as np

df = pd.read_csv('./EURUSD_DATAFRAME.csv')
BinEncoder = LabelEncoder()
scalar = MinMaxScaler()

df['pos'] = df['pos'].astype('int')
dat = df.values




X = dat[0:30000,0:5]
Y = dat[0:6000,5]


X[:,4]= BinEncoder.fit_transform(X[:,4])
X[:,0:4] = scalar.fit_transform(X[:,0:4])
X[:,4] = X[:,4].astype('int')
Y = BinEncoder.fit_transform(Y)

X = X.reshape(6000,5,5)
#MODEL 3
 model = Sequential()
 model.add(LSTM(1024,input_shape=(5,5),return_sequences=True,kernel_initializer='normal'))
 #model.add(Activation('tanh'))
 model.add(Dropout(0.2))
 model.add(LSTM(512))
 model.add(Dropout(0.3))
 model.add(Dense(1))
 model.add(Activation('sigmoid'))
 model.compile(optimizer='adam',loss='binary_crossentropy',metrics=['accuracy'])
 model.fit(X,Y,batch_size=100,epochs=10,validation_split=0.2)
 p = model.predict(X)
# print(classifier.score(X,Y))
# ----

I am classifiying Y which is Encoded as 1 or 0.

Ad

Answer

Sorry, but I don't understand really what do you mean by this? Your input shape is (6000, 5, 5) and your output shape is (6000, 2)? So what do you mean by sixth row?

Ad
source: stackoverflow.com
Ad