Monday, 27 August 2018

Failed to predict cryptocurrency price

I'm trying to predict 5 periodic prices of cryptocurrency based on previous 50 inputs

>>> X_train.shape, X_test.shape, Y_train.shape, Y_test.shape
((291314, 50, 8), (72829, 50, 8), (291314, 5), (72829, 5))

Here I have 50 previous samples x 8 features as input sample and prices for 5 next periods as outputs

I've build model with this code:

from tensorflow.keras.layers import GRU
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Dropout, Activation

model = Sequential()
model.add(GRU(units=50, input_shape=X_train.shape[1:], return_sequences=False))
model.add(Activation('tanh'))
model.add(Dropout(0.2))
model.add(Dense(NFS))
model.add(Activation('relu'))
model.compile(loss='mse', optimizer='adam')
model.fit(X_train, Y_train, batch_size=50, validation_data=(X_test, Y_test), epochs=2)

That gave me output:

Train on 291314 samples, validate on 72829 samples
Epoch 1/2
291314/291314 [==============================] - 487s 2ms/step - loss: 0.0107 - val_loss: 0.2502
Epoch 2/2
291314/291314 [==============================] - 463 2ms/step - loss: 0.0103 - val_loss: 0.2502

After this step I've tried to predict outputs for X_test but instead of prediction I've got matrix with correct shape but full of zeros instead of any predictions:

>>> model.predict(X_test)
array([[-0., -0., -0., -0., -0.],
       [-0., -0., -0., -0., -0.],
       [-0., -0., -0., -0., -0.],
       ...,
       [-0., -0., -0., -0., -0.],
       [-0., -0., -0., -0., -0.],
       [-0., -0., -0., -0., -0.]], dtype=float32)

Why I'm getting this bad? And do I use correct way to do what I want?

UPD full notebook: https://github.com/vassilyvv/HelloML/blob/master/Tutorials/Prediction.ipynb



from Failed to predict cryptocurrency price

No comments:

Post a Comment