Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Stock Price Forecasting with ARIMA and LSTM
|
| 2 |
+
|
| 3 |
+
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.
|
| 4 |
+
|
| 5 |
+
## Files in this Repository
|
| 6 |
+
|
| 7 |
+
* `stock_forecasting.py`: The main Python script that performs the following:
|
| 8 |
+
* Loads and preprocesses the `yahoo_stock.csv` dataset.
|
| 9 |
+
* Implements, trains, and evaluates an ARIMA model.
|
| 10 |
+
* Implements, trains, and evaluates an LSTM model.
|
| 11 |
+
* Generates a plot comparing the actual prices with the forecasts from both models (`stock_forecast.png`).
|
| 12 |
+
* Prints a performance comparison table and a discussion of the results to the console.
|
| 13 |
+
* `yahoo_stock.csv`: The dataset used for training and testing the models.
|
| 14 |
+
* `requirements.txt`: A list of the Python libraries required to run the script.
|
| 15 |
+
|
| 16 |
+
## Installation
|
| 17 |
+
|
| 18 |
+
To run this project, you need to have Python 3 installed. You can install the necessary libraries using pip:
|
| 19 |
+
|
| 20 |
+
```bash
|
| 21 |
+
pip install -r requirements.txt
|
| 22 |
+
```
|
| 23 |
+
|
| 24 |
+
## Usage
|
| 25 |
+
|
| 26 |
+
To run the forecasting script, execute the following command in your terminal:
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
python stock_forecasting.py
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
## Output
|
| 33 |
+
|
| 34 |
+
After running the script, you will see the following output in your console:
|
| 35 |
+
|
| 36 |
+
1. **Training progress** for both the ARIMA and LSTM models.
|
| 37 |
+
2. **A performance comparison table** showing the Root Mean Squared Error (RMSE) and Mean Absolute Percentage Error (MAPE) for both models.
|
| 38 |
+
3. **A discussion and recommendation** on which model generalizes better and why.
|
| 39 |
+
|
| 40 |
+
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.
|
| 41 |
+
|
| 42 |
+
### Example Output
|
| 43 |
+
|
| 44 |
+
```
|
| 45 |
+
Model Performance Comparison
|
| 46 |
+
-----------------------------
|
| 47 |
+
| Model | RMSE | MAPE (%) |
|
| 48 |
+
| :---- | :------ | :------- |
|
| 49 |
+
| ARIMA | 278.60 | 7.44 |
|
| 50 |
+
| LSTM | 371.12 | 10.35 |
|
| 51 |
+
|
| 52 |
+
Discussion and Recommendation
|
| 53 |
+
------------------------------
|
| 54 |
+
Based on the RMSE and MAPE metrics, the ARIMA model performed better than the LSTM model in this particular forecasting task...
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
![Stock Price Forecasting - ARIMA vs LSTM]
|
| 58 |
+
|
| 59 |
+

|