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规范。欢迎任何形式的贡献!

编辑推荐精选

TRAE编程

TRAE编程

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

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

AI工具TraeAI IDE协作生产力转型热门
蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

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

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

讯飞智文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

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

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

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

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多