## Seánce v0.0.5
A simple wrapper around Nixtla's MLForecast aimed at streamlining plug-and-play forecasting.
A general pattern is to optimize then forecast such as:
```
from mlforecast.utils import generate_daily_series
series = generate_daily_series(
n_series=20,
max_length=100,
min_length=50,
with_trend=True
)
from Seance.Optimizer import Optimize
opt = Optimize(series,
target_column='y',
date_column='ds',
id_column='unique_id',
freq='D',
seasonal_period=7,
test_size=10,
# ar_lags=[list(range(1, 8))], #by default this will be done based on seasonal period
metric='smape',
n_trials=100)
#returns an optuna study obj
best_params, study = opt.fit(seed=1)
```
## optuna plotting
```
import optuna
optuna.visualization.matplotlib.plot_param_importances(study)
```
![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_param_imp.png?raw=true "Param Importance")
Here we can see the most important parameter is (unsurprisingly) the number of lags. Followd by decay which controls the 'forgetfulness' of the basis functions.
```
optuna.visualization.matplotlib.plot_optimization_history(study)
```
![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_study.png?raw=true "Study")
## passing off best params for forecasts
```
from Seance.Forecaster import Forecaster
seance = Forecaster()
output = seance.fit(series,
target_column='y',
date_column='ds',
id_column='unique_id',
freq='D',
**best_params)
predicted = seance.predict(24)
```
## quick plot of the forecasts
```
import matplotlib.pyplot as plt
plot_ser = np.append(series[series['unique_id'] == 'id_00']['y'].values,
predicted[predicted['unique_id'] == 'id_00']['LGBMRegressor'].values)
plt.plot(plot_ser)
plt.vlines(x=len(plot_ser) - 24, ymin=0, ymax=max(plot_ser), linestyle='dashed', color='red')
plt.show()
```
![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_forecast.png?raw=true "Forecast Results")
Raw data
{
"_id": null,
"home_page": "https://github.com/tblume1992/Seance",
"name": "Seance",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "forecasting,time series,lightgbm,mlforecast",
"author": "Tyler Blume",
"author_email": "t-blume@hotmail.com",
"download_url": "",
"platform": null,
"description": "## Se\u00c3\u00a1nce v0.0.5\n\nA simple wrapper around Nixtla's MLForecast aimed at streamlining plug-and-play forecasting.\n\nA general pattern is to optimize then forecast such as:\n\n```\nfrom mlforecast.utils import generate_daily_series\nseries = generate_daily_series(\n n_series=20,\n max_length=100,\n min_length=50,\n with_trend=True\n)\n\n\nfrom Seance.Optimizer import Optimize\nopt = Optimize(series,\n target_column='y',\n date_column='ds',\n id_column='unique_id',\n freq='D',\n seasonal_period=7,\n test_size=10,\n # ar_lags=[list(range(1, 8))], #by default this will be done based on seasonal period\n metric='smape',\n n_trials=100)\n#returns an optuna study obj\nbest_params, study = opt.fit(seed=1)\n```\n## optuna plotting\n```\nimport optuna\noptuna.visualization.matplotlib.plot_param_importances(study)\n```\n![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_param_imp.png?raw=true \"Param Importance\")\nHere we can see the most important parameter is (unsurprisingly) the number of lags. Followd by decay which controls the 'forgetfulness' of the basis functions.\n```\noptuna.visualization.matplotlib.plot_optimization_history(study)\n```\n![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_study.png?raw=true \"Study\")\n## passing off best params for forecasts\n```\nfrom Seance.Forecaster import Forecaster\nseance = Forecaster()\noutput = seance.fit(series,\n target_column='y',\n date_column='ds',\n id_column='unique_id',\n freq='D',\n **best_params)\npredicted = seance.predict(24)\n```\n## quick plot of the forecasts\n```\nimport matplotlib.pyplot as plt\nplot_ser = np.append(series[series['unique_id'] == 'id_00']['y'].values,\n predicted[predicted['unique_id'] == 'id_00']['LGBMRegressor'].values)\nplt.plot(plot_ser)\nplt.vlines(x=len(plot_ser) - 24, ymin=0, ymax=max(plot_ser), linestyle='dashed', color='red')\nplt.show()\n```\n![alt text](https://github.com/tblume1992/Seance/blob/main/static/seance_forecast.png?raw=true \"Forecast Results\")\n",
"bugtrack_url": null,
"license": "",
"summary": "A Wrapper around MLForecast.",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/tblume1992/Seance"
},
"split_keywords": [
"forecasting",
"time series",
"lightgbm",
"mlforecast"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a0c658b3b302675f76c1eeae6c379e97ac859ea8e7070e83c5e4cd5526e71fcc",
"md5": "9f1dda278ea242481e212d9121040742",
"sha256": "02b5cb0d9dc08c5b7684a278e27510ee99004a5ee1b007b3faa2e6ae31f51b86"
},
"downloads": -1,
"filename": "Seance-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9f1dda278ea242481e212d9121040742",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 16679,
"upload_time": "2023-12-04T02:12:55",
"upload_time_iso_8601": "2023-12-04T02:12:55.340203Z",
"url": "https://files.pythonhosted.org/packages/a0/c6/58b3b302675f76c1eeae6c379e97ac859ea8e7070e83c5e4cd5526e71fcc/Seance-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-04 02:12:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tblume1992",
"github_project": "Seance",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "seance"
}