https://dps-ai-model-ishq.onrender.com/predict - run it on postman api
This project is a Flask-based API that provides predictions using time-series forecasting models. It allows users to input a specific year and month and returns the predicted value for that period.
- Implements SARIMA, Prophet, and a Hybrid model (combining both SARIMA and Prophet) for forecasting.
- Provides a RESTful API to interact with the forecasting system.
- Error metrics for each model are stored in respective folders as
.txt
files, along with their corresponding plots. - SARIMA was found to perform the best with minor parameter tuning.
The dataset used for training and testing the models is available at the following link:
Monatszahlen Verkehrsunfälle Dataset
- Filtered data for:
AUSPRAEGUNG = 'insgesamt'
MONATSZAHL = 'Alkoholunfälle'
- Removed rows with
MONAT = 'Summe'
. - Ensured valid numeric values in the
MONAT
column. - Converted the
MONAT
column to a datetime format and set it as the index.
-
Clone the Repository:
git clone https://github.com/medss19/DPS-AI-Model cd DPS-AI-Model
-
Set Up Virtual Environment (Optional but Recommended):
python -m venv venv source venv/bin/activate # For Linux/Mac venv\Scripts\activate # For Windows
-
Install Dependencies:
pip install -r requirements.txt
-
Prepare Dataset:
- Place the dataset (
subset.pkl
) in thedatasets/
directory.
- Place the dataset (
-
Run the API:
python app.py
The API will be accessible at
http://127.0.0.1:5000
.
Description: Accepts a JSON payload with the year and month and returns the prediction.
{
"year": 2020,
"month": 10
}
{
"prediction": 39.022958706306206
}
Three models were evaluated: SARIMA, Prophet, and a Hybrid model (combination of SARIMA and Prophet). The error metrics for each model are as follows:
- Mean Absolute Error (MAE): 8.33
- Mean Squared Error (MSE): 80.14
- Root Mean Squared Error (RMSE): 8.95
- Mean Absolute Percentage Error (MAPE): 35.30%
- Mean Absolute Error (MAE): 9.43
- Root Mean Squared Error (RMSE): 11.05
- Mean Absolute Error (MAE): 8.42
- Root Mean Squared Error (RMSE): 9.17
Conclusion: SARIMA performed the best among the three models with minimal parameter tuning.
- Each model’s error metrics are stored in their respective folders as
.txt
files. - Visual plots showcasing the performance of the models are also included in the same folders.
DPS-AI-Model/
│
├── app.py # Flask API
├── Sarima/
│ ├── sarima.py # SARIMA model training and prediction logic
│
├── Prophet/
│ ├── prophet_model.py # Prophet model training and prediction logic
│
├── Hybrid/
│ ├── hybrid_model.py # Hybrid model combining SARIMA and Prophet
│
├── datasets/
│ └── subset.pkl # Dataset for training and testing
│
├── requirements.txt # Project dependencies
└── README.md # Project documentation
- The dataset is preprocessed and fed into the SARIMA, Prophet, and Hybrid models.
- Optimized parameters for the SARIMA model are identified through a grid search.
- Forecasts are generated based on user-provided year and month inputs.
- Python: Core programming language.
- Flask: API development.
- SARIMAX (Statsmodels): Time-series forecasting.
- Prophet: Facebook Prophet for forecasting.
- Pandas: Data manipulation and preprocessing.
- NumPy: Numerical computations.
- Matplotlib: Visualization.
- Add support for dynamic dataset uploads.
- Explore additional models like ARIMA and LSTM.
- Include endpoints for batch predictions.
- Improve the hybrid model with advanced integration techniques.
- Add a front-end dashboard for better visualization.
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements.