statsforecast

statsforecast

快速高效的统计时间序列预测工具

StatsForecast是一个专注于统计时间序列预测的Python库。它集成了多种常用模型如ARIMA、ETS等,并通过numba实现高性能计算。该库支持概率预测、外生变量处理和异常检测,可与Spark等大数据框架无缝对接。StatsForecast能高效处理大规模时间序列数据,适用于生产环境和基准测试。

StatsForecast时间序列预测统计模型自动模型性能优化Github开源项目

Nixtla   发推  Slack

<!-- ALL-CONTRIBUTORS-BADGE:START - 请勿删除或修改此部分 -->

所有贡献者

<!-- ALL-CONTRIBUTORS-BADGE:END --> <div align="center"> <img src="https://yellow-cdn.veclightyear.com/0a4dffa0/72d90368-2759-48f1-8603-e717b85baccf.png"> <h1 align="center">统计 ⚡️ 预测</h1> <h3 align="center">使用统计和计量经济模型进行快速预测</h3>

CI Python PyPi conda-nixtla 许可证 文档 下载量

StatsForecast提供了广泛使用的单变量时间序列预测模型集合,包括使用numba优化的自动ARIMAETSCESTheta建模,以实现高性能。它还包括大量基准测试模型。

</div>

安装

您可以通过以下方式安装StatsForecast

pip install statsforecast

conda install -c conda-forge statsforecast

访问我们的安装指南获取更多说明。

快速开始

最小示例

from statsforecast import StatsForecast from statsforecast.models import AutoARIMA from statsforecast.utils import AirPassengersDF df = AirPassengersDF sf = StatsForecast( models = [AutoARIMA(season_length = 12)], freq = 'M' ) sf.fit(df) sf.predict(h=12, level=[95])

从这个快速指南开始。

按照这个端到端演练了解最佳实践。

为什么?

目前Python中用于统计模型的替代方案速度慢、不准确且扩展性差。因此,我们创建了一个可以在生产环境中使用或作为基准的库。StatsForecast包含大量可以高效拟合数百万时间序列的模型。

特性

  • Python中最快和最准确的AutoARIMAAutoETSAutoCESMSTLTheta实现。
  • 与Spark、Dask和Ray开箱即用的兼容性。
  • 概率预测和置信区间。
  • 支持外生变量和静态协变量。
  • 异常检测。
  • 熟悉的sklearn语法:.fit.predict

亮点

  • ARIMA包含外生变量预测区间
  • pmdarima快20倍链接
  • R快1.5倍。
  • Prophet快500倍。
  • statsmodels快4倍链接
  • 通过numba编译为高性能机器代码。
  • 使用ray30分钟内处理1,000,000个序列。
  • 用两行代码替换FB-Prophet,提高速度和准确性。查看这里的实验。
  • 1,000,000个序列上拟合10个基准模型,用时不到5分钟

缺少什么?请开一个issue或在Slack上联系我们

示例和指南

📚 端到端演练:多个时间序列的模型训练、评估和选择

🔎 异常检测:使用样本内预测区间检测时间序列的异常。

👩‍🔬 交叉验证:稳健的模型性能评估。

❄️ 多重季节性:如何使用MSTL预测具有多重季节性的数据。

🔌 预测需求高峰:电力负荷预测,用于检测每日高峰并降低电费。 📈 间歇性需求:预测非零观测值很少的时间序列。

🌡️ 外生回归因子:如天气或价格

模型

自动预测

自动预测工具搜索最佳参数并为一组时间序列选择最佳可能模型。这些工具适用于大量单变量时间序列。

模型点预测概率预测样本内拟合值概率拟合值外生特征
自动ARIMA
自动ETS
自动CES
自动Theta

ARIMA族

这些模型利用时间序列中存在的自相关性。

模型点预测概率预测样本内拟合值概率拟合值外生特征
ARIMA
自回归

Theta族

对去季节性的时间序列拟合两条theta线,使用不同技术获取并组合两条theta线以产生最终预测。

模型点预测概率预测样本内拟合值概率拟合值外生特征
Theta
优化Theta
动态Theta
动态优化Theta

多重季节性

适用于具有多个明显季节性的信号。对于电力和日志等低频数据很有用。

模型点预测概率预测样本内拟合值概率拟合值外生特征
MSTL如果趋势预测器支持

GARCH和ARCH模型

适用于建模随时间表现出非恒定波动性的时间序列。ARCH模型是GARCH的特例。

模型点预测概率预测样本内拟合值概率拟合值外生特征
GARCH
ARCH

基准模型

用于建立基准的经典模型。

模型点预测概率预测样本内拟合值概率拟合值外生特征
历史平均
朴素
带漂移随机游走
季节性朴素
窗口平均
季节性窗口平均

指数平滑

使用所有过去观测值的加权平均,其中权重向过去呈指数递减。适用于具有明显趋势和/或季节性的数据。对于没有明显趋势或季节性的数据,使用简单指数族。

模型点预测概率预测样本内拟合值概率拟合值外生特征
简单指数平滑
优化简单指数平滑
季节性指数平滑
优化季节性指数平滑
Holt
Holt-Winters

