This project provides implementations for univariate time series forecasting using ARIMA, Auto-ARIMA, and LSTM models. The code is modular and designed for easy adaptation to various datasets and forecasting requirements.
This repository contains code for forecasting univariate time series data using ARIMA, Auto-ARIMA, and LSTM models. The project is structured to be easily extensible and reusable for different datasets and forecasting scenarios.
- Data preparation and scaling
- Hyperparameter tuning for ARIMA and LSTM models
- Rolling and expanding window evaluation methods
- Plotting results and summary metrics
- Python 3.7 or later
- Required packages listed in
requirements.txt
Clone the repository:
git clone https://github.com/zhaleh-rahimi/univariate-time-series-forecasting.git
cd univariate-time-series-forecastingInstall the required packages:
pip install -r requirements.txtRun the main script with the necessary arguments:
python main.py --file_path data/your_data.csv --date_col date --target_col target --model_type ARIMA --evaluation_type rolling --output_file results/output.csv --steps 4--file_path: Path to the CSV file containing the time series data--date_col: Name of the date column in the CSV file--target_col: Name of the target column in the CSV file--model_type: Type of model to use (ARIMA,AUTO-ARIMA,LSTM)--evaluation_type: Type of evaluation method (rolling,expanding)--output_file: Path to save the output CSV file--steps: Number of steps ahead to forecast
The data is loaded using the DataPrep class, which also handles scaling and splitting the data into training and testing sets.It also can prepare a dataset for a supervised learning process, e.g. LSTM forecasting.
Data is scaled using the MinMaxScaler from sklearn.preprocessing. One may change the scaler.
Implemented in the ARIMAModel class. Hyperparameters are selected using grid search and minimizing mse for imeplemented ARIMA.
Implemented in the AutoARIMA class using the pmdarima library.
Implemented in the LSTMModel class. Hyperparameters are selected using grid search.
Evaluates the model performance using a rolling window approach.
Evaluates the model performance using an expanding window approach.
The results are saved to a CSV file and can be visualized using the provided plotting functions.
This project is licensed under the MIT License - see the LICENSE file for details.