Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gold Price Prediction Project

This project predicts the daily GLD price using market features.

It includes:

  • A model training script
  • A FastAPI backend for predictions
  • A Streamlit web app for user input and results

What This Project Does

The model learns from historical data and predicts GLD price from these inputs:

  • SPX
  • USO
  • SLV
  • EUR/USD

Project Structure

  • src/train_model.py trains the model and saves files
  • src/gold_model.py contains shared ML logic (load data, train, save, load, predict)
  • src/api.py provides REST API endpoints
  • src/app.py provides Streamlit UI
  • data/gld_price_data.csv is the dataset
  • artifacts/ stores generated model and metrics

Easy Flow

  1. Run training once.
  2. Training creates model and metrics files in artifacts/.
  3. Start FastAPI backend (model is loaded there).
  4. Streamlit sends user input to FastAPI /predict.
  5. Streamlit shows predicted GLD price from API response.

Output Files After Training

When training finishes, these files are created:

  • artifacts/gold_price_model.joblib (trained model)
  • artifacts/metrics.json (R2, MAE, RMSE)

Setup

Use your virtual environment and install dependencies:

pip install -r requirements.txt

Run Commands

Train model:

python src/train_model.py

Run FastAPI server:

python -m uvicorn src.api:app --reload

Run Streamlit app:

streamlit run app.py

Optional (if backend is not local):

$env:BACKEND_URL="http://127.0.0.1:8000"

API Usage

Base URL after running API:

  • http://127.0.0.1:8000

Health route:

  • GET /

Prediction route:

  • POST /predict

Example request body:

{
  "spx": 1447.16,
  "uso": 78.47,
  "slv": 15.18,
  "eurUsd": 1.471692
}

Example response:

{
  "predicted_gld_price": 84.98
}

Notes

  • If Streamlit cannot predict, ensure FastAPI is running and BACKEND_URL is correct.
  • This project is for learning and experimentation.
  • It is not financial advice.

Get This Repository

Clone from GitHub:

git clone https://github.com/saimtec/Gold-Price-Prediction.git
cd Gold-Price-Prediction

Install dependencies:

pip install -r requirements.txt

About

Gold price prediction app built with scikit-learn, FastAPI, and Streamlit, including reproducible training and model artifact management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages