Gold Price Prediction Using Machine Learning
Gold Price Prediction Using Machine Learning is a medium-level Python project that applies machine learning and time-series feature engineering to estimate gold prices in Indian Rupees. The system combines historical gold-price information with the USD/INR exchange rate and presents the prediction workflow through an interactive Gradio interface. It is designed as a practical college project for students who want to understand how financial data can be prepared, modeled, evaluated, and presented through a simple web application.
Complete Advance AI Topics: Click Here
Real Time Projects on YouTube:- DecodeIT
Project Overview
Gold prices are influenced by several market conditions, and exchange-rate movement can also affect the value of gold when prices are considered in INR. Instead of relying on a single regression technique, this project compares three approaches: Linear Regression, Ridge Regression, and Random Forest Regression. Historical records are transformed into useful numerical features, including recent gold-price values, a seven-day rolling average, and daily USD/INR movement.
The project is organized as a complete college-level workflow rather than a single prediction script. It includes dataset handling, feature preparation, model training, evaluation, saved models, charts, and an interactive Gradio application. The included sample data allows the application to be tested immediately, while the same structure can be used with a larger historical dataset for an academic experiment.
Key Features
- Historical gold price and USD/INR exchange-rate data handling.
- Time-series features based on recent gold prices and rolling averages.
- Three regression models for comparison.
- Model evaluation using MSE, RMSE, and R².
- Saved trained models for reuse by the application.
- Historical gold-price and model-comparison visualizations.
- Interactive Gradio interface for entering market values and receiving an estimated gold price.
- Input validation and readable prediction messages.
Project Details
| Attribute | Description |
|---|---|
| Project Name | Gold Price Prediction Using Machine Learning |
| Language | Python |
| Type | Machine Learning Web Application |
| Interface | Gradio |
| Recommended Version | Python 3.x |
Technologies Used
The project uses Python as its main programming language. Pandas is used for loading and preparing tabular data, NumPy supports numerical operations, and scikit-learn provides the regression algorithms and evaluation metrics. Joblib is used to store trained models so that the Gradio application can reuse them without training every time. Matplotlib generates the project charts, while Gradio provides the interactive prediction interface.
Project Modules
1. Dataset Handling
The data module reads historical records containing the date, gold price in INR, and USD/INR exchange rate. Values are converted into suitable numerical formats, missing records are removed, and the dataset is sorted by date before modeling.
2. Feature Preparation
The application creates lag-based and rolling features from historical values. The feature set includes the USD/INR exchange rate, one-day gold-price lag, seven-day gold-price lag, seven-day average gold price, and daily USD/INR change. These values give the regression models recent market context.
3. Model Training
Linear Regression provides a straightforward baseline. Ridge Regression adds regularization to reduce the effect of overly large coefficients, while Random Forest Regression combines multiple decision trees to model non-linear relationships. The training script keeps the time order of the data and uses an 80/20 split for evaluation.
4. Evaluation and Visualization
Each model is evaluated using Mean Squared Error, Root Mean Squared Error, and R². The training module saves the results in a CSV file and creates charts for the historical gold-price trend and model R² comparison. This makes the project easier to explain during a college demonstration or viva.
5. Gradio Prediction App
The Gradio interface provides a clean prediction screen where users select a model and enter the USD/INR rate, recent gold-price values, seven-day average, and exchange-rate change. After submitting the form, the application displays the estimated gold price and the selected model. The interface is intentionally simple, responsive, and focused on the project’s actual forecasting workflow.
Download complete source code
Screenshot




How the System Works
The workflow begins by loading the historical dataset. After validation, time-series features are generated from previous observations. The prepared records are divided chronologically into training and testing portions. Each regression model learns from the training data and produces predictions for the test portion. The evaluation metrics are then calculated and stored. Once training is complete, the models are saved in the models directory. The Gradio application loads those files and uses them for interactive predictions.
Installation and Setup
Open the project folder in VS Code and create a Python virtual environment if required. Install the dependencies with:
pip install -r requirements.txt
Train the models by running:
python src/train.py
After training finishes, start the Gradio application:
python src/app.py
The terminal will provide a local Gradio address. Open that address in a browser to use the prediction interface. The Jupyter notebook inside the notebook folder can also be opened for step-by-step experimentation with the dataset and models.
Usage
After launching the application, select a prediction model from the dropdown. Enter the current USD/INR exchange rate and the required recent gold-price values. The interface also accepts the seven-day average and daily exchange-rate change. Click Predict Gold Price to receive the model-generated estimate. For academic analysis, compare the saved evaluation values in models/model_results.csv and review the charts generated under assets/plots.
Frequently Asked Questions
What is the purpose of this project?
It demonstrates how historical gold and currency data can be used to build and evaluate regression models for estimating gold prices in INR.
Which algorithms are included?
The project includes Linear Regression, Ridge Regression, and Random Forest Regression.
Which interface is used?
A Gradio-based interface is used to provide an interactive prediction screen without requiring a separate frontend framework.
What metrics are used?
The models are evaluated with MSE, RMSE, and R² so that prediction error and model fit can be examined from multiple perspectives.
Does the application guarantee the future gold price?
No. The output is a machine-learning estimate based on the supplied features and trained data. Real market prices can change because of factors that are not represented in the project dataset.
Can the dataset be replaced?
Yes. A larger and more recent dataset can be placed in the data folder as long as the required columns are maintained.
Future Scope
- Expand the historical dataset with more recent observations.
- Add additional market indicators when suitable data is available.
- Experiment with additional time-series forecasting methods.
- Add date-based forecasting visualizations to the Gradio interface.
- Provide downloadable prediction reports for academic analysis.
For a college presentation, the project can be demonstrated in a clear sequence: first show the dataset, then explain the generated lag and rolling features, followed by model training and metric calculation. The final step is the Gradio prediction screen. This sequence helps connect the technical implementation with the visible result and makes it easier to explain the role of each file during project evaluation.
The separation between training, saved models, and the user interface also keeps the project organized for future dataset updates. A student can retrain the models after adding new historical records without changing the main prediction interface.
Conclusion
Gold Price Prediction Using Machine Learning provides a practical way to study financial-data modeling through a manageable college project. It connects dataset preparation, time-series feature engineering, regression, evaluation, visualization, and an interactive Gradio interface in one workflow. The project remains understandable for students while offering enough components for meaningful experimentation and presentation. Because the application clearly separates training from prediction, students can update the dataset, retrain the models, compare metrics, and demonstrate how changes in the input market variables affect the generated gold-price estimate.
Keyword:
Gold Price Prediction
Gold Price Prediction – Google Search
gold price prediction for next 5 years
gold price prediction 2026
gold price prediction for next 5 years in india
gold price prediction for next week india
gold price prediction 2026 in india
gold price prediction for next 6 months
gold price prediction in august 2026
gold price prediction for september 2026
gold price prediction 2027