【问题标题】:Using Holt-winters, ARIMA, exponential smoothing, etc. to forecast time series value in Python在 Python 中使用 Holt-winters、ARIMA、指数平滑等来预测时间序列值
【发布时间】:2016-06-27 12:16:07
【问题描述】:

例如,如果我有以下时间序列:

x = [1999, 2000, 2001, ... , 2015]
annual_sales = [10000000, 1500000, 1800000, ... , 2800000]

如何在 Python 中使用 Holt-Winters 方法预测 2016 年的销售额?

【问题讨论】:

    标签: python forecasting


    【解决方案1】:

    您可以像这样使用 Statsmodels.tsa 的 ExponentialSmoothing:

    import pandas as pd
    import statsmodels.tsa.holtwinters as hw    
    
    d = {'Year':x, 'Sales':annual_sales}
    sales_df = pd.DataFrame(d)
    sales_df['Year] = pd.to_datetime(sales_df['Year])
    sales_df.set_index('Year', inplace=True)
    
    model = hw.ExponentialSmoothing(sales_df).fit()
    

    模型生成后,您可以使用predict()

    不过,它似乎只适用于最新版本的 statsmodels。见here。在我的基于 Windows 10 Anaconda 的 Python 3.6 安装中,我使用了 statsmodels 0.9.0,它可以在其中工作。

    【讨论】:

    • 不要只链接到解决方案。在答案正文中解释解决方案。
    猜你喜欢
    • 2018-11-19
    • 2017-06-02
    • 2020-09-17
    • 2011-08-17
    • 1970-01-01
    • 2023-04-11
    • 2012-09-16
    • 2014-11-04
    相关资源
    最近更新 更多