# forecast_combine
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
## Overview
forecast_combine is a Python library built upon the foundation of the sktime library, designed to simplify and streamline the process of forecasting and prediction model aggregation. It provides tools for aggregating predictions from multiple models, evaluating their performance, and visualizing the results. Whether you're working on time series forecasting, data analysis, or any other predictive modeling task, forecast_combine offers a convenient and efficient way to handle aggregation and comparison.
## Key Features
- **Model Aggregation:** Easily aggregate predictions from multiple models using various aggregation modes such as best model overall, best model per horizon, inverse score weighted average model, and more.
- **Out-of-Sample Evaluation:** Evaluate model performance using out-of-sample data and choose the best models based on user-defined performance metrics.
- **Visualization:** Visualize model performance, aggregated predictions, and prediction intervals with built-in plotting functions.
- **Flexibility:** Accommodate various aggregation strategies, forecast horizons, and performance metrics to cater to your specific use case.
## Installation
Install Your Package Name using pip:
```bash
pip install forecast_combine
```
## Usage
```python
# Read the data
import pandas as pd
import numpy as np
data = pd.Series(np.cumsum(np.random.normal(0, 1, size=1000)),
index=pd.date_range(end='31/12/2022', periods=1000)
).rename('y').to_frame()
# Import the package
from forecast_combine.model_select import ForecastModelSelect
# Import the packages of the models to test
from sktime.forecasting.naive import NaiveForecaster
from sktime.forecasting.statsforecast import (
StatsForecastAutoARIMA,
StatsForecastAutoETS,
StatsForecastAutoTheta,
StatsForecastAutoTBATS
)
# Define the forecasting models
ForecastingModels = {
"Naive": NaiveForecaster(),
"AutoARIMA": StatsForecastAutoARIMA(),
"AutoETS": StatsForecastAutoETS(),
"AutoTheta": StatsForecastAutoTheta(),
"AutoTBATS": StatsForecastAutoTBATS(seasonal_periods=1),
}
model = ForecastModelSelect(
data= data,
depvar_str = 'y',
exog_l=None,
fh = 10,
pct_initial_window=0.75,
step_length = 5,
forecasters_d = ForecastingModels,
freq = 'B',
mode = 'best_horizon',
score = 'RMSE', )
# evaluate all the models out-of-sample
summary_horizon, summary_results = model.evaluate()
# compare models
rank, score = model.select_best(score = 'MAPE')
# Visualize model comparison
model.plot_model_compare(score ='MAPE', view = 'cutoff')
model.plot_model_compare(score ='MAPE', view = 'horizon')
# Generate prediction
y_pred, y_pred_ints, preds, pred_ints = model.predict(score='RMSE', ret_underlying=True)
# Visualize prediction
model.plot_prediction(y_pred = y_pred,
models_preds = preds,
y_pred_interval = y_pred_ints,
title = 'Prediction')
```
## Documentation
For detailed information about available classes, methods, and parameters, please refer to the [Documentation](https://amineraboun.github.io/forecast/).
## License
This project is licensed under the [MIT License](LICENSE).
## Contributing
We welcome contributions from the community! If you have suggestions, bug reports, or feature requests, please open an issue or submit a pull request.
## Contact
For queries, support, or general inquiries, please feel free to reach me at [amineraboun@gmail.com](mailto:amineraboun@gmail.com).
Raw data
{
"_id": null,
"home_page": "https://github.com/amineraboun/forecast",
"name": "forecast_combine",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.12,>=3.9",
"maintainer_email": null,
"keywords": "arima, ets, theta, tbats, prophet",
"author": "amineraboun",
"author_email": "amineraboun@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a7/18/18fa59f6b33b9147a3ba67814b694b95a4bd2f1d71c57ecb707b013d9a67/forecast_combine-0.0.6.tar.gz",
"platform": null,
"description": "# forecast_combine\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n## Overview\n\nforecast_combine is a Python library built upon the foundation of the sktime library, designed to simplify and streamline the process of forecasting and prediction model aggregation. It provides tools for aggregating predictions from multiple models, evaluating their performance, and visualizing the results. Whether you're working on time series forecasting, data analysis, or any other predictive modeling task, forecast_combine offers a convenient and efficient way to handle aggregation and comparison.\n\n## Key Features\n\n- **Model Aggregation:** Easily aggregate predictions from multiple models using various aggregation modes such as best model overall, best model per horizon, inverse score weighted average model, and more.\n- **Out-of-Sample Evaluation:** Evaluate model performance using out-of-sample data and choose the best models based on user-defined performance metrics.\n- **Visualization:** Visualize model performance, aggregated predictions, and prediction intervals with built-in plotting functions.\n- **Flexibility:** Accommodate various aggregation strategies, forecast horizons, and performance metrics to cater to your specific use case.\n\n## Installation\n\nInstall Your Package Name using pip:\n\n```bash\npip install forecast_combine\n```\n\n## Usage\n\n```python\n# Read the data\nimport pandas as pd\nimport numpy as np\ndata = pd.Series(np.cumsum(np.random.normal(0, 1, size=1000)), \n index=pd.date_range(end='31/12/2022', periods=1000)\n ).rename('y').to_frame()\n\n# Import the package\nfrom forecast_combine.model_select import ForecastModelSelect\n\n# Import the packages of the models to test\nfrom sktime.forecasting.naive import NaiveForecaster\nfrom sktime.forecasting.statsforecast import (\n StatsForecastAutoARIMA,\n StatsForecastAutoETS, \n StatsForecastAutoTheta,\n StatsForecastAutoTBATS\n)\n\n# Define the forecasting models \nForecastingModels = {\n \"Naive\": NaiveForecaster(),\n \"AutoARIMA\": StatsForecastAutoARIMA(),\n \"AutoETS\": StatsForecastAutoETS(),\n \"AutoTheta\": StatsForecastAutoTheta(),\n \"AutoTBATS\": StatsForecastAutoTBATS(seasonal_periods=1),\n}\n\nmodel = ForecastModelSelect(\n data= data,\n depvar_str = 'y', \n exog_l=None,\n fh = 10,\n pct_initial_window=0.75,\n step_length = 5,\n forecasters_d = ForecastingModels,\n freq = 'B',\n mode = 'best_horizon',\n score = 'RMSE', )\n\n# evaluate all the models out-of-sample\nsummary_horizon, summary_results = model.evaluate()\n\n# compare models\nrank, score = model.select_best(score = 'MAPE')\n\n# Visualize model comparison\nmodel.plot_model_compare(score ='MAPE', view = 'cutoff')\nmodel.plot_model_compare(score ='MAPE', view = 'horizon')\n\n# Generate prediction\ny_pred, y_pred_ints, preds, pred_ints = model.predict(score='RMSE', ret_underlying=True)\n\n# Visualize prediction\nmodel.plot_prediction(y_pred = y_pred,\n models_preds = preds,\n y_pred_interval = y_pred_ints, \n title = 'Prediction')\n```\n\n## Documentation\n\nFor detailed information about available classes, methods, and parameters, please refer to the [Documentation](https://amineraboun.github.io/forecast/).\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Contributing\n\nWe welcome contributions from the community! If you have suggestions, bug reports, or feature requests, please open an issue or submit a pull request. \n\n## Contact\n\nFor queries, support, or general inquiries, please feel free to reach me at [amineraboun@gmail.com](mailto:amineraboun@gmail.com).\n",
"bugtrack_url": null,
"license": null,
"summary": "Automation of forecast models testing, combining and predicting",
"version": "0.0.6",
"project_urls": {
"Homepage": "https://github.com/amineraboun/forecast",
"Repository": "https://github.com/amineraboun/forecast"
},
"split_keywords": [
"arima",
" ets",
" theta",
" tbats",
" prophet"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "95d56d00f49fdd1ba7548680332f20e12f5fca695d8c89369cc6a12624809c26",
"md5": "36af10a1b8e49d52a859dafb0a0f3c06",
"sha256": "b16ee8d2569c063ddbe4cc62555b7a798dfe5a6b51f6cc9da2510df35b4f16c8"
},
"downloads": -1,
"filename": "forecast_combine-0.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "36af10a1b8e49d52a859dafb0a0f3c06",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.12,>=3.9",
"size": 33421,
"upload_time": "2024-08-16T14:29:23",
"upload_time_iso_8601": "2024-08-16T14:29:23.477520Z",
"url": "https://files.pythonhosted.org/packages/95/d5/6d00f49fdd1ba7548680332f20e12f5fca695d8c89369cc6a12624809c26/forecast_combine-0.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a71818fa59f6b33b9147a3ba67814b694b95a4bd2f1d71c57ecb707b013d9a67",
"md5": "5f23ec8eb9d0bfb500441529f4bfa933",
"sha256": "84d1b064c3553a9fe7f04d50d4f87c2626fcfb90a4b1205d0c8f957cd76607db"
},
"downloads": -1,
"filename": "forecast_combine-0.0.6.tar.gz",
"has_sig": false,
"md5_digest": "5f23ec8eb9d0bfb500441529f4bfa933",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.12,>=3.9",
"size": 31940,
"upload_time": "2024-08-16T14:29:25",
"upload_time_iso_8601": "2024-08-16T14:29:25.552519Z",
"url": "https://files.pythonhosted.org/packages/a7/18/18fa59f6b33b9147a3ba67814b694b95a4bd2f1d71c57ecb707b013d9a67/forecast_combine-0.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-16 14:29:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "amineraboun",
"github_project": "forecast",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "forecast_combine"
}