一个库,它统一了Python生态系统中最常用库的API和时间序列预测的建模技术。
hcrystalball的Python项目详细描述
H晶体球
HCrystal Ball由两个主要部分组成:
- Wrappers—它们带来了不同的第三方 与时间序列兼容的sklearn API库
- Model Selection—启用包装器、通用或定制变压器的网格搜索 并在整个过程中添加方便的图层(访问结果、绘图、存储等)
文件
请参阅文档site上的示例、教程、贡献、API和更多内容site尝试使用binder上的笔记本或直接浏览docs/examples中的示例笔记本。在
堆芯安装
如果你想要最小限度的安装,你可以从pip或conda forge安装
pip install hcrystalball^{pr2}$
典型安装
通常您需要使用更多的包装器,而不仅仅是Sklearn,在jupyterlab中运行示例,或者并行执行模型选择。让这些依赖项很好地一起运行可能会很麻烦,所以检查envrionment.yml
可能会让您更快地开始。在
# get dependencies file, e.g. using curl curl -O https://raw.githubusercontent.com/heidelbergcement/hcrystalball/master/environment.yml # check comments in environment.yml, keep or remove as requested, than create environment using conda env create -f environment.yml # activate the environment conda activate hcrystalball # if you want to see progress bar in jupyterlab, execute also jupyter labextension install @jupyter-widgets/jupyterlab-manager # install the library from pip pip install hcrystalball # or from conda conda install -c conda-forge hcrystalball
开发安装:
要准备好一切,包括文档构建或执行测试,请执行以下代码
git clone https://github.com/heidelbergcement/hcrystalball cd hcrystalball conda env create -f environment.yml conda activate hcrystalball # ensures interactive progress bar will work in example notebooks jupyter labextension install @jupyter-widgets/jupyterlab-manager python setup.py develop
示例用法
包装器
fromhcrystalball.utilsimportgenerate_tsdatafromhcrystalball.wrappersimportProphetWrapperX,y=generate_tsdata(n_dates=365*2)X_train,y_train,X_test,y_test=X[:-10],y[:-10],X[-10:],y[-10:]model=ProphetWrapper()y_pred=model.fit(X_train,y_train).predict(X_test)y_predprophet2018-12-226.0669992018-12-236.0500762018-12-246.1056202018-12-256.1419532018-12-266.1502292018-12-276.1636152018-12-286.1474202018-12-296.0486332018-12-306.0317112018-12-316.087255
选型
importpandasaspdimportmatplotlib.pyplotaspltplt.style.use('seaborn')plt.rcParams['figure.figsize']=[12,6]fromhcrystalball.utilsimportget_sales_datafromhcrystalball.model_selectionimportModelSelectordf=get_sales_data(n_dates=200,n_assortments=1,n_states=2,n_stores=2)ms=ModelSelector(horizon=10,frequency="D",country_code_column="HolidayCode",)ms.create_gridsearch(n_splits=2,sklearn_models=True,prophet_models=False,exog_cols=["Open","Promo","SchoolHoliday","Promo2"],)ms.select_model(df=df,target_col_name="Sales",partition_columns=["Assortment","State","Store"],)ms.plot_results(plot_from="2015-06-01",partitions=[{"Assortment":"a","State":"NW","Store":335}])
- 项目
标签: