Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: DataSynthis ML JobTask
|
| 3 |
emoji: π¨
|
|
|
|
| 1 |
+
# π Stock Price Forecasting β ARIMA & LSTM
|
| 2 |
+
|
| 3 |
+
This project demonstrates **time-series forecasting** on stock prices using both:
|
| 4 |
+
- **ARIMA** (classical statistical model)
|
| 5 |
+
- **LSTM** (deep learning model)
|
| 6 |
+
|
| 7 |
+
The app is deployed with **Gradio on Hugging Face Spaces** so you can upload stock price data and generate **future forecasts interactively**.
|
| 8 |
+
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
## π Features
|
| 12 |
+
β
Upload your own stock CSV (must include a **`Close`** column).
|
| 13 |
+
β
Forecast with **ARIMA**, **LSTM**, or **Compare Both**.
|
| 14 |
+
β
Interactive **forecast horizon slider (5β30 days)**.
|
| 15 |
+
β
**Forecasted table** + **visual chart** output.
|
| 16 |
+
β
Clean, modular code for easy extension.
|
| 17 |
+
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## π§ Models Used
|
| 21 |
+
- **ARIMA** (`arima.pkl`)
|
| 22 |
+
- Captures autocorrelation and seasonality in time series.
|
| 23 |
+
- **LSTM** (`lstm.pth`)
|
| 24 |
+
- Learns nonlinear sequential dependencies in stock prices.
|
| 25 |
+
|
| 26 |
+
Both models are pre-trained and loaded inside the app.
|
| 27 |
+
|
| 28 |
+
---
|
| 29 |
+
|
| 30 |
+
## π Project Structure
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
βββ app.py # Main Gradio app
|
| 34 |
+
βββ arima.pkl # Saved ARIMA model
|
| 35 |
+
βββ lstm.pth # Trained LSTM model
|
| 36 |
+
βββ requirements.txt # Dependencies
|
| 37 |
+
βββ README.md # Documentation
|
| 38 |
+
|
| 39 |
+
````
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π Input Format
|
| 44 |
+
Upload a **CSV file** with at least one column:
|
| 45 |
+
|
| 46 |
+
| Date | Open | High | Low | Close | Volume |
|
| 47 |
+
|------------|--------|--------|--------|---------|---------|
|
| 48 |
+
| 2024-01-01 | 100.25 | 101.20 | 99.80 | 100.90 | 2000000 |
|
| 49 |
+
| 2024-01-02 | 100.90 | 102.10 | 100.30 | 101.70 | 1800000 |
|
| 50 |
+
| ... | ... | ... | ... | ... | ... |
|
| 51 |
+
|
| 52 |
+
Only the **`Close`** column is required.
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## βοΈ Installation & Run Locally
|
| 57 |
+
Clone this repo and install dependencies:
|
| 58 |
+
```bash
|
| 59 |
+
git clone https://huggingface.co/spaces/mrshibly/DataSynthis_ML_JobTask
|
| 60 |
+
cd DataSynthis_ML_JobTask
|
| 61 |
+
pip install -r requirements.txt
|
| 62 |
+
````
|
| 63 |
+
|
| 64 |
+
Run the app locally:
|
| 65 |
+
|
| 66 |
+
```bash
|
| 67 |
+
python app.py
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
The app will run on: [http://localhost:7860](http://localhost:7860)
|
| 71 |
+
|
| 72 |
+
---
|
| 73 |
+
|
| 74 |
+
## π Deployment on Hugging Face Spaces
|
| 75 |
+
|
| 76 |
+
This project is ready to run on **Hugging Face Spaces (Gradio)**.
|
| 77 |
+
|
| 78 |
+
* Upload `app.py`, `arima.pkl`, `lstm.pth`, `requirements.txt`, and `README.md`.
|
| 79 |
+
* Hugging Face will automatically detect `app.py` and launch the Gradio app.
|
| 80 |
+
|
| 81 |
+
---
|
| 82 |
+
|
| 83 |
+
## π Example Output
|
| 84 |
+
|
| 85 |
+
**Forecast Horizon: 10 days, Compare Both**
|
| 86 |
+
|
| 87 |
+
* **Forecast Table**
|
| 88 |
+
| Future | ARIMA Forecast | LSTM Forecast |
|
| 89 |
+
|--------|----------------|---------------|
|
| 90 |
+
| t+1 | 101.2 | 101.5 |
|
| 91 |
+
| t+2 | 101.4 | 102.1 |
|
| 92 |
+
| ... | ... | ... |
|
| 93 |
+
|
| 94 |
+
* **Forecast Plot**
|
| 95 |
+
Historical data (blue) + Predictions (orange/green).
|
| 96 |
+
|
| 97 |
+
---
|
| 98 |
+
|
| 99 |
+
## π‘ Why This Project is Interesting
|
| 100 |
+
|
| 101 |
+
* Combines **traditional stats** and **modern deep learning** in one tool.
|
| 102 |
+
* Clear comparison of model performance for real-world time series.
|
| 103 |
+
* Deployed in an interactive way β **turns research into a product**.
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## π¨βπ» Author
|
| 108 |
+
|
| 109 |
+
Developed by **[Md. Mahmudur Rahman]**
|
| 110 |
+
*Built as part of a job interview task β demonstrating forecasting, ML/DL, and deployment skills.*
|
| 111 |
+
|
| 112 |
---
|
| 113 |
title: DataSynthis ML JobTask
|
| 114 |
emoji: π¨
|