aka*_*aii 6 python forecasting
例如,如果我有以下时间序列:
x = [1999, 2000, 2001, ... , 2015]
annual_sales = [10000000, 1500000, 1800000, ... , 2800000]
Run Code Online (Sandbox Code Playgroud)
我将如何使用 Python 中的 Holt-Winters 方法预测 2016 年的销售额?
您可以像这样使用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()
Run Code Online (Sandbox Code Playgroud)
生成模型后,您可以使用predict()
.
然而,它似乎只适用于最新版本的 statsmodels。见这里。在我的基于 Windows 10 Anaconda 的 Python 3.6 安装中,我使用了它工作的 statsmodels 0.9.0。
归档时间: |
|
查看次数: |
2091 次 |
最近记录: |