07-16-2018, 02:35 PM
I made a dataframe of Fuzzified Candlesticks from a paper. My dataframe looks like this:
Input is 5 candlesticks and output is color of 6th candlestick. Target(label) is Color and features are Lbody,Lupper,Llower,OStyle and Cstyle.
I'm trying to train it with Keras library with back end of Tensorflow.
My code is:
acc is not improved and stuck in 40% to 42%. Also I try it with SVM and I got same result. What's the problem with my code/model?
Code:
Lupper Lbody Llower OStyle CStyle Var Color
0 equal short equal open_equal_high close_high larg_inc red
1 equal short equal open_equal_high close_equal ext_dec green
2 equal equal equal open_equal_high close_equal_high sm_inc red
3 equal equal short open_high close_equal_high norm_dec green
4 equal equal equal open_equal_high close_equal_high sm_dec green
5 equal short equal open_equal_low close_equal_low ext_dec green
6 equal equal equal open_equal close_equal ext_dec green
7 equal equal equal open_equal_high close_equal sm_dec green
8 short short equal open_equal_low close_equal_low sm_inc red
9 short short equal open_equal_low close_equal ext_dec green
I'm trying to train it with Keras library with back end of Tensorflow.
My code is:
Code:
df['Color'].replace('green',1,inplace=True)
df['Color'].replace('red',2,inplace=True)
df['Color'].replace('cross',0,inplace=True)
cols_to_transform = ['Lupper','Lbody','Llower','OStyle','CStyle','Var']
df = pd.get_dummies(df,columns=cols_to_transform)
def create_dataset(dataset, look_back=1):
dataX, dataY = [], []
for i in range(len(dataset)-look_back-1):
a = dataset[i:(i + look_back), 1:29]
dataX.append(a)
dataY.append(dataset[i + look_back, 0])
return np.array(dataX), np.array(dataY)
X, Y = create_dataset(df.values,look_back=5)
Y = to_categorical(Y,num_classes=3)
model = Sequential()
model.add(LSTM(64,input_shape=(5,28),return_sequences=True))
model.add(Activation('relu'))
model.add(Dropout(0.2))
model.add(LSTM(64,return_sequences=True))
model.add(Activation('relu'))
model.add(Dropout(0.2))
model.add(LSTM(32))
model.add(Dropout(0.2))
model.add(Dense(3))
model.add(Activation('softmax'))
model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['acc'])
acc is not improved and stuck in 40% to 42%. Also I try it with SVM and I got same result. What's the problem with my code/model?