File size: 2,029 Bytes
9b5b949
c6a3043
9b5b949
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed93193
9408877
c6a3043
 
 
 
 
ed93193
c6a3043
 
 
 
 
 
 
ed93193
c6a3043
 
 
 
 
ed93193
c6a3043
 
 
58bb864
ce914f0
c6a3043
0b627de
c6a3043
350fd36
 
 
 
 
ce914f0
350fd36
 
 
 
7e4592e
 
ed93193
bd01af3
 
 
 
 
 
7e4592e
ed93193
7e4592e
 
 
 
 
 
ed93193
9408877
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
---
---
language: en
tags:
- time-series
- forecasting
- lstm
- arima
- stock-market
license: mit
datasets:
- yahoo-finance
metrics:
- rmse
- mape
---

# LSTM Stock Price Forecasting

This repository contains an **LSTM model** trained on stock closing prices and compared with a traditional ARIMA baseline.  
The goal is to forecast future stock values and evaluate which approach generalizes better.  

---

## Dataset
- **Source:** Yahoo Finance  
- **Ticker:** Apple Inc. (AAPL)  
- **Period:** 2015–2023  
- **Feature Used:** Daily closing price  

---

## Models Implemented
- **ARIMA (Auto ARIMA)** — traditional statistical time-series forecasting  
- **LSTM** — deep learning recurrent neural network for sequential data  

---

## Evaluation Results

| Model | RMSE      | MAPE     |
|-------|-----------|----------|
| ARIMA | 15.7959   | 0.0857   |
| LSTM  | 5.8747    | 0.0305   |

**Conclusion:** LSTM significantly outperforms ARIMA with lower RMSE and MAPE, showing its ability to capture nonlinear patterns in stock prices. Under a single split, LSTM significantly outperforms ARIMA.

---

### Rolling Window Evaluation
| Model | RMSE (avg) | MAPE (avg) |
|-------|------------|------------|
| ARIMA (Rolling Window) | 3.448  | 0.0304 |
| LSTM (Rolling Window)  | 23.282 | 0.1869 |

Under rolling window evaluation, **ARIMA outperforms LSTM**, showing better stability and adaptability across multiple forecasting horizons.


---
## ARIMA vs LSTM Forecasts

**ARIMA Forecast:**
![ARIMA](./forecast_arima.png)

**LSTM Forecast:**
![LSTM](./forecast.png)

## Deployment
- Model hosted on **Hugging Face Hub**  
- Repository: `Jalal10/DataSynthis_ML_JobTask`  
- Includes model weights (`lstm_stock_model.h5`) and usage instructions  

---

## Usage

```python
from huggingface_hub import hf_hub_download
import tensorflow as tf

# Download model
model_path = hf_hub_download(repo_id="Jalal10/DataSynthis_ML_JobTask", filename="lstm_stock_model.h5")

# Load model
model = tf.keras.models.load_model(model_path)