https://github.com/samadpls/goldpredictapi
FastAPI-based gold price prediction system using machine learning. Trained model and API for seamless usability. đđ¤
https://github.com/samadpls/goldpredictapi
api fastapi gold-price-prediction machine-learning pydantic regression-models swagger-ui
Last synced: 6 months ago
JSON representation
FastAPI-based gold price prediction system using machine learning. Trained model and API for seamless usability. đđ¤
- Host: GitHub
- URL: https://github.com/samadpls/goldpredictapi
- Owner: samadpls
- License: mit
- Created: 2024-01-02T19:29:21.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-02T19:37:28.000Z (about 2 years ago)
- Last Synced: 2025-02-12T07:49:35.833Z (11 months ago)
- Topics: api, fastapi, gold-price-prediction, machine-learning, pydantic, regression-models, swagger-ui
- Language: Jupyter Notebook
- Homepage:
- Size: 3.6 MB
- Stars: 8
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GoldPredictAPI đđ¤
This project implements a gold price prediction system using machine learning. The system is trained on historical gold price data and provides a `FastAPI`-based API for making predictions.
## Files đ
- **gld_predication.py**: FastAPI app with a pre-trained model, offering an API endpoint for gold price predictions.
- **Gold Price Prediction.ipynb**: Jupyter Notebook for initial gold price data exploration, preprocessing, and training of the RandomForestRegressor model.
## Dependencies đ ī¸
- FastAPI
- Scikit-learn
- NumPy
- Pandas
- Matplotlib
- Seaborn
## How to Use đ
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Run the FastAPI application:
```bash
uvicorn gld_predication:app --reload
```
This will start the FastAPI server locally.
3. Make predictions using Swagger:
Open your web browser and go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs) to access the Swagger UI.
- Click on the `/predict` endpoint.
- Click on the "Try it out" button.
- Input the sample request data:
```json
{
"SPX": 2671.91992,
"USO": 14.0600,
"SLV": 15.5100,
"EUR_USD": 1.186789
}
```
- Click on the "Execute" button to make a prediction.

4. Make predictions using curl:
Alternatively, you can use `curl` to make predictions:
```bash
curl -X 'POST' \
'http://127.0.0.1:8000/predict' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"SPX": 2671.91992,
"USO": 14.0600,
"SLV": 15.5100,
"EUR_USD": 1.186789
}'
```
## Additional Information âšī¸
- **Colab Notebook**: The `Gold Price Prediction.ipynb` file in Google Colab contains the initial exploration and model training.
- **Model Saving**: The trained model is saved as `gld_data.pkl` using the `pickle` library and loaded by the FastAPI application for predictions.
## License đ
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
---