Skip to content

Exponential Smoothing: Brown Simple Method in Python Videos

Last Update: April 24, 2022

My online video tutorials are hosted at YouTube channel.

For learning this concept, you can view my online video tutorials: Exponential Smooting: Brown Simple Method in Python (Spyder) and Exponential Smoothing: Brown Simple Method in Python (Jupyter).

Videos Code

1. Packages

import pandas as pd
import statsmodels.api as sm
import statsmodels.tsa.holtwinters as ets
import matplotlib.pyplot as plt

2. Data

mdata_obj = sm.datasets.get_rdataset(dataname="AirPassengers",
                                     package="datasets",
                                     cache=True)
mdata = mdata_obj.data
mdata = pd.DataFrame(data=mdata["value"]).set_index(
    pd.date_range(start="1949", end="1961", freq="M"))
print(mdata.head())
print(mdata_obj.__doc__)

Ranges Delimiting

tdata = mdata[:"1958-12-31"]
fdata = mdata["1959-01-01":]

3. Exponential Smoothing

Brown Simple Exponential Smoothing

tbrown = ets.ExponentialSmoothing(endog=tdata, trend=None,
                                  damped_trend=False,
                                  seasonal=None,
                                  initialization_method=
                                  "estimated").fit()
fbrown = tbrown.forecast(steps=len(fdata))
fbrown = pd.DataFrame(fbrown).set_index(fdata.index)
plt.figure()
plt.plot(tdata, label="tdata")
plt.plot(fbrown, label="fbrown")
plt.plot(fdata, label="fdata", linestyle="--")
plt.legend(loc="upper left")
plt.title("Simple Exponential Smoothing")
plt.ylabel("Air Passengers")
plt.xlabel("Year")
plt.show()
My online courses are closed for enrollment.
+