稀疏或间歇性

适用于非零观测值很少的时间序列

模型点预测概率预测样本内拟合值概率拟合值外生特征
ADIDA
CrostonClassic
CrostonOptimized
CrostonSBA
IMAPA
TSB

🔨 如何贡献

请参阅CONTRIBUTING.md

引用

@misc{garza2022statsforecast, author={Federico Garza, Max Mergenthaler Canseco, Cristian Challú, Kin G. Olivares}, title = {{StatsForecast}: 基于统计和计量经济模型的超快速预测}, year={2022}, howpublished={{PyCon} 盐湖城, 犹他州, 美国 2022}, url={https://github.com/Nixtla/statsforecast} }

贡献者 ✨

感谢这些优秀的人(表情符号说明):

<!-- ALL-CONTRIBUTORS-LIST:START - 请勿删除或修改此部分 --> <!-- prettier-ignore-start --> <!-- markdownlint-disable --> <table> <tbody> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/FedericoGarza"><img src="https://avatars.githubusercontent.com/u/10517170?v=4?s=100" width="100px;" alt="fede"/><br /><sub><b>fede</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=FedericoGarza" title="代码">💻</a> <a href="#maintenance-FedericoGarza" title="维护">🚧</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jmoralez"><img src="https://avatars.githubusercontent.com/u/8473587?v=4?s=100" width="100px;" alt="José Morales"/><br /><sub><b>José Morales</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=jmoralez" title="代码">💻</a> <a href="#maintenance-jmoralez" title="维护">🚧</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/sugatoray/"><img src="https://avatars.githubusercontent.com/u/10201242?v=4?s=100" width="100px;" alt="Sugato Ray"/><br /><sub><b>Sugato Ray</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=sugatoray" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="http://www.jefftackes.com"><img src="https://avatars.githubusercontent.com/u/9125316?v=4?s=100" width="100px;" alt="Jeff Tackes"/><br /><sub><b>Jeff Tackes</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/issues?q=author%3Atackes" title="错误报告">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/darinkist"><img src="https://avatars.githubusercontent.com/u/62692170?v=4?s=100" width="100px;" alt="darinkist"/><br /><sub><b>darinkist</b></sub></a><br /><a href="#ideas-darinkist" title="想法、规划与反馈">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/alech97"><img src="https://avatars.githubusercontent.com/u/22159405?v=4?s=100" width="100px;" alt="Alec Helyar"/><br /><sub><b>Alec Helyar</b></sub></a><br /><a href="#question-alech97" title="回答问题">💬</a></td> <td align="center" valign="top" width="14.28%"><a href="https://dhirschfeld.github.io"><img src="https://avatars.githubusercontent.com/u/881019?v=4?s=100" width="100px;" alt="Dave Hirschfeld"/><br /><sub><b>Dave Hirschfeld</b></sub></a><br /><a href="#question-dhirschfeld" title="回答问题">💬</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/mergenthaler"><img src="https://avatars.githubusercontent.com/u/4086186?v=4?s=100" width="100px;" alt="mergenthaler"/><br /><sub><b>mergenthaler</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=mergenthaler" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/kdgutier"><img src="https://avatars.githubusercontent.com/u/19935241?v=4?s=100" width="100px;" alt="Kin"/><br /><sub><b>Kin</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=kdgutier" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Yasslight90"><img src="https://avatars.githubusercontent.com/u/58293883?v=4?s=100" width="100px;" alt="Yasslight90"/><br /><sub><b>Yasslight90</b></sub></a><br /><a href="#ideas-Yasslight90" title="想法、规划与反馈">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/asinig"><img src="https://avatars.githubusercontent.com/u/99350687?v=4?s=100" width="100px;" alt="asinig"/><br /><sub><b>asinig</b></sub></a><br /><a href="#ideas-asinig" title="想法、规划与反馈">🤔</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/guerda"><img src="https://avatars.githubusercontent.com/u/230782?v=4?s=100" width="100px;" alt="Philip Gillißen"/><br /><sub><b>Philip Gillißen</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=guerda" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/shagn"><img src="https://avatars.githubusercontent.com/u/16029092?v=4?s=100" width="100px;" alt="Sebastian Hagn"/><br /><sub><b>Sebastian Hagn</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/issues?q=author%3Ashagn" title="错误报告">🐛</a> <a href="https://github.com/Nixtla/statsforecast/commits?author=shagn" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/fugue-project/fugue"><img src="https://avatars.githubusercontent.com/u/21092479?v=4?s=100" width="100px;" alt="Han Wang"/><br /><sub><b>Han Wang</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=goodwanghan" title="代码">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/benjamin-jeffrey-218548a8/"><img src="https://avatars.githubusercontent.com/u/36240394?v=4?s=100" width="100px;" alt="Ben Jeffrey"/><br /><sub><b>Ben Jeffrey</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/issues?q=author%3Abjeffrey92" title="错误报告">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Beliavsky"><img src="https://avatars.githubusercontent.com/u/38887928?v=4?s=100" width="100px;" alt="Beliavsky"/><br /><sub><b>Beliavsky</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=Beliavsky" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/MMenchero"><img src="https://avatars.githubusercontent.com/u/47995617?v=4?s=100" width="100px;" alt="Mariana Menchero García "/><br /><sub><b>Mariana Menchero García </b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=MMenchero" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/guptanick/"><img src="https://avatars.githubusercontent.com/u/33585645?v=4?s=100" width="100px;" alt="Nikhil Gupta"/><br /><sub><b>Nikhil Gupta</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/issues?q=author%3Angupta23" title="错误报告">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jdegene"><img src="https://avatars.githubusercontent.com/u/17744939?v=4?s=100" width="100px;" alt="JD"/><br /><sub><b>JD</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/issues?q=author%3Ajdegene" title="错误报告">🐛</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jattenberg"><img src="https://avatars.githubusercontent.com/u/924185?v=4?s=100" width="100px;" alt="josh attenberg"/><br /><sub><b>josh attenberg</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=jattenberg" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/JeroenPeterBos"><img src="https://avatars.githubusercontent.com/u/15342738?v=4?s=100" width="100px;" alt="JeroenPeterBos"/><br /><sub><b>JeroenPeterBos</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=JeroenPeterBos" title="代码">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/jvdd"><img src="https://avatars.githubusercontent.com/u/18898740?v=4?s=100" width="100px;" alt="Jeroen Van Der Donckt"/><br /><sub><b>Jeroen Van Der Donckt</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=jvdd" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/Roymprog"><img src="https://avatars.githubusercontent.com/u/4035367?v=4?s=100" width="100px;" alt="Roymprog"/><br /><sub><b>Roymprog</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=Roymprog" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/nelsoncardenas"><img src="https://avatars.githubusercontent.com/u/18086414?v=4?s=100" width="100px;" alt="Nelson Cárdenas Bolaño"/><br /><sub><b>Nelson Cárdenas Bolaño</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=nelsoncardenas" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/kschmaus"><img src="https://avatars.githubusercontent.com/u/6586847?v=4?s=100" width="100px;" alt="Kyle Schmaus"/><br /><sub><b>Kyle Schmaus</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=kschmaus" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/akmal-soliev/"><img src="https://avatars.githubusercontent.com/u/24494206?v=4?s=100" width="100px;" alt="Akmal Soliev"/><br /><sub><b>Akmal Soliev</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=akmalsoliev" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/nickto"><img src="https://avatars.githubusercontent.com/u/11967792?v=4?s=100" width="100px;" alt="Nick To"/><br /><sub><b>Nick To</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=nickto" title="代码">💻</a></td> <td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/kvnkho/"><img src="https://avatars.githubusercontent.com/u/32503212?v=4?s=100" width="100px;" alt="Kevin Kho"/><br /><sub><b>Kevin Kho</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=kvnkho" title="代码">💻</a></td> </tr> <tr> <td align="center" valign="top" width="14.28%"><a href="https://github.com/yibenhuang"><img src="https://avatars.githubusercontent.com/u/62163340?v=4?s=100" width="100px;" alt="黄一本"/><br /><sub><b>黄一本</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=yibenhuang" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/andrewgross"><img src="https://avatars.githubusercontent.com/u/370118?v=4?s=100" width="100px;" alt="安德鲁·格罗斯"/><br /><sub><b>安德鲁·格罗斯</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=andrewgross" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://github.com/taniishkaaa"><img src="https://avatars.githubusercontent.com/u/109246904?v=4?s=100" width="100px;" alt="taniishkaaa"/><br /><sub><b>taniishkaaa</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=taniishkaaa" title="文档">📖</a></td> <td align="center" valign="top" width="14.28%"><a href="https://manuel.calzolari.name"><img src="https://avatars.githubusercontent.com/u/2764902?v=4?s=100" width="100px;" alt="曼努埃尔·卡尔佐拉里"/><br /><sub><b>曼努埃尔·卡尔佐拉里</b></sub></a><br /><a href="https://github.com/Nixtla/statsforecast/commits?author=manuel-calzolari" title="代码">💻</a></td> </tr> </tbody> </table> <!-- markdownlint-restore --> <!-- prettier-ignore-end --> <!-- ALL-CONTRIBUTORS-LIST:END -->

本项目遵循all-contributors规范。欢迎任何形式的贡献!

编辑推荐精选

博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

热门AI工具AI办公办公工具智能排版AI生成PPT博思AIPPT海量精品模板AI创作
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

AI助手热门AI工具AI创作AI辅助写作讯飞绘文内容运营个性化文章多平台分发
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
商汤小浣熊

商汤小浣熊

最强AI数据分析助手

小浣熊家族Raccoon,您的AI智能助手,致力于通过先进的人工智能技术,为用户提供高效、便捷的智能服务。无论是日常咨询还是专业问题解答,小浣熊都能以快速、准确的响应满足您的需求,让您的生活更加智能便捷。

imini AI

imini AI

像人一样思考的AI智能体

imini 是一款超级AI智能体,能根据人类指令,自主思考、自主完成、并且交付结果的AI智能体。

下拉加载更多