Gold Price Prediction Models
Overview
This repository contains two models designed for predicting gold prices, both trained on the mltrev23/gold-price dataset. The models include:
- GRU-Based Model: A deep learning model utilizing Gated Recurrent Units (GRUs) to predict the future price of gold.
- LSTM-Based Model: A deep learning model utilizing Long Short-Term Memory (LSTM) units for the same prediction task.
Both models are designed to handle time series data effectively, capturing temporal dependencies to provide accurate predictions.
Models
1. GRU-Based Model
- Filename:
gru_gold_price_model.pkl - Type: Gated Recurrent Unit (GRU)
- Input: Sequential time series data (e.g., historical gold prices, other related features)
- Output: Predicted future gold price
2. LSTM-Based Model
- Filename:
lstm_gold_price_model.pkl - Type: Long Short-Term Memory (LSTM)
- Input: Sequential time series data (e.g., historical gold prices, other related features)
- Output: Predicted future gold price
Dataset
Both models were trained on the mltrev23/gold-price dataset, which includes historical data on gold prices, potentially augmented with additional financial indicators to enhance predictive performance.
Installation
To use these models, first clone this repository and install the required Python packages:
git clone https://huggingface.co/mltrev23/gold-price-prediction
cd gold-price-prediction
pip install -r requirements.txt
Requirements
The models require the following Python libraries:
pip install numpy
pip install pandas
pip install tensorflow
pip install scikit-learn
Usage
Loading the Models
You can load the models using the joblib library for scikit-learn or pickle for Python's built-in serialization:
import joblib
# Load the GRU model
gru_model = joblib.load('gru_gold_price_model.pkl')
# Load the LSTM model
lstm_model = joblib.load('lstm_gold_price_model.pkl')
Predicting Gold Prices
To predict future gold prices using either model, you can follow this approach:
import numpy as np
# Example input data (replace with your actual data)
input_data = np.array([[1790, 1805, 1780]]) # Example sequence: previous gold prices
# Predict using the GRU model
gru_prediction = gru_model.predict(input_data)
# Predict using the LSTM model
lstm_prediction = lstm_model.predict(input_data)
print(f"GRU Prediction: {gru_prediction}")
print(f"LSTM Prediction: {lstm_prediction}")
Evaluating the Models
You can also evaluate the performance of the models using a test set from the same dataset:
from sklearn.metrics import mean_squared_error
# Assuming you have a test set
gru_predictions = gru_model.predict(X_test)
lstm_predictions = lstm_model.predict(X_test)
gru_mse = mean_squared_error(y_test, gru_predictions)
lstm_mse = mean_squared_error(y_test, lstm_predictions)
print(f"GRU Model MSE: {gru_mse}")
print(f"LSTM Model MSE: {lstm_mse}")
Model Interpretability
Both models can be interpreted by examining their predictions over time and comparing their performance on various test sets. Understanding the impact of different time series inputs on the prediction can provide insights into how each model captures temporal dependencies.
Contributing
If you wish to contribute to this repository by improving the models, adding new features, or expanding the dataset, feel free to submit a pull request. Please ensure that your code is well-documented and adheres to the existing style.
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
If you use these models in your research or project, please cite the dataset and relevant model training methods as follows:
- Dataset:
mltrev23/gold-price - GRU and LSTM Models: Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780.