saif05's picture
Update README.md
4414d79 verified
|
Raw History Blame Contribute Delete
3.08 kB
# πŸ“ˆ Time Series Forecasting – Stock Prices
This project demonstrates how to perform **time series forecasting** on stock prices using both **statistical models** (ARIMA, SARIMAX) and **deep learning (LSTM)**, with proper evaluation techniques like **rolling window forecasting**.
---
## πŸ“‚ Project Overview
The notebook walks through the end-to-end pipeline of forecasting stock prices:
1. **Dataset Acquisition**
- Uses the Kaggle dataset: *World Stock Prices – Daily Updating*
- Downloaded via `kagglehub`
2. **Preprocessing**
- Convert `Date` column to datetime and set as index.
- Sort data by date.
- Filter for a single stock (default: **AAPL**).
- Handle missing values using forward-fill / interpolation.
3. **Exploratory Data Analysis (EDA)**
- Visualize stock closing prices over time.
- Check for stationarity (ADF test).
- Plot ACF/PACF to guide ARIMA orders.
4. **Modeling Approaches**
- **ARIMA**: Baseline forecasting with manually selected parameters.
- **Auto-ARIMA**: Automated parameter tuning using AIC/BIC.
- **SARIMAX**: Seasonal ARIMA with exogenous variables (optional).
- **LSTM**: Deep learning model for sequence prediction.
5. **Forecast Evaluation**
- Implement **rolling window forecasting**:
- Train on initial window β†’ Forecast one step ahead β†’ Update with true value β†’ Repeat.
- Evaluate models using metrics:
- RMSE, MAE, MAPE
---
## βš™οΈ Installation & Requirements
Install dependencies:
```bash
pip install pandas numpy matplotlib seaborn scikit-learn statsmodels pmdarima tensorflow kagglehub
```
If running in **Google Colab**, you may also need:
```bash
pip install kagglehub
```
---
## πŸš€ Usage
1. Clone or download the notebook:
```bash
git clone <repo-link>
cd stock-forecasting
```
2. Run the Jupyter Notebook:
```bash
jupyter notebook "Time_Series_Forecasting_–_Stock_Prices.ipynb"
```
3. Inside the notebook:
- Change the stock ticker (`ticker_symbol = 'AAPL'`) to forecast other stocks.
- Choose between **ARIMA / SARIMAX / LSTM** sections.
- Run evaluation cells to compare results.
---
## πŸ“Š Results
- **ARIMA** works well for short-term stationary series.
- **SARIMAX** captures seasonality but is computationally heavier.
- **LSTM** adapts to nonlinear patterns, showing better performance for long-term forecasts.
- Rolling window evaluation provides realistic performance assessment compared to a single train-test split.
---
## πŸ“Œ Key Files
- `Time_Series_Forecasting_–_Stock_Prices.ipynb` β†’ Main notebook with full workflow
- `world_stock_prices_2_years.csv` β†’ Example filtered dataset for a single stock
---
## ✨ Future Improvements
- Add Prophet model for easier seasonality handling.
- Incorporate financial indicators (RSI, MACD) as exogenous features.
- Deploy as a web dashboard with live forecasts.
---
## πŸ“œ License
This project is for educational and research purposes only. Not financial advice.