{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 18: Smoothing Methods\n",
    "\n",
    "> (c) 2019 Galit Shmueli, Peter C. Bruce, Peter Gedeck \n",
    ">\n",
    "> Code included in\n",
    ">\n",
    "> _Data Mining for Business Analytics: Concepts, Techniques, and Applications in Python_ (First Edition) \n",
    "> Galit Shmueli, Peter C. Bruce, Peter Gedeck, and Nitin R. Patel. 2019.\n",
    "\n",
    "## Import required packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:43.544235Z",
     "iopub.status.busy": "2021-05-27T20:03:43.543774Z",
     "iopub.status.idle": "2021-05-27T20:03:44.422060Z",
     "shell.execute_reply": "2021-05-27T20:03:44.421531Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "no display found. Using non-interactive Agg backend\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pylab as plt\n",
    "import statsmodels.formula.api as sm\n",
    "from statsmodels.tsa import tsatools\n",
    "from statsmodels.tsa.holtwinters import ExponentialSmoothing\n",
    "\n",
    "import dmba\n",
    "\n",
    "%matplotlib inline\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:44.431249Z",
     "iopub.status.busy": "2021-05-27T20:03:44.430792Z",
     "iopub.status.idle": "2021-05-27T20:03:44.433673Z",
     "shell.execute_reply": "2021-05-27T20:03:44.433274Z"
    }
   },
   "outputs": [],
   "source": [
    "# Create the graph\n",
    "def singleGraphLayout(ax, ylim, train_df, valid_df):\n",
    "    ax.set_xlim('1990', '2004-6')\n",
    "    ax.set_ylim(*ylim)\n",
    "    ax.set_xlabel('Time')\n",
    "    one_month = pd.Timedelta('31 days')\n",
    "    xtrain = (min(train_df.index), max(train_df.index) - one_month)\n",
    "    xvalid = (min(valid_df.index) + one_month, max(valid_df.index) - one_month)\n",
    "    xtv = xtrain[1] + 0.5 * (xvalid[0] - xtrain[1])\n",
    "\n",
    "    ypos = 0.9 * ylim[1] + 0.1 * ylim[0]\n",
    "    ax.add_line(plt.Line2D(xtrain, (ypos, ypos), color='black', linewidth=0.5))\n",
    "    ax.add_line(plt.Line2D(xvalid, (ypos, ypos), color='black', linewidth=0.5))\n",
    "    ax.axvline(x=xtv, ymin=0, ymax=1, color='black', linewidth=0.5)\n",
    "\n",
    "    ypos = 0.925 * ylim[1] + 0.075 * ylim[0]\n",
    "    ax.text('1995', ypos, 'Training')\n",
    "    ax.text('2002-3', ypos, 'Validation')\n",
    "\n",
    "def graphLayout(axes, train_df, valid_df):\n",
    "    singleGraphLayout(axes[0], [1300, 2550], train_df, valid_df)\n",
    "    singleGraphLayout(axes[1], [-550, 550], train_df, valid_df)\n",
    "    train_df.plot(y='Ridership', ax=axes[0], color='C0', linewidth=0.75)\n",
    "    valid_df.plot(y='Ridership', ax=axes[0], color='C0', linestyle='dashed', linewidth=0.75)\n",
    "    axes[1].axhline(y=0, xmin=0, xmax=1, color='black', linewidth=0.5)\n",
    "    axes[0].set_xlabel('')\n",
    "    axes[0].set_ylabel('Ridership (in 000s)')\n",
    "    axes[1].set_ylabel('Forecast Errors')\n",
    "    if axes[0].get_legend(): \n",
    "        axes[0].get_legend().remove()\n",
    "    # ensure that both axes have the same x-range\n",
    "    xlim = (min(axes[0].get_xlim()[0], axes[1].get_xlim()[0]), \n",
    "            max(axes[0].get_xlim()[1], axes[1].get_xlim()[1]))\n",
    "    axes[0].set_xlim(*xlim)\n",
    "    axes[1].set_xlim(*xlim)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Figure 18.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:44.440043Z",
     "iopub.status.busy": "2021-05-27T20:03:44.439548Z",
     "iopub.status.idle": "2021-05-27T20:03:44.728500Z",
     "shell.execute_reply": "2021-05-27T20:03:44.728098Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 55520 characters]\n",
      "text/plain": [
       "<Figure size 576x504 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Load data and convert to time series\n",
    "Amtrak_df = dmba.load_data('Amtrak.csv')\n",
    "Amtrak_df['Date'] = pd.to_datetime(Amtrak_df.Month, format='%d/%m/%Y')\n",
    "ridership_ts = pd.Series(Amtrak_df.Ridership.values, index=Amtrak_df.Date, name='Ridership')\n",
    "ridership_ts.index = pd.DatetimeIndex(ridership_ts.index, freq=ridership_ts.index.inferred_freq)\n",
    "\n",
    "# centered moving average with window size = 12\n",
    "ma_centered = ridership_ts.rolling(12, center=True).mean()\n",
    "\n",
    "# trailing moving average with window size = 12\n",
    "ma_trailing = ridership_ts.rolling(12).mean()\n",
    "\n",
    "# shift the average by one time unit\n",
    "ma_centered = pd.Series(ma_centered[:-1].values, index=ma_centered.index[1:])\n",
    "ma_trailing = pd.Series(ma_trailing[:-1].values, index=ma_trailing.index[1:])\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(8, 7))\n",
    "ax = ridership_ts.plot(ax=ax, color='black', linewidth=0.25)\n",
    "ma_centered.plot(ax=ax, linewidth=2)\n",
    "ma_trailing.plot(ax=ax, style='--', linewidth=2)\n",
    "ax.set_xlabel('Time')\n",
    "ax.set_ylabel('Ridership')\n",
    "ax.legend(['Ridership', 'Centered Moving Average', 'Trailing Moving Average'])\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Figure 18.3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:44.736149Z",
     "iopub.status.busy": "2021-05-27T20:03:44.735687Z",
     "iopub.status.idle": "2021-05-27T20:03:44.996402Z",
     "shell.execute_reply": "2021-05-27T20:03:44.996785Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 34248 characters]\n",
      "text/plain": [
       "<Figure size 648x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# partition the data\n",
    "nValid = 36\n",
    "nTrain = len(ridership_ts) - nValid\n",
    "\n",
    "train_ts = ridership_ts[:nTrain]\n",
    "valid_ts = ridership_ts[nTrain:]\n",
    "\n",
    "# moving average on training\n",
    "ma_trailing = train_ts.rolling(12).mean()\n",
    "last_ma = ma_trailing[-1]\n",
    "\n",
    "# create forecast based on last moving average in the training period\n",
    "ma_trailing_pred = pd.Series(last_ma, index=valid_ts.index)\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(9,4))\n",
    "train_ts.plot(ax=ax, color='black', linewidth=0.5)\n",
    "valid_ts.plot(ax=ax, color='black', linewidth=0.25)\n",
    "ma_trailing.plot(ax=ax, linewidth=2, color='C0')\n",
    "ma_trailing_pred.plot(ax=ax, style='--', linewidth=2, color='C0')\n",
    "singleGraphLayout(ax, [1300, 2550], train_ts, valid_ts)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:44.999205Z",
     "iopub.status.busy": "2021-05-27T20:03:44.998772Z",
     "iopub.status.idle": "2021-05-27T20:03:45.528079Z",
     "shell.execute_reply": "2021-05-27T20:03:45.527678Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 72444 characters]\n",
      "text/plain": [
       "<Figure size 648x540 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(9, 7.5))\n",
    "\n",
    "ma_trailing.plot(ax=axes[0], linewidth=2, color='C1')\n",
    "ma_trailing_pred.plot(ax=axes[0], linewidth=2, color='C1', linestyle='dashed')\n",
    "\n",
    "residual = train_ts - ma_trailing\n",
    "residual.plot(ax=axes[1], color='C1')\n",
    "residual = valid_ts - ma_trailing_pred\n",
    "residual.plot(ax=axes[1], color='C1', linestyle='dashed')\n",
    "\n",
    "graphLayout(axes, train_ts, valid_ts)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Table 18.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:45.548258Z",
     "iopub.status.busy": "2021-05-27T20:03:45.547802Z",
     "iopub.status.idle": "2021-05-27T20:03:45.558697Z",
     "shell.execute_reply": "2021-05-27T20:03:45.558206Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Prediction 2004.2708927644999\n",
      "ma_trailing 30.780684624059024\n"
     ]
    }
   ],
   "source": [
    "# Build a model with seasonality, trend, and quadratic trend\n",
    "ridership_df = tsatools.add_trend(ridership_ts, trend='ct')\n",
    "ridership_df['Month'] = ridership_df.index.month\n",
    "\n",
    "# partition the data\n",
    "train_df = ridership_df[:nTrain]\n",
    "valid_df = ridership_df[nTrain:]\n",
    "\n",
    "formula = 'Ridership ~ trend + np.square(trend) + C(Month)'\n",
    "ridership_lm_trendseason = sm.ols(formula=formula, data=train_df).fit()\n",
    "\n",
    "# create single-point forecast\n",
    "ridership_prediction = ridership_lm_trendseason.predict(valid_df.iloc[0, :])\n",
    "\n",
    "# apply MA to residuals\n",
    "ma_trailing = ridership_lm_trendseason.resid.rolling(12).mean()\n",
    "\n",
    "print('Prediction', ridership_prediction[0])\n",
    "print('ma_trailing', ma_trailing[-1])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Figure 18.4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:45.618705Z",
     "iopub.status.busy": "2021-05-27T20:03:45.594961Z",
     "iopub.status.idle": "2021-05-27T20:03:45.773917Z",
     "shell.execute_reply": "2021-05-27T20:03:45.773462Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<AxesSubplot:xlabel='Date'>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 36956 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "ax = train_df.Ridership.plot()\n",
    "valid_df.Ridership.plot(ax=ax)\n",
    "ridership_lm_trendseason.predict(valid_df).plot(ax=ax)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:45.777141Z",
     "iopub.status.busy": "2021-05-27T20:03:45.776705Z",
     "iopub.status.idle": "2021-05-27T20:03:45.779478Z",
     "shell.execute_reply": "2021-05-27T20:03:45.779005Z"
    }
   },
   "outputs": [],
   "source": [
    "# residuals_ts = ridership_lm_trendseason.resid\n",
    "\n",
    "# ax = ridership_lm_trendseason.resid.plot(color='black', linewidth=0.5)\n",
    "# ax.set_ylabel('Ridership')\n",
    "# ax.set_xlabel('Time')\n",
    "# ax.axhline(y=0, xmin=0, xmax=1, color='grey', linewidth=0.5)\n",
    "\n",
    "# # run exponential smoothing\n",
    "# # with smoothing level alpha = 0.2\n",
    "# expSmooth = ExponentialSmoothing(residuals_ts, freq='MS')\n",
    "# expSmoothFit = expSmooth.fit(smoothing_level=0.2)\n",
    "\n",
    "# expSmoothFit.fittedvalues.plot(ax=ax)\n",
    "# expSmoothFit.forecast(len(valid_ts)).plot(ax=ax, style='--', linewidth=2, color='C0')\n",
    "\n",
    "# plt.show()\n",
    "\n",
    "# print(expSmoothFit.forecast(1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:45.814360Z",
     "iopub.status.busy": "2021-05-27T20:03:45.804694Z",
     "iopub.status.idle": "2021-05-27T20:03:46.076772Z",
     "shell.execute_reply": "2021-05-27T20:03:46.076356Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.9/site-packages/statsmodels/tsa/holtwinters/model.py:427: FutureWarning: After 0.13 initialization must be handled at model creation\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 30336 characters]\n",
      "text/plain": [
       "<Figure size 648x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2001-04-01    14.142855\n",
      "Freq: MS, dtype: float64\n"
     ]
    }
   ],
   "source": [
    "residuals_ts = ridership_lm_trendseason.resid\n",
    "residuals_pred = valid_df.Ridership - ridership_lm_trendseason.predict(valid_df)\n",
    "\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(9,4))\n",
    "\n",
    "ridership_lm_trendseason.resid.plot(ax=ax, color='black', linewidth=0.5)\n",
    "residuals_pred.plot(ax=ax, color='black', linewidth=0.5)\n",
    "ax.set_ylabel('Ridership')\n",
    "ax.set_xlabel('Time')\n",
    "ax.axhline(y=0, xmin=0, xmax=1, color='grey', linewidth=0.5)\n",
    "\n",
    "# run exponential smoothing\n",
    "# with smoothing level alpha = 0.2\n",
    "expSmooth = ExponentialSmoothing(residuals_ts, freq='MS')\n",
    "expSmoothFit = expSmooth.fit(smoothing_level=0.2)\n",
    "\n",
    "expSmoothFit.fittedvalues.plot(ax=ax)\n",
    "expSmoothFit.forecast(len(valid_ts)).plot(ax=ax, style='--', linewidth=2, color='C0')\n",
    "\n",
    "singleGraphLayout(ax, [-550, 550], train_df, valid_df)\n",
    "\n",
    "plt.show()\n",
    "\n",
    "print(expSmoothFit.forecast(1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:46.080137Z",
     "iopub.status.busy": "2021-05-27T20:03:46.079700Z",
     "iopub.status.idle": "2021-05-27T20:03:46.082642Z",
     "shell.execute_reply": "2021-05-27T20:03:46.082189Z"
    }
   },
   "outputs": [],
   "source": [
    "# residuals_ts = ridership_lm_trendseason.resid\n",
    "\n",
    "# fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(9, 7.5))\n",
    "\n",
    "# ridership_lm_trendseason.predict(train_df).plot(ax=axes[0], linewidth=2, color='C1')\n",
    "# ridership_lm_trendseason.predict(valid_df).plot(ax=axes[0], linewidth=1, color='C1')\n",
    "\n",
    "# ridership_lm_trendseason.resid.plot(ax=axes[1], color='C1')\n",
    "# residuals_pred = valid_df.Ridership - ridership_lm_trendseason.predict(valid_df)\n",
    "# residuals_pred.plot(ax=axes[1], color='C1', linestyle='dashed')\n",
    "\n",
    "\n",
    "# # run exponential smoothing\n",
    "# # with smoothing level alpha = 0.2\n",
    "# expSmooth = ExponentialSmoothing(residuals_ts, freq='MS')\n",
    "# expSmoothFit = expSmooth.fit(smoothing_level=0.2)\n",
    "# expSmoothForecast = expSmoothFit.forecast(len(valid_ts))\n",
    "\n",
    "# expSmoothFit.fittedvalues.plot(ax=axes[1], color='C2')\n",
    "# expSmoothForecast.plot(ax=axes[1], linewidth=2, color='C2', linestyle='dashed')\n",
    "\n",
    "# correctedRidership_lm_trendseason = ridership_lm_trendseason.predict(valid_df) - expSmoothForecast\n",
    "# correctedRidership_lm_trendseason.plot(ax=axes[0], linewidth=0.5, color='C2')\n",
    "\n",
    "\n",
    "# graphLayout(axes, train_ts, valid_ts)\n",
    "\n",
    "\n",
    "# plt.show()\n",
    "\n",
    "# print(expSmoothFit.forecast(1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Figure 18.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:46.092801Z",
     "iopub.status.busy": "2021-05-27T20:03:46.092314Z",
     "iopub.status.idle": "2021-05-27T20:03:46.464413Z",
     "shell.execute_reply": "2021-05-27T20:03:46.464801Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/opt/conda/lib/python3.9/site-packages/statsmodels/tsa/holtwinters/model.py:427: FutureWarning: After 0.13 initialization must be handled at model creation\n",
      "  warnings.warn(\n"
     ]
    },
    {
     "data": {
      "image/png": "[encoded data, 50040 characters]\n",
      "text/plain": [
       "<Figure size 648x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# run exponential smoothing with additive trend and additive seasonal\n",
    "expSmooth = ExponentialSmoothing(train_ts, trend='additive', seasonal='additive', seasonal_periods=12, freq='MS')\n",
    "expSmoothFit = expSmooth.fit()\n",
    "\n",
    "fig, ax = plt.subplots(figsize=(9,4))\n",
    "train_ts.plot(ax=ax, color='black', linewidth=0.5)\n",
    "valid_ts.plot(ax=ax, color='black', linewidth=0.25)\n",
    "\n",
    "expSmoothFit.fittedvalues.plot(ax=ax)\n",
    "expSmoothFit.forecast(len(valid_ts)).plot(ax=ax, style='--', linewidth=2, color='C0')\n",
    "singleGraphLayout(ax, [1300, 2550], train_ts, valid_ts)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:46.503145Z",
     "iopub.status.busy": "2021-05-27T20:03:46.492237Z",
     "iopub.status.idle": "2021-05-27T20:03:46.976854Z",
     "shell.execute_reply": "2021-05-27T20:03:46.975722Z"
    }
   },
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 74876 characters]\n",
      "text/plain": [
       "<Figure size 648x540 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(9, 7.5))\n",
    "\n",
    "expSmoothFit.fittedvalues.plot(ax=axes[0], linewidth=2, color='C1')\n",
    "expSmoothFit.forecast(len(valid_ts)).plot(ax=axes[0], linewidth=2, color='C1', linestyle='dashed')\n",
    "\n",
    "residual = train_ts - expSmoothFit.fittedvalues\n",
    "residual.plot(ax=axes[1], color='C1')\n",
    "residual = valid_ts - expSmoothFit.forecast(len(valid_ts))\n",
    "residual.plot(ax=axes[1], color='C1', linestyle='dashed')\n",
    "\n",
    "graphLayout(axes, train_ts, valid_ts)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Table 18.2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:46.981261Z",
     "iopub.status.busy": "2021-05-27T20:03:46.980834Z",
     "iopub.status.idle": "2021-05-27T20:03:46.983938Z",
     "shell.execute_reply": "2021-05-27T20:03:46.983442Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'smoothing_level': 0.5641935329401964,\n",
       " 'smoothing_trend': 0.0039077893405662185,\n",
       " 'smoothing_seasonal': 0.0005060994453987424,\n",
       " 'damping_trend': nan,\n",
       " 'initial_level': 1677.021852558779,\n",
       " 'initial_trend': 0.19821938768344577,\n",
       " 'initial_seasons': array([ 32.30923383, -10.24612048, 293.96013748, 294.91368035,\n",
       "        326.80746863, 281.36122053, 392.33191764, 443.45406142,\n",
       "        122.93665201, 247.42488569, 238.2382331 , 275.18748082]),\n",
       " 'use_boxcox': False,\n",
       " 'lamda': None,\n",
       " 'remove_bias': False}"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "expSmoothFit.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-05-27T20:03:46.987547Z",
     "iopub.status.busy": "2021-05-27T20:03:46.987096Z",
     "iopub.status.idle": "2021-05-27T20:03:46.990415Z",
     "shell.execute_reply": "2021-05-27T20:03:46.990890Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AIC:  1022.3592535867122\n",
      "AICc:  1028.9361766636353\n",
      "BIC:  1067.354203272671\n"
     ]
    }
   ],
   "source": [
    "print('AIC: ', expSmoothFit.aic)\n",
    "print('AICc: ', expSmoothFit.aicc)\n",
    "print('BIC: ', expSmoothFit.bic)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
