Python 时间序列预测(销量)

Python Time Series forecasting (sales volumes)

我正在尝试对连锁店半年的每日现金流量(流入 - 流出)进行预测。我有过去 3 年的每日现金流入和现金流出、inflation 利率、国定假日日期和商店数量。已使用 pandas 数据框处理数据。

哪些 Python 工具(库、算法)最适合预测?

我建议按照这些步骤操作:

  • 找到日期和销售数量或任何其他变量之间的相关性(但我认为日期会起到作用,人们通常会在假期和周末购买更多东西)你可以使用 numpy 库here

  • 假设销售遵循季节性趋势或周末精选销售,您应该根据日期计算这些特征,您可以将列添加到数据框,例如 dayofweek 、 season .. , pandas 非常适合 dt.dayofweek 就这么简单,将数据拆分为训练集和测试集。

  • 现在很酷,您可以使用 sklearn here i think it will work great! you can try other algorithm as well such as Ridge regression... alot of examples can be found on the sklearn web site http://scikit-learn.org
  • 尝试线性回归
  • 评估你的模型!

你可以看看TSFresh, that is a popular python library for extraction of features from time-series. Then you need to experiment with algorithms and the most popular python library for that is Scikit-learn.

我肯定会建议导入、表示和进行基本(或不太基本)转换和分析的常用基本工具是:

  • pandas 提供 "smart" 数据结构,允许轻松导入数据并执行许多转换
  • Jupyter轻松创建集成叙述文本、代码和结果的笔记本
  • matplotlib方便数据作图(pandas中也有一个plot API就是基于它)

特别是关于时间序列预测我不太了解:你应该能够使用 pandas 实现基本算法,否则我通过快速谷歌搜索找到的有用库示例是 StatsModels and Prophet