{"id":23317968,"url":"https://github.com/medss19/dps-ai-model","last_synced_at":"2026-05-04T07:41:15.427Z","repository":{"id":265265967,"uuid":"895562681","full_name":"medss19/DPS-AI-Model","owner":"medss19","description":"A Flask-based API for time-series forecasting using SARIMA, Prophet, and a Hybrid model, with traffic accident data analysis and visualization.","archived":false,"fork":false,"pushed_at":"2025-01-07T18:04:58.000Z","size":3385,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-07T04:52:50.709Z","etag":null,"topics":["eda","fbprophet","flask-api","hybrid-model","postman","prophet","sarima"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/medss19.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-28T12:49:18.000Z","updated_at":"2025-01-07T18:05:01.000Z","dependencies_parsed_at":"2025-01-07T19:29:21.738Z","dependency_job_id":"d1133210-ad53-42ab-8a51-473e9a1efbf1","html_url":"https://github.com/medss19/DPS-AI-Model","commit_stats":null,"previous_names":["medss19/dps-ai-model"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medss19%2FDPS-AI-Model","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medss19%2FDPS-AI-Model/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medss19%2FDPS-AI-Model/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/medss19%2FDPS-AI-Model/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/medss19","download_url":"https://codeload.github.com/medss19/DPS-AI-Model/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595379,"owners_count":20963943,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eda","fbprophet","flask-api","hybrid-model","postman","prophet","sarima"],"created_at":"2024-12-20T17:14:38.922Z","updated_at":"2026-05-04T07:41:15.399Z","avatar_url":"https://github.com/medss19.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# DPS-AI-Model\r\n\r\n https://dps-ai-model-ishq.onrender.com/predict - run it on postman api\r\n\r\n\r\n## **SARIMA-Based Forecasting API**\r\n\r\nThis 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. \r\n\r\n---\r\n\r\n## **Features**\r\n- Implements **SARIMA**, **Prophet**, and a **Hybrid model** (combining both SARIMA and Prophet) for forecasting.\r\n- Provides a RESTful API to interact with the forecasting system.\r\n- Error metrics for each model are stored in respective folders as `.txt` files, along with their corresponding plots.\r\n- **SARIMA** was found to perform the best with minor parameter tuning.\r\n\r\n---\r\n\r\n## **Dataset**\r\n\r\nThe dataset used for training and testing the models is available at the following link:\r\n\r\n[Monatszahlen Verkehrsunfälle Dataset](https://opendata.muenchen.de/en/dataset/monatszahlen-verkehrsunfaelle/resource/40094bd6-f82d-4979-949b-26c8dc00b9a7)\r\n\r\n### **Preprocessing Steps**\r\n1. Filtered data for:\r\n   - `AUSPRAEGUNG = 'insgesamt'`\r\n   - `MONATSZAHL = 'Alkoholunfälle'`\r\n2. Removed rows with `MONAT = 'Summe'`.\r\n3. Ensured valid numeric values in the `MONAT` column.\r\n4. Converted the `MONAT` column to a datetime format and set it as the index.\r\n\r\n---\r\n\r\n## **Installation**\r\n\r\n1. **Clone the Repository:**\r\n   ```bash\r\n   git clone https://github.com/medss19/DPS-AI-Model\r\n   cd DPS-AI-Model\r\n   ```\r\n\r\n2. **Set Up Virtual Environment (Optional but Recommended):**\r\n   ```bash\r\n   python -m venv venv\r\n   source venv/bin/activate  # For Linux/Mac\r\n   venv\\Scripts\\activate     # For Windows\r\n   ```\r\n\r\n3. **Install Dependencies:**\r\n   ```bash\r\n   pip install -r requirements.txt\r\n   ```\r\n\r\n4. **Prepare Dataset:**\r\n   - Place the dataset (`subset.pkl`) in the `datasets/` directory.\r\n\r\n5. **Run the API:**\r\n   ```bash\r\n   python app.py\r\n   ```\r\n\r\n   The API will be accessible at `http://127.0.0.1:5000`.\r\n\r\n---\r\n\r\n## **API Endpoints**\r\n\r\n### **POST /predict**\r\n\r\n**Description:** Accepts a JSON payload with the year and month and returns the prediction.\r\n\r\n#### **Request Example:**\r\n```json\r\n{\r\n  \"year\": 2020,\r\n  \"month\": 10\r\n}\r\n```\r\n\r\n#### **Response Example:**\r\n```json\r\n{\r\n  \"prediction\": 39.022958706306206\r\n}\r\n```\r\n\r\n---\r\n\r\n## **Model Comparison**\r\n\r\nThree models were evaluated: **SARIMA**, **Prophet**, and a **Hybrid model** (combination of SARIMA and Prophet). The error metrics for each model are as follows:\r\n\r\n### **SARIMA:**\r\n- Mean Absolute Error (MAE): **8.33**\r\n- Mean Squared Error (MSE): **80.14**\r\n- Root Mean Squared Error (RMSE): **8.95**\r\n- Mean Absolute Percentage Error (MAPE): **35.30%**\r\n\r\n### **Prophet:**\r\n- Mean Absolute Error (MAE): **9.43**\r\n- Root Mean Squared Error (RMSE): **11.05**\r\n\r\n### **Hybrid Model:**\r\n- Mean Absolute Error (MAE): **8.42**\r\n- Root Mean Squared Error (RMSE): **9.17**\r\n\r\n**Conclusion:** SARIMA performed the best among the three models with minimal parameter tuning.\r\n\r\n### **Error Metrics and Plots**\r\n- Each model’s error metrics are stored in their respective folders as `.txt` files.\r\n- Visual plots showcasing the performance of the models are also included in the same folders.\r\n\r\n---\r\n\r\n## **Project Structure**\r\n```\r\nDPS-AI-Model/\r\n│\r\n├── app.py                 # Flask API\r\n├── Sarima/\r\n│   ├── sarima.py          # SARIMA model training and prediction logic\r\n│\r\n├── Prophet/\r\n│   ├── prophet_model.py   # Prophet model training and prediction logic\r\n│\r\n├── Hybrid/\r\n│   ├── hybrid_model.py    # Hybrid model combining SARIMA and Prophet\r\n│\r\n├── datasets/\r\n│   └── subset.pkl         # Dataset for training and testing\r\n│\r\n├── requirements.txt       # Project dependencies\r\n└── README.md              # Project documentation\r\n```\r\n\r\n---\r\n\r\n## **How It Works**\r\n1. The dataset is preprocessed and fed into the SARIMA, Prophet, and Hybrid models.\r\n2. Optimized parameters for the SARIMA model are identified through a grid search.\r\n3. Forecasts are generated based on user-provided year and month inputs.\r\n\r\n---\r\n\r\n## **Technologies Used**\r\n- **Python**: Core programming language.\r\n- **Flask**: API development.\r\n- **SARIMAX (Statsmodels)**: Time-series forecasting.\r\n- **Prophet**: Facebook Prophet for forecasting.\r\n- **Pandas**: Data manipulation and preprocessing.\r\n- **NumPy**: Numerical computations.\r\n- **Matplotlib**: Visualization.\r\n\r\n---\r\n\r\n## **Future Improvements**\r\n- Add support for dynamic dataset uploads.\r\n- Explore additional models like ARIMA and LSTM.\r\n- Include endpoints for batch predictions.\r\n- Improve the hybrid model with advanced integration techniques.\r\n- Add a front-end dashboard for better visualization.\r\n\r\n---\r\n\r\n## **Contributing**\r\nContributions are welcome! Please fork the repository and submit a pull request for any enhancements.\r\n\r\n---\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedss19%2Fdps-ai-model","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmedss19%2Fdps-ai-model","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmedss19%2Fdps-ai-model/lists"}