File size: 2,700 Bytes
f190052 4beaeb0 f190052 4beaeb0 ade9f92 4beaeb0 f190052 ca51b56 f190052 |
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 |
---
library_name: tensorflow
tags:
- time-series-forecasting
- stock-forecasting
inference: false # repo itself isn't running code
pipeline_tag: time-series-forecasting
license: apache-2.0
spaces:
- Ti-sha/Stock_Forecaster # deployed Space
---
# Stock Price Forecasting with ARIMA and LSTM
This repository contains a Python script for time-series forecasting of stock prices using both a traditional statistical model (ARIMA) and a deep learning model (LSTM). The models are trained and evaluated on the "Time Series Forecasting with Yahoo Stock Price" dataset, and their performance is compared.
## Files in this Repository
* `stock_forecasting.py`: The main Python script that performs the following:
* Loads and preprocesses the `yahoo_stock.csv` dataset.
* Implements, trains, and evaluates an ARIMA model.
* Implements, trains, and evaluates an LSTM model.
* Generates a plot comparing the actual prices with the forecasts from both models (`stock_forecast.png`).
* Prints a performance comparison table and a discussion of the results to the console.
* `yahoo_stock.csv`: The dataset used for training and testing the models.
* `requirements.txt`: A list of the Python libraries required to run the script.
## Installation
To run this project, you need to have Python 3 installed. You can install the necessary libraries using pip:
```bash
pip install -r requirements.txt
```
## Usage
To run the forecasting script, execute the following command in your terminal:
```bash
python stock_forecasting.py
```
## Output
After running the script, you will see the following output in your console:
1. **Training progress** for both the ARIMA and LSTM models.
2. **A performance comparison table** showing the Root Mean Squared Error (RMSE) and Mean Absolute Percentage Error (MAPE) for both models.
3. **A discussion and recommendation** on which model generalizes better and why.
Additionally, the script will generate a file named `stock_forecast.png` in the same directory, which contains a plot visualizing the actual stock prices against the ARIMA and LSTM forecasts.
### Example Output
```
Model Performance Comparison
-----------------------------
| Model | RMSE | MAPE (%) |
| :---- | :------ | :------- |
| ARIMA | 278.60 | 7.44 |
| LSTM | 371.12 | 10.35 |
Discussion and Recommendation
------------------------------
Based on the RMSE and MAPE metrics, the ARIMA model performed better than the LSTM model in this particular forecasting task...
```
![Stock Price Forecasting - ARIMA vs LSTM]
 |