You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ML-For-Beginners/7-TimeSeries/2-ARIMA/solution/notebook.ipynb

1089 lines
346 KiB

4 years ago
{
"cells": [
{
"cell_type": "markdown",
4 years ago
"source": [
"# Time series forecasting with ARIMA\n",
"\n",
"In this notebook, we demonstrate how to:\n",
4 years ago
"- prepare time series data for training an ARIMA time series forecasting model\n",
4 years ago
"- implement a simple ARIMA model to forecast the next HORIZON steps ahead (time *t+1* through *t+HORIZON*) in the time series\n",
"- evaluate the model \n",
"\n",
"\n",
"The data in this example is taken from the GEFCom2014 forecasting competition<sup>1</sup>. It consists of 3 years of hourly electricity load and temperature values between 2012 and 2014. The task is to forecast future values of electricity load. In this example, we show how to forecast one time step ahead, using historical load data only.\n",
"\n",
"<sup>1</sup>Tao Hong, Pierre Pinson, Shu Fan, Hamidreza Zareipour, Alberto Troccoli and Rob J. Hyndman, \"Probabilistic energy forecasting: Global Energy Forecasting Competition 2014 and beyond\", International Journal of Forecasting, vol.32, no.3, pp 896-913, July-September, 2016."
4 years ago
],
"metadata": {}
},
{
"cell_type": "markdown",
"source": [
"## Install Dependencies\n",
"Get started by installing some of the required dependencies. These libraries with their corresponding versions are known to work for the solution:\n",
"\n",
"* `statsmodels == 0.12.2`\n",
"* `matplotlib == 3.4.2`\n",
"* `scikit-learn == 0.24.2`\n"
],
"metadata": {}
},
4 years ago
{
"cell_type": "code",
"execution_count": 16,
"source": [
"!pip install statsmodels"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/bin/sh: pip: command not found\n"
4 years ago
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 17,
4 years ago
"source": [
"import os\n",
"import warnings\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"import datetime as dt\n",
"import math\n",
"\n",
"from pandas.plotting import autocorrelation_plot\n",
"from statsmodels.tsa.statespace.sarimax import SARIMAX\n",
"from sklearn.preprocessing import MinMaxScaler\n",
"from common.utils import load_data, mape\n",
"from IPython.display import Image\n",
"\n",
"%matplotlib inline\n",
"pd.options.display.float_format = '{:,.2f}'.format\n",
"np.set_printoptions(precision=2)\n",
"warnings.filterwarnings(\"ignore\") # specify to ignore warning messages\n"
],
"outputs": [],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 18,
"source": [
"energy = load_data('./data')[['load']]\n",
"energy.head(10)"
],
4 years ago
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>load</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2012-01-01 00:00:00</th>\n",
" <td>2,698.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 01:00:00</th>\n",
" <td>2,558.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 02:00:00</th>\n",
" <td>2,444.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 03:00:00</th>\n",
" <td>2,402.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 04:00:00</th>\n",
" <td>2,403.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 05:00:00</th>\n",
" <td>2,453.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 06:00:00</th>\n",
" <td>2,560.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 07:00:00</th>\n",
" <td>2,719.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 08:00:00</th>\n",
" <td>2,916.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2012-01-01 09:00:00</th>\n",
" <td>3,105.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" load\n",
"2012-01-01 00:00:00 2,698.00\n",
"2012-01-01 01:00:00 2,558.00\n",
"2012-01-01 02:00:00 2,444.00\n",
"2012-01-01 03:00:00 2,402.00\n",
"2012-01-01 04:00:00 2,403.00\n",
"2012-01-01 05:00:00 2,453.00\n",
"2012-01-01 06:00:00 2,560.00\n",
"2012-01-01 07:00:00 2,719.00\n",
"2012-01-01 08:00:00 2,916.00\n",
"2012-01-01 09:00:00 3,105.00"
]
4 years ago
},
"metadata": {},
"execution_count": 18
4 years ago
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Plot all available load data (January 2012 to Dec 2014)"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 19,
"source": [
"energy.plot(y='load', subplots=True, figsize=(15, 8), fontsize=12)\n",
"plt.xlabel('timestamp', fontsize=12)\n",
"plt.ylabel('load', fontsize=12)\n",
"plt.show()"
],
4 years ago
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4kAAAHVCAYAAABc/b7wAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nOy9d5xfVZ3//zopEBGwIOiu7Bp0bYuIBXdtYMOKosh3VwHLuqv+lNXVdReNuCgdpBuahNBNQkASIKQnpPdJnfRkJtOSTO8zmfb5nN8fn8+duZ/7Obff+7n3fu7r6SMyc8u5Z255n/M+7yaklCCEEEIIIYQQQgBgXNQdIIQQQgghhBASH6gkEkIIIYQQQggZhUoiIYQQQgghhJBRqCQSQgghhBBCCBmFSiIhhBBCCCGEkFGo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KTzUbdBVJGUEkkqUXqZmVPrKuJriOEEOIKapSEkGIyKlNiHkoN4hYqiSS1PFdRH3UXCCGEEEICwUpJZHgzccuEqDtASFRsPtIRSDs76jtx6sn8lAgh7tGym9LdNF14yWpLiB0ZChISIJzZktRimijCJd94cF0g7RBCCEkXkpN6UiL4phG30N2UpBaOzYSQ2EOLU1kiaEokISAUAmOc0JJjjU167l5yAJOnzC9Zv0gyoZJIUkspVnAzWYnrX96Dho5+5f7VB1tC7wMhJL7YqgoKMRXnBa7m7gFMnjIf2+qCcecvd2L8KEkCUa09jMvP9LM6wXH/q4dL1COSZKgkktRSisF5W10Hnlxfg1/N3qnc/6O
"text/plain": [
"<Figure size 1080x576 with 1 Axes>"
]
4 years ago
},
"metadata": {
"needs_background": "light"
}
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
4 years ago
"source": [
4 years ago
"## Create training and testing data sets\n"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 20,
4 years ago
"source": [
"train_start_dt = '2014-11-01 00:00:00'\n",
"test_start_dt = '2014-12-30 00:00:00' "
],
"outputs": [],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 21,
"source": [
"energy[(energy.index < test_start_dt) & (energy.index >= train_start_dt)][['load']].rename(columns={'load':'train'}) \\\n",
" .join(energy[test_start_dt:][['load']].rename(columns={'load':'test'}), how='outer') \\\n",
" .plot(y=['train', 'test'], figsize=(15, 8), fontsize=12)\n",
"plt.xlabel('timestamp', fontsize=12)\n",
"plt.ylabel('load', fontsize=12)\n",
"plt.show()"
],
4 years ago
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4kAAAITCAYAAACqpFnEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17Yc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7bLGibupIAiCIAjbktjKJIq7qSBsPy666CIcPnwYJ06c2Ohd4bF0FujPA1OPc3p5t9vFRRddxNqEBImCIAiCIGxL+qlkEgVhO9NqtXDJJZds9G7wectO8/P3pgGl1mUTIjcVBEEQBGFbInJTQRA2Ncuz6/bWEiQKgiAIgrAtEbmpIAibmvn1k8lKkCgIgiAIwrakJ5lEQRA2I91d5ufCqXXbhASJgiAIgiBsSyiTGAUKyxIkCoKwWRjLgsT5k+u2CQkSBUEQBEHYllBN4ng7lEyiIAibh7Hd5ueCBImCIAiCIAjnFAoSJzuRZBIFQdg8UJAomURBEARBEIRzS5wauel4J0IvTlhjj04vYn45Xo/dEgRBGEzYNj/7i+u2CQkSBUEQBEHYllBN4ng7ZLub/vu3/Rt+4QM3rcduCYIgDCbNFrXipXXbhASJgiAIgiBsS1JtgsRu5FeTeMfhmXO9S4IgCKujKUhcXrdNSJAoCIIgCMK2JMnkpp1WgFQDaapXGVEeJwiCsCGkmdRdMomCIAiCIAjnliTLJHaiEADQT92yieKEKgjChkL3KskkCoIgCIIgnFtSK5MIFDWKq7HU55ncCIIg1LHUT3DVLYe
"text/plain": [
"<Figure size 1080x576 with 1 Axes>"
]
4 years ago
},
"metadata": {
"needs_background": "light"
}
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 22,
"source": [
"train = energy.copy()[(energy.index >= train_start_dt) & (energy.index < test_start_dt)][['load']]\n",
"test = energy.copy()[energy.index >= test_start_dt][['load']]\n",
"\n",
"print('Training data shape: ', train.shape)\n",
"print('Test data shape: ', test.shape)"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Training data shape: (1416, 1)\n",
"Test data shape: (48, 1)\n"
4 years ago
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 23,
"source": [
"scaler = MinMaxScaler()\n",
"train['load'] = scaler.fit_transform(train)\n",
"train.head(10)"
],
4 years ago
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>load</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2014-11-01 00:00:00</th>\n",
" <td>0.10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 01:00:00</th>\n",
" <td>0.07</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 02:00:00</th>\n",
" <td>0.05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 03:00:00</th>\n",
" <td>0.04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 04:00:00</th>\n",
" <td>0.06</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 05:00:00</th>\n",
" <td>0.10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 06:00:00</th>\n",
" <td>0.19</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 07:00:00</th>\n",
" <td>0.31</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 08:00:00</th>\n",
" <td>0.40</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-11-01 09:00:00</th>\n",
" <td>0.48</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" load\n",
"2014-11-01 00:00:00 0.10\n",
"2014-11-01 01:00:00 0.07\n",
"2014-11-01 02:00:00 0.05\n",
"2014-11-01 03:00:00 0.04\n",
"2014-11-01 04:00:00 0.06\n",
"2014-11-01 05:00:00 0.10\n",
"2014-11-01 06:00:00 0.19\n",
"2014-11-01 07:00:00 0.31\n",
"2014-11-01 08:00:00 0.40\n",
"2014-11-01 09:00:00 0.48"
]
4 years ago
},
"metadata": {},
"execution_count": 23
4 years ago
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Original vs scaled data:"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 24,
"source": [
"energy[(energy.index >= train_start_dt) & (energy.index < test_start_dt)][['load']].rename(columns={'load':'original load'}).plot.hist(bins=100, fontsize=12)\n",
"train.rename(columns={'load':'scaled load'}).plot.hist(bins=100, fontsize=12)\n",
"plt.show()"
],
4 years ago
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD7CAYAAACMlyg3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAZ+klEQVR4nO3df5BV5Z3n8fdHoOjwKyq0ZFYGOroRGBEDNNHEgJg4cUdXolIzi8YVzRiyZq1UyspkslZQRl3N7jBOyk00YWOUKJgfikw07tRIIok6M2rjChFtpSxFWX8UkAnQ/Ea/+8c5rZdL3+5z6T739u3zeVWdou95zjn3e56+fb8853nOcxQRmJlZMR1V7wDMzKx+nATMzArMScDMrMCcBMzMCsxJwMyswAbXO4BqjBkzJlpaWuodhplZQ1m7du3WiGjuqqyhkkBLSwttbW31DsPMrKFI2lSpzJeDzMwKzEnAzKzAnATMzAqsofoEzKz/OnDgAJs3b2bv3r31DqWwmpqaGDduHEOGDMm8j5OAmfWJzZs3M3LkSFpaWpBU73AKJyLYtm0bmzdv5qMf/Wjm/Xw5yMz6xN69exk9erQTQJ1IYvTo0VW3xJwEzKzPOAHU15HUv5OAmVmBuU/AzHLR8s1f9unxXvv2eX12rHPPPZcVK1Zw9NFHV9zmuuuuY/bs2Zx99tlVH3/NmjUsWbKEhx9+ONP6IzFnzhyWLFlCa2trr47jJGBWAKVfyH35ZdpoIoKI4JFHHulx2xtuuKEGEdWfLweZ2YBx6623MmXKFKZMmcJ3vvMdAF577TUmTpzIZZddxpQpU3jjjTdoaWlh69atANx4441MnDiRT3/601x88cUsWbIEgMsvv5z7778fSKasuf7665k+fTqnnHIK7e3tADz99NN88pOfZNq0aXzqU5/ipZdeyhzr73//ey644AKmTp3K6aefzvr167s95p49e5g/fz6TJ0/mwgsvZM+ePX1SZzVpCUj6GPA74P6IuDRddwlwCzAGeBT4YkT8vhbxmNnAs3btWu666y6eeuopIoLTTjuNM888k2OOOYaNGzeybNkyTj/99EP2eeaZZ3jggQdYt24dBw4cYPr06cyYMaPL448ZM4Znn32W22+/nSVLlvDDH/6QSZMm8fjjjzN48GBWr17NtddeywMPPJAp3uuvv55p06axatUqfv3rX3PZZZfx3HPPVTzmHXfcwbBhw3jxxRdZv34906dP73WdQe0uB30PeKbzhaSTgR8A5wHPAkuB24H5NYrHzAaYJ554ggsvvJDhw4cDcNFFF/H4448zd+5cJkyYcFgCAHjyySf5/Oc/T1NTE01NTZx//vkVj3/RRRcBMGPGDFauXAnA9u3bWbBgARs3bkQSBw4cqCrezoTxmc98hm3btrFjx46Kx/ztb3/LV7/6VQCmTp3K1KlTM79Xd3K/HCRpPvAH4Fclq78APBQRv42IDmARcJGkkXnHY2bF05kYemPo0KEADBo0iIMHDwKwaNEizjrrLJ5//nkeeuihPrlbOo9jdifXJCBpFHADcE1Z0cnAus4XEfEKsB84qYtjLJTUJqlty5YteYZrVjgt3/zl+0ujmzVrFqtWrWL37t3s2rWLBx98kFmzZnW7zxlnnPH+F21HR0fVo3a2b9/O8ccfD8Ddd99ddbzLly8HklFDY8aMYdSoURWPOXv2bFasWAHA888//34fQm/lfTnoRuDOiNhcdhPDCGB72bbbgcNaAhGxlORyEa2trZFTnGbWx2o9Cmn69OlcfvnlfOITnwDgyiuvZNq0abz22msV95k5cyZz585l6tSpjB07llNOOYUPf/jDmd/zG9/4BgsWLO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f0QsjYjWiGhtbm7OGK6ZmWWRNQnskjS984WkGcCebrbv3E7AncBYYF5EHKiwaVQZj5mZ9YGsl4O
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
4 years ago
},
"metadata": {
"needs_background": "light"
}
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYEAAAD7CAYAAACMlyg3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAaCklEQVR4nO3de5RV5Znn8e+PSyjlIhEK1GBZagJeQBQL7ehSM9EWO2omhjjRqOOltaIOsTNZzdLJ0oTYtunOmpl0JEokbTAg2iRpcKKxXYKXVmNPQsE0ERQ0LsHQogIJSCF3n/ljn9JjUUXtU5x9Tp3av89aZ8m+nf285+B5ePfz7ncrIjAzs3zqU+0AzMysepwEzMxyzEnAzCzHnATMzHLMScDMLMf6VTuAUgwfPjwaGxurHYaZWU1ZsmTJhoio72hbTSWBxsZGWlpaqh2GmVlNkbSms22+HGRmlmNOAmZmOeYkYGaWYzVVEzCz2rJr1y7Wrl3L9u3bqx1KLtTV1TFq1Cj69++f+hgnATPLzNq1axk8eDCNjY1IqnY4vVpEsHHjRtauXcuRRx6Z+jhfDjKzzGzfvp1hw4Y5AVSAJIYNG1Zyr8tJwMwy5QRQOd35rJ0EzMxyzDUBM6uYxlt+Vdb3W/1355f1/To8x+rVXHDBBSxfvjz1MVdddRUXXHABX/rSl1Ktr0RMnXESMMuB4h/fSvxwWu3w5SAz67W2bt3K+eefz/jx4xk7dizz5s0DYPHixZx22mmMHz+eU045hS1btrB69WrOOOMMJkyYwIQJE3jhhRf2er89e/YwdepUJk6cyAknnMC9994LJCNzpkyZwpgxYzjnnHN45513uoztySef5KSTTmLcuHFcc8017NixA4Dbb7+diRMnMnbsWJqbm2l7+uOSJUsYP34848eP5+677y7XR1SZJCDpU5K2S3qgaN1XJK2RtFXSw5IOrkQsZpYfjz/+OIcddhjLli1j+fLlnHfeeezcuZMvf/nL/OAHP2DZsmUsWrSIAw44gBEjRrBw4UKWLl3KvHnzuOmmm/Z6v/vuu4+DDjqIxYsXs3jxYn784x/z+uuvs2DBAlatWsVLL73E7NmzO0wgxbZv385VV13FvHnzePHFF9m9ezczZswAYMqUKSxevJjly5ezbds2Hn30UQCuvvpqpk+fzrJly8r6GVWqJ3A3sLhtQdLxwL3AFcBI4D3gngrFYmY5MW7cOBYuXMjNN9/Mc889x0EHHcSqVas49NBDmThxIgBDhgyhX79+7Nq1i+uuu45x48Zx8cUX89JLL+31fk888QSzZ8/mxBNP5NRTT2Xjxo28+uqrPPvss1x66aX07duXww47jM9+9rP7jGvVqlUceeSRjB49GoArr7ySZ599FoCnn36aU089lXHjxvHUU0+xYsUKNm3axKZNmzjzzDMBuOKKK8r2GWVeE5B0CbAJeAH4ZGH1ZcAjEfFsYZ/bgJclDY6ILVnHZGb5MHr0aJYuXcpjjz3Grbfeytlnn81FF13U4b7f//73GTlyJMuWLeP999+nrq5ur30igunTpzNp0qSPrH/sscfKEu/27du58cYbaWlp4fDDD2fatGmZ322daU9A0hDgduAb7TYdD3zQp4mI14CdwOgO3qNZUouklvXr12cZrlnuNN7yqw9evdGbb77JgQceyOWXX87UqVNZunQpY8aMYd26dSxenFyc2LJlC7t372bz5s0ceuih9OnThzlz5rBnz5693m/SpEnMmDGDXbt2AfDKK6+wdetWzjzzTObNm8eePXtYt24dTz/99D7jGjNmDKtXr+b3v/89AHPmzOGss8764Ad/+PDhtLa28otf/AKAoUOHMnToUJ5//nkA5s6dW54PiOx7An8D3BcRa9vdxDAI2Nxu383A4PZvEBEzgZkATU1NkVGcZlYBlR6Z9OKLLzJ16lT69OlD//79mTFjBh/72MeYN28eX/va19i2bRsHHHAAixYt4sYbb2Ty5MnMnj2b8847j4EDB+71ftdeey2rV69mwoQJRAT19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WY45CZiZ5ZiTgJlZjjkJmJnlmJOAmVmOOQmYmeVYpklA0gOS1kl6V9Irkq4t2na2pJWS3pP0tKQjsozFzMz2lnVP4LtAY0QMAT4P3CHpZEnDgfnAbcDBQAswL+NYzMysnUxvFouIFcWLhdfRwMnAioj4OYCkacAGScdExMosYzIzsw9lXhOQdI+k94CVwDrgMeB4YFnbPhGxFXitsL798c2SWiS1rF+/PutwzcxyJfMkEBE3AoOBM0guAe0ABgGb2+26ubBf++NnRkRTRDTV19dnHa6ZWa5UZHRQROyJiOeBUcANQCswpN1uQ4AtlYjHzMwSlR4i2o+kJrACGN+2UtLAovVmZlYhmSUBSSMkXSJpkKS+kiYBlwJPAguAsZImS6oDvgX8zkVhM7PKynJ0UJBc+vkRSbJZA3w9In4JIGky8EPgAeA3wCUZxmLWI2Q9rbSnrbZSZZYEImI9cNY+ti8Cjsnq/GZm1jVPG2FmlmNOAmZmOeYkYGaWY37GsFkP4+KuVZJ7AmZmOeYkYGaWY04CZmY55iRgZpZjLgybWUlcuO5d3BMwM8sxJwEzsxxzEjAzy7FUSUDSuKwDMTOzyktbGL5H0gDgfmBuRLR/NKSZZcBFWMtaqp5ARJwBXAYcDiyR9KCkP880MjMzy1zqmkBEvArcCtxM8pyAuyStlPTFjvaXNEDSfZLWSNoi6d8l/UVhW6OkkNRa9LqtHA0yM7P0Ul0OknQCcDVwPrAQuDAilko6DPg3YH4n7/0HkoTxBvA54Gft6gtDI2L3fsRvZmb7IW1NYDrwj8A3I2Jb28qIeFPSrR0dEBFbgWlFqx6V9DpwMrCke+GamVk5pU0C5wPbImIPgKQ+QF1EvBcRc9K8gaSRwGhgRdHqNZKCpHcxNSI2pA/dzMz2V9oksAg4B2gtLB8IPAGcluZgSf2BucBPI2KlpEHARODfgWHA3YXtkzo
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
4 years ago
},
"metadata": {
"needs_background": "light"
}
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Let's also scale the test data"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 25,
"source": [
"test['load'] = scaler.transform(test)\n",
"test.head()"
],
4 years ago
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>load</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2014-12-30 00:00:00</th>\n",
" <td>0.33</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 01:00:00</th>\n",
" <td>0.29</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 02:00:00</th>\n",
" <td>0.27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 03:00:00</th>\n",
" <td>0.27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 04:00:00</th>\n",
" <td>0.30</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" load\n",
"2014-12-30 00:00:00 0.33\n",
"2014-12-30 01:00:00 0.29\n",
"2014-12-30 02:00:00 0.27\n",
"2014-12-30 03:00:00 0.27\n",
"2014-12-30 04:00:00 0.30"
]
4 years ago
},
"metadata": {},
"execution_count": 25
4 years ago
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"## Implement ARIMA method"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 26,
"source": [
"# Specify the number of steps to forecast ahead\n",
"HORIZON = 3\n",
"print('Forecasting horizon:', HORIZON, 'hours')"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Forecasting horizon: 3 hours\n"
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 27,
4 years ago
"source": [
"order = (4, 1, 0)\n",
"seasonal_order = (1, 1, 0, 24)\n",
"\n",
"model = SARIMAX(endog=train, order=order, seasonal_order=seasonal_order)\n",
"results = model.fit()\n",
"\n",
4 years ago
"print(results.summary())\n"
],
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
" SARIMAX Results \n",
"==========================================================================================\n",
"Dep. Variable: load No. Observations: 1416\n",
"Model: SARIMAX(4, 1, 0)x(1, 1, 0, 24) Log Likelihood 3477.239\n",
"Date: Thu, 30 Sep 2021 AIC -6942.477\n",
"Time: 14:36:28 BIC -6911.050\n",
"Sample: 11-01-2014 HQIC -6930.725\n",
" - 12-29-2014 \n",
"Covariance Type: opg \n",
"==============================================================================\n",
" coef std err z P>|z| [0.025 0.975]\n",
"------------------------------------------------------------------------------\n",
"ar.L1 0.8403 0.016 52.226 0.000 0.809 0.872\n",
"ar.L2 -0.5220 0.034 -15.388 0.000 -0.588 -0.456\n",
"ar.L3 0.1536 0.044 3.470 0.001 0.067 0.240\n",
"ar.L4 -0.0778 0.036 -2.158 0.031 -0.148 -0.007\n",
"ar.S.L24 -0.2327 0.024 -9.718 0.000 -0.280 -0.186\n",
"sigma2 0.0004 8.32e-06 47.358 0.000 0.000 0.000\n",
"===================================================================================\n",
"Ljung-Box (L1) (Q): 0.05 Jarque-Bera (JB): 1464.60\n",
"Prob(Q): 0.83 Prob(JB): 0.00\n",
"Heteroskedasticity (H): 0.84 Skew: 0.14\n",
"Prob(H) (two-sided): 0.07 Kurtosis: 8.02\n",
"===================================================================================\n",
"\n",
"Warnings:\n",
"[1] Covariance matrix calculated using the outer product of gradients (complex-step).\n"
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"## Evaluate the model"
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Create a test data point for each HORIZON step."
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 28,
"source": [
"test_shifted = test.copy()\n",
"\n",
"for t in range(1, HORIZON):\n",
" test_shifted['load+'+str(t)] = test_shifted['load'].shift(-t, freq='H')\n",
" \n",
"test_shifted = test_shifted.dropna(how='any')\n",
"test_shifted.head(5)"
],
4 years ago
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>load</th>\n",
" <th>load+1</th>\n",
" <th>load+2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2014-12-30 00:00:00</th>\n",
" <td>0.33</td>\n",
" <td>0.29</td>\n",
" <td>0.27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 01:00:00</th>\n",
" <td>0.29</td>\n",
" <td>0.27</td>\n",
" <td>0.27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 02:00:00</th>\n",
" <td>0.27</td>\n",
" <td>0.27</td>\n",
" <td>0.30</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 03:00:00</th>\n",
" <td>0.27</td>\n",
" <td>0.30</td>\n",
" <td>0.41</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2014-12-30 04:00:00</th>\n",
" <td>0.30</td>\n",
" <td>0.41</td>\n",
" <td>0.57</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" load load+1 load+2\n",
"2014-12-30 00:00:00 0.33 0.29 0.27\n",
"2014-12-30 01:00:00 0.29 0.27 0.27\n",
"2014-12-30 02:00:00 0.27 0.27 0.30\n",
"2014-12-30 03:00:00 0.27 0.30 0.41\n",
"2014-12-30 04:00:00 0.30 0.41 0.57"
]
4 years ago
},
"metadata": {},
"execution_count": 28
4 years ago
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Make predictions on the test data"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 29,
"source": [
"%%time\n",
"training_window = 720 # dedicate 30 days (720 hours) for training\n",
"\n",
"train_ts = train['load']\n",
"test_ts = test_shifted\n",
"\n",
"history = [x for x in train_ts]\n",
"history = history[(-training_window):]\n",
"\n",
"predictions = list()\n",
"\n",
"# let's user simpler model for demonstration\n",
"order = (2, 1, 0)\n",
"seasonal_order = (1, 1, 0, 24)\n",
"\n",
"for t in range(test_ts.shape[0]):\n",
" model = SARIMAX(endog=history, order=order, seasonal_order=seasonal_order)\n",
" model_fit = model.fit()\n",
" yhat = model_fit.forecast(steps = HORIZON)\n",
" predictions.append(yhat)\n",
" obs = list(test_ts.iloc[t])\n",
" # move the training window\n",
" history.append(obs[0])\n",
" history.pop(0)\n",
" print(test_ts.index[t])\n",
" print(t+1, ': predicted =', yhat, 'expected =', obs)"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"2014-12-30 00:00:00\n",
"1 : predicted = [0.32 0.29 0.28] expected = [0.32945389435989236, 0.2900626678603402, 0.2739480752014323]\n",
"2014-12-30 01:00:00\n",
"2 : predicted = [0.3 0.29 0.3 ] expected = [0.2900626678603402, 0.2739480752014323, 0.26812891674127126]\n",
"2014-12-30 02:00:00\n",
"3 : predicted = [0.27 0.28 0.32] expected = [0.2739480752014323, 0.26812891674127126, 0.3025962399283795]\n",
"2014-12-30 03:00:00\n",
"4 : predicted = [0.28 0.32 0.42] expected = [0.26812891674127126, 0.3025962399283795, 0.40823634735899716]\n",
"2014-12-30 04:00:00\n",
"5 : predicted = [0.3 0.39 0.54] expected = [0.3025962399283795, 0.40823634735899716, 0.5689346463742166]\n",
"2014-12-30 05:00:00\n",
"6 : predicted = [0.4 0.55 0.66] expected = [0.40823634735899716, 0.5689346463742166, 0.6799462846911368]\n",
"2014-12-30 06:00:00\n",
"7 : predicted = [0.57 0.68 0.75] expected = [0.5689346463742166, 0.6799462846911368, 0.7309758281110115]\n",
"2014-12-30 07:00:00\n",
"8 : predicted = [0.68 0.75 0.8 ] expected = [0.6799462846911368, 0.7309758281110115, 0.7511190689346463]\n",
"2014-12-30 08:00:00\n",
"9 : predicted = [0.75 0.8 0.82] expected = [0.7309758281110115, 0.7511190689346463, 0.7636526410026856]\n",
"2014-12-30 09:00:00\n",
"10 : predicted = [0.77 0.78 0.78] expected = [0.7511190689346463, 0.7636526410026856, 0.7381378692927483]\n",
"2014-12-30 10:00:00\n",
"11 : predicted = [0.76 0.75 0.74] expected = [0.7636526410026856, 0.7381378692927483, 0.7188898836168307]\n",
"2014-12-30 11:00:00\n",
"12 : predicted = [0.77 0.76 0.75] expected = [0.7381378692927483, 0.7188898836168307, 0.7090420769919425]\n",
"2014-12-30 12:00:00\n",
"13 : predicted = [0.7 0.68 0.69] expected = [0.7188898836168307, 0.7090420769919425, 0.7081468218442255]\n",
"2014-12-30 13:00:00\n",
"14 : predicted = [0.72 0.73 0.76] expected = [0.7090420769919425, 0.7081468218442255, 0.7385854968666068]\n",
"2014-12-30 14:00:00\n",
"15 : predicted = [0.71 0.73 0.86] expected = [0.7081468218442255, 0.7385854968666068, 0.8478066248880931]\n",
"2014-12-30 15:00:00\n",
"16 : predicted = [0.73 0.85 0.97] expected = [0.7385854968666068, 0.8478066248880931, 0.9516562220232765]\n",
"2014-12-30 16:00:00\n",
"17 : predicted = [0.87 0.99 0.97] expected = [0.8478066248880931, 0.9516562220232765, 0.934198746642793]\n",
"2014-12-30 17:00:00\n",
"18 : predicted = [0.94 0.92 0.86] expected = [0.9516562220232765, 0.934198746642793, 0.8876454789615038]\n",
"2014-12-30 18:00:00\n",
"19 : predicted = [0.94 0.89 0.82] expected = [0.934198746642793, 0.8876454789615038, 0.8294538943598924]\n",
"2014-12-30 19:00:00\n",
"20 : predicted = [0.88 0.82 0.71] expected = [0.8876454789615038, 0.8294538943598924, 0.7197851387645477]\n",
"2014-12-30 20:00:00\n",
"21 : predicted = [0.83 0.72 0.58] expected = [0.8294538943598924, 0.7197851387645477, 0.5747538048343777]\n",
"2014-12-30 21:00:00\n",
"22 : predicted = [0.72 0.58 0.47] expected = [0.7197851387645477, 0.5747538048343777, 0.4592658907788718]\n",
"2014-12-30 22:00:00\n",
"23 : predicted = [0.58 0.47 0.39] expected = [0.5747538048343777, 0.4592658907788718, 0.3858549686660697]\n",
"2014-12-30 23:00:00\n",
"24 : predicted = [0.46 0.38 0.34] expected = [0.4592658907788718, 0.3858549686660697, 0.34377797672336596]\n",
"2014-12-31 00:00:00\n",
"25 : predicted = [0.38 0.34 0.33] expected = [0.3858549686660697, 0.34377797672336596, 0.32542524619516544]\n",
"2014-12-31 01:00:00\n",
"26 : predicted = [0.36 0.34 0.34] expected = [0.34377797672336596, 0.32542524619516544, 0.33034914950760963]\n",
"2014-12-31 02:00:00\n",
"27 : predicted = [0.32 0.32 0.35] expected = [0.32542524619516544, 0.33034914950760963, 0.3706356311548791]\n",
"2014-12-31 03:00:00\n",
"28 : predicted = [0.32 0.36 0.47] expected = [0.33034914950760963, 0.3706356311548791, 0.470008952551477]\n",
"2014-12-31 04:00:00\n",
"29 : predicted = [0.37 0.48 0.65] expected = [0.3706356311548791, 0.470008952551477, 0.6145926589077886]\n",
"2014-12-31 05:00:00\n",
"30 : predicted = [0.48 0.64 0.75] expected = [0.470008952551477, 0.6145926589077886, 0.7247090420769919]\n",
"2014-12-31 06:00:00\n",
"31 : predicted = [0.63 0.73 0.79] expected = [0.6145926589077886, 0.7247090420769919, 0.786034019695613]\n",
"2014-12-31 07:00:00\n",
"32 : predicted = [0.71 0.76 0.79] expected = [0.7247090420769919, 0.786034019695613, 0.8012533572068039]\n",
"2014-12-31 08:00:00\n",
"33 : predicted = [0.79 0.82 0.83] expected = [0.786034019695613, 0.8012533572068039, 0.7994628469113696]\n",
"2014-12-31 09:00:00\n",
"34 : predicted = [0.82 0.83 0.81] expected = [0.8012533572068039, 0.7994628469113696, 0.780214861235452]\n",
"2014-12-31 10:00:00\n",
"35 : predicted = [0.8 0.78 0.76] expected = [0.7994628469113696, 0.780214861235452, 0.7587287376902416]\n",
"2014-12-31 11:00:00\n",
"36 : predicted = [0.77 0.75 0.74] expected = [0.780214861235452, 0.7587287376902416, 0.7367949865711727]\n",
"2014-12-31 12:00:00\n",
"37 : predicted = [0.77 0.76 0.76] expected = [0.7587287376902416, 0.7367949865711727, 0.7188898836168307]\n",
"2014-12-31 13:00:00\n",
"38 : predicted = [0.75 0.75 0.78] expected = [0.7367949865711727, 0.7188898836168307, 0.7273948075201431]\n",
"2014-12-31 14:00:00\n",
"39 : predicted = [0.73 0.75 0.87] expected = [0.7188898836168307, 0.7273948075201431, 0.8299015219337511]\n",
"2014-12-31 15:00:00\n",
"40 : predicted = [0.74 0.85 0.96] expected = [0.7273948075201431, 0.8299015219337511, 0.909579230080573]\n",
"2014-12-31 16:00:00\n",
"41 : predicted = [0.83 0.94 0.93] expected = [0.8299015219337511, 0.909579230080573, 0.855863921217547]\n",
"2014-12-31 17:00:00\n",
"42 : predicted = [0.94 0.93 0.88] expected = [0.909579230080573, 0.855863921217547, 0.7721575649059982]\n",
"2014-12-31 18:00:00\n",
"43 : predicted = [0.87 0.82 0.77] expected = [0.855863921217547, 0.7721575649059982, 0.7023276633840643]\n",
"2014-12-31 19:00:00\n",
"44 : predicted = [0.79 0.73 0.63] expected = [0.7721575649059982, 0.7023276633840643, 0.6195165622202325]\n",
"2014-12-31 20:00:00\n",
"45 : predicted = [0.7 0.59 0.46] expected = [0.7023276633840643, 0.6195165622202325, 0.5425246195165621]\n",
"2014-12-31 21:00:00\n",
"46 : predicted = [0.6 0.47 0.36] expected = [0.6195165622202325, 0.5425246195165621, 0.4735899731423454]\n",
"CPU times: user 12min 15s, sys: 2min 39s, total: 14min 54s\n",
"Wall time: 2min 36s\n"
4 years ago
]
}
],
"metadata": {
"scrolled": true
}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Compare predictions to actual load"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 30,
"source": [
"eval_df = pd.DataFrame(predictions, columns=['t+'+str(t) for t in range(1, HORIZON+1)])\n",
"eval_df['timestamp'] = test.index[0:len(test.index)-HORIZON+1]\n",
"eval_df = pd.melt(eval_df, id_vars='timestamp', value_name='prediction', var_name='h')\n",
"eval_df['actual'] = np.array(np.transpose(test_ts)).ravel()\n",
"eval_df[['prediction', 'actual']] = scaler.inverse_transform(eval_df[['prediction', 'actual']])\n",
"eval_df.head()"
],
4 years ago
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>timestamp</th>\n",
" <th>h</th>\n",
" <th>prediction</th>\n",
" <th>actual</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2014-12-30 00:00:00</td>\n",
" <td>t+1</td>\n",
" <td>3,008.74</td>\n",
" <td>3,023.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2014-12-30 01:00:00</td>\n",
" <td>t+1</td>\n",
" <td>2,955.53</td>\n",
" <td>2,935.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2014-12-30 02:00:00</td>\n",
" <td>t+1</td>\n",
" <td>2,900.17</td>\n",
" <td>2,899.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2014-12-30 03:00:00</td>\n",
" <td>t+1</td>\n",
" <td>2,917.69</td>\n",
" <td>2,886.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2014-12-30 04:00:00</td>\n",
" <td>t+1</td>\n",
" <td>2,946.99</td>\n",
" <td>2,963.00</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" timestamp h prediction actual\n",
"0 2014-12-30 00:00:00 t+1 3,008.74 3,023.00\n",
"1 2014-12-30 01:00:00 t+1 2,955.53 2,935.00\n",
"2 2014-12-30 02:00:00 t+1 2,900.17 2,899.00\n",
"3 2014-12-30 03:00:00 t+1 2,917.69 2,886.00\n",
"4 2014-12-30 04:00:00 t+1 2,946.99 2,963.00"
]
4 years ago
},
"metadata": {},
"execution_count": 30
4 years ago
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Compute the **mean absolute percentage error (MAPE)** over all predictions\n",
"\n",
"$$MAPE = \\frac{1}{n} \\sum_{t=1}^{n}|\\frac{actual_t - predicted_t}{actual_t}|$$"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 31,
"source": [
"if(HORIZON > 1):\n",
" eval_df['APE'] = (eval_df['prediction'] - eval_df['actual']).abs() / eval_df['actual']\n",
" print(eval_df.groupby('h')['APE'].mean())"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"h\n",
"t+1 0.01\n",
"t+2 0.01\n",
"t+3 0.02\n",
"Name: APE, dtype: float64\n"
4 years ago
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [],
"metadata": {}
},
4 years ago
{
"cell_type": "code",
"execution_count": 32,
"source": [
"print('One step forecast MAPE: ', (mape(eval_df[eval_df['h'] == 't+1']['prediction'], eval_df[eval_df['h'] == 't+1']['actual']))*100, '%')"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"One step forecast MAPE: 0.5570581332313952 %\n"
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 33,
"source": [
"print('Multi-step forecast MAPE: ', mape(eval_df['prediction'], eval_df['actual'])*100, '%')"
],
4 years ago
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Multi-step forecast MAPE: 1.1460048657704118 %\n"
]
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "markdown",
"source": [
"Plot the predictions vs the actuals for the first week of the test set"
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": 34,
4 years ago
"source": [
"if(HORIZON == 1):\n",
" ## Plotting single step forecast\n",
" eval_df.plot(x='timestamp', y=['actual', 'prediction'], style=['r', 'b'], figsize=(15, 8))\n",
"\n",
"else:\n",
" ## Plotting multi step forecast\n",
" plot_df = eval_df[(eval_df.h=='t+1')][['timestamp', 'actual']]\n",
" for t in range(1, HORIZON+1):\n",
" plot_df['t+'+str(t)] = eval_df[(eval_df.h=='t+'+str(t))]['prediction'].values\n",
"\n",
" fig = plt.figure(figsize=(15, 8))\n",
" ax = plt.plot(plot_df['timestamp'], plot_df['actual'], color='red', linewidth=4.0)\n",
" ax = fig.add_subplot(111)\n",
" for t in range(1, HORIZON+1):\n",
" x = plot_df['timestamp'][(t-1):]\n",
" y = plot_df['t+'+str(t)][0:len(x)]\n",
" ax.plot(x, y, color='blue', linewidth=4*math.pow(.9,t), alpha=math.pow(0.8,t))\n",
" \n",
" ax.legend(loc='best')\n",
" \n",
"plt.xlabel('timestamp', fontsize=12)\n",
"plt.ylabel('load', fontsize=12)\n",
"plt.show()"
],
"outputs": [
{
"output_type": "stream",
"name": "stderr",
"text": [
"No handles with labels found to put in legend.\n"
]
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA4QAAAHjCAYAAAB7INHwAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJza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DJ5+Eb75p/vykJPjud+UrSOP6J5/UxvUdjS/aA2jFo8BTkRXDUiSIxDTN1YZhvACsAYLAdaZpattLpZRysNpA+P3QJ6MYArWsZCwmBnh9kJzU5BUGZGZBejrhvXvZ8Y0PfziF8khCxpccyQvztzPgnQIGH7WHnIsnMvXUJI4+2r2PcMMG+b6G0X4/q1JKqfbR0GBPOBqG9B88+WTZMpCQIMVjJkyAmTPhqKPse0FmJlxxhXQ5amiQxvXPPy+rh17tFdAhtHtjetM0F5umeUYL15MdxwHTNC80TXOoaZoTTdPc7HjsT6ZpDjFNc7hpmvPaa9xKKdUZlJXJHo1AQG68WWUbSaSGBcyUJ6Slkp5uMHOmew8gAB4v9DkCRo8mJcOHgZQYNfFQSSo7zb58uCqFJ36znmvOLuSDxSbp6dKCAmS/4q5mSfxKKaW6gg0bZA8hwMCBsHChBIMg6aAbNsBXX8Hf/ga//CXMmyf3BYC+fd2N6zduhNdf1x62HUVHXSFUSil1CJzpoh4PpO/Ip5BsaonUBU9L59JL4apI9mgoBDt3SiP7zZutr7FsSRpI0pY6qooDEAxSSSppVGBYL9qxnb/9qJzjvsolN1daGoKsTlpFBJRSSnUdTauL3nef+/EdO2TVMD4
"text/plain": [
"<Figure size 1080x576 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
}
}
],
"metadata": {}
4 years ago
},
{
"cell_type": "code",
"execution_count": null,
"source": [],
4 years ago
"outputs": [],
"metadata": {}
4 years ago
}
],
"metadata": {
"kernel_info": {
"name": "python3"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3.7.0 64-bit"
4 years ago
},
"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.7.0"
4 years ago
},
"nteract": {
"version": "nteract-front-end@1.0.0"
4 years ago
},
"metadata": {
"interpreter": {
"hash": "70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d"
}
},
"interpreter": {
"hash": "70b38d7a306a849643e446cd70466270a13445e5987dfa1344ef2b127438fa4d"
4 years ago
}
},
"nbformat": 4,
"nbformat_minor": 2
}