Question "Predicting Gold Prices"

#1
by markMayuska - opened

Doing your code "Predicting Gold Prices"

I wanted to know why trying your example the return are

GRU Prediction: [[4.7930627]]
LSTM Prediction: [[1.1015676]]

I mean isn't supposed to return a prediction of the next value?

Did you run example code in readme?
It is just example.
In practise, we need large data, at least more than 24 previous values.
Each time, every gold price is depending on 24 fore-values.
You might need more data, you can download from financial sites like yahoo.

I tryed with a dataset with 2050 values aswell, but still didn't get back an array of prediction. Maybe i missed something

See image

goldPr.png

Which dataset did you use?
I would suggest to use mltrev/gold-price dataset.
You got value around 4 and 0 so it seems that you didn't use this dataset.

img_20240914.png
Result on my side

I tryed with your Csv, but still get this value and not predictions, i'm sorry but can i ask you the code for get that graph?

Which dataset did you use?
I used the actual dataset with all values of gold every day for last 2050 days

goldPr.png

import matplotlib.pyplot as plt

# Predict using LSTM
predictions_lstm = lstm_model.predict(X_test)
predictions_lstm = scaler.inverse_transform(predictions_lstm)

# Predict using GRU
predictions_gru = gru_model.predict(X_test)
predictions_gru = scaler.inverse_transform(predictions_gru)

# Plot the results
plt.figure(figsize=(14, 7))
plt.plot(data.index[train_size + seq_length:], data['Adj Close'][train_size + seq_length:], color='blue', label='Actual Gold Price')
plt.plot(data.index[train_size + seq_length:], predictions_lstm, color='red', label='LSTM Predicted Gold Price')
plt.plot(data.index[train_size + seq_length:], predictions_gru, color='green', label='GRU Predicted Gold Price')
plt.title('Gold Price Prediction')
plt.xlabel('Date')
plt.ylabel('Price')
plt.legend()
plt.show()

Which scaling method you applied during training of both models? Kindly elaborate so that we can inverse transform forecasted values accordingly.

Sign up or log in to comment