akaii
akaii

Reputation: 103

Using Holt-winters, ARIMA, exponential smoothing, etc. to forecast time series value in Python

For example, if I had the following time series:

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

How would I forecast sales for year 2016 using Holt-Winters method in Python?

Upvotes: 6

Views: 2257

Answers (1)

Neelotpal Shukla
Neelotpal Shukla

Reputation: 476

You could use ExponentialSmoothing from Statsmodels.tsa as such:

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()

Once the model is generated, you can use predict().

It does seem, however, that it is only available for the latest version of statsmodels. See here. In my Windows 10 Anaconda based Python 3.6 installation, I use statsmodels 0.9.0 in which it works.

Upvotes: 5

Related Questions