You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
df = df[['y','h','o','l']]
df2 = df.values
print(len(df))
training = int(np.ceil(len(df) * .95))
print(training)
# MinMaxScaler expecting like 1 feature
scaler = MinMaxScaler()
scaled_data = scaler.fit_transform(df)
# How many past days of data we want to use to predict the next day price
prediction_days = 500
# Preparing the Training data
X_train = []
y_train = []
for x in range(prediction_days, len(scaled_data)):
X_train.append(scaled_data[x - prediction_days:x, 0])
y_train.append(scaled_data[x, 0])
X_train, y_train = np.array(X_train), np.array(y_train)
# Reshaping so that it will work in Neural net
X_train = np.reshape(X_train, (X_train.shape[0], X_train.shape[1], 1))
print(X_train.shape)
print(y_train.shape)
model = Sequential()
model.add(LSTM(units=50, return_sequences=True, input_shape=(X_train.shape[1], 1)))
model.add(Dropout(0.2))
model.add(LSTM(units=50, return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(units=50))
model.add(Dropout(0.2))
model.add(Dense(units=500))
model.compile(optimizer='adam', loss='mean_squared_error')
model.fit(X_train, y_train, epochs=500, batch_size=32)
model.save('model.h5')
model = load_model('model.h5')
# show me examples hot to train my model
company = "Crypo price"
test_data = 60
total_dataset = df.values
model_inputs = total_dataset[len(total_dataset) - test_data - prediction_days:]
print(model_inputs)
print(len(model_inputs))
model_inputs = model_inputs.reshape(-1, 1)
print(model_inputs)
print(len(model_inputs))
model_inputs = scaler.fit_transform(model_inputs) # ValueError: X has 1 features, but MinMaxScaler is expecting 4 features as input.
print(f"model_inputs len{len(model_inputs)}")
print(f"prediction_days {prediction_days}")
real_data = [model_inputs[len(model_inputs) - prediction_days : len(model_inputs)+1, 0]]
print(f"prediction_days")
print(real_data)
print(len(real_data[0]))
real_data = np.array(real_data)
real_data = np.reshape(real_data, (real_data.shape[0], real_data.shape[1], 1))
prediction = model.predict(real_data)
prediction = scaler.inverse_transform(prediction)
prediction = prediction.reshape(-1, 1)
plt.plot(prediction, color='green')
plt.legend()
plt.show()
`
This code must predict LTC coin price.
I have a problem what can't to fix. Code work good, but if get from my DB 800 records(every records is 1 minute price) for example, then I receive predicttion like on follow graph: https://prnt.sc/2GFx9K7ujxa4
But if I take much more data(for example - 20000 records) for prediction with the same predicting step, then receive next graph. https://prnt.sc/JobzJmR0RGxE
Meybe some one try to make the same code or working in this way.
Please help me figure out with this problem.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
hi Daniel and every one who read this message. Please help me improve my code to predicting stock market price.
`
df = pd.DataFrame({'y': close, 'h':close_high_o,'o':open_arr_o,'l':close_low_o})
`
This code must predict LTC coin price.
I have a problem what can't to fix. Code work good, but if get from my DB 800 records(every records is 1 minute price) for example, then I receive predicttion like on follow graph:
https://prnt.sc/2GFx9K7ujxa4
But if I take much more data(for example - 20000 records) for prediction with the same predicting step, then receive next graph.
https://prnt.sc/JobzJmR0RGxE
Meybe some one try to make the same code or working in this way.
Please help me figure out with this problem.
Beta Was this translation helpful? Give feedback.
All reactions