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:

pip install -r requirements.txt

Usage

To run the forecasting script, execute the following command in your terminal:

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]

image

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support