Skip to content

Instantly share code, notes, and snippets.

@ngupta23
Created November 7, 2021 14:29
Show Gist options
  • Save ngupta23/12dc80fc39f0a57ac9b7416953114ece to your computer and use it in GitHub Desktop.
Save ngupta23/12dc80fc39f0a57ac9b7416953114ece to your computer and use it in GitHub Desktop.
pycaret_ts_enfore_pi.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "pycaret_ts_enfore_pi.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyOQD5YAEWi2F3zL+FMjSI42",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"25366243c7894fe08accd90082b46137": {
"model_module": "@jupyter-widgets/controls",
"model_name": "IntProgressModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_2a2016733d6f45009b1f937e2e94c82d",
"_dom_classes": [],
"description": "Processing: ",
"_model_name": "IntProgressModel",
"bar_style": "",
"max": 3,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 3,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_490a5021cd25416ca204c8774f4681a0"
}
},
"2a2016733d6f45009b1f937e2e94c82d": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"490a5021cd25416ca204c8774f4681a0": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"3f79bea2eea04d9d9109c662ccbb5146": {
"model_module": "@jupyter-widgets/controls",
"model_name": "IntProgressModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_7a77c23424244ba2b943f80d20c3e92a",
"_dom_classes": [],
"description": "Processing: ",
"_model_name": "IntProgressModel",
"bar_style": "",
"max": 4,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 4,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_d61de86a373f4a82941b60006f630b80"
}
},
"7a77c23424244ba2b943f80d20c3e92a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"d61de86a373f4a82941b60006f630b80": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
},
"8a091b5ddaaf46e6bb4d839a564f1974": {
"model_module": "@jupyter-widgets/controls",
"model_name": "IntProgressModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "ProgressView",
"style": "IPY_MODEL_43c33e71a37448de8b37c27713772f1a",
"_dom_classes": [],
"description": "Processing: ",
"_model_name": "IntProgressModel",
"bar_style": "",
"max": 44,
"_view_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"value": 39,
"_view_count": null,
"_view_module_version": "1.5.0",
"orientation": "horizontal",
"min": 0,
"description_tooltip": null,
"_model_module": "@jupyter-widgets/controls",
"layout": "IPY_MODEL_8e67598e2a52408fb55fe146275caea7"
}
},
"43c33e71a37448de8b37c27713772f1a": {
"model_module": "@jupyter-widgets/controls",
"model_name": "ProgressStyleModel",
"model_module_version": "1.5.0",
"state": {
"_view_name": "StyleView",
"_model_name": "ProgressStyleModel",
"description_width": "",
"_view_module": "@jupyter-widgets/base",
"_model_module_version": "1.5.0",
"_view_count": null,
"_view_module_version": "1.2.0",
"bar_color": null,
"_model_module": "@jupyter-widgets/controls"
}
},
"8e67598e2a52408fb55fe146275caea7": {
"model_module": "@jupyter-widgets/base",
"model_name": "LayoutModel",
"model_module_version": "1.2.0",
"state": {
"_view_name": "LayoutView",
"grid_template_rows": null,
"right": null,
"justify_content": null,
"_view_module": "@jupyter-widgets/base",
"overflow": null,
"_model_module_version": "1.2.0",
"_view_count": null,
"flex_flow": null,
"width": null,
"min_width": null,
"border": null,
"align_items": null,
"bottom": null,
"_model_module": "@jupyter-widgets/base",
"top": null,
"grid_column": null,
"overflow_y": null,
"overflow_x": null,
"grid_auto_flow": null,
"grid_area": null,
"grid_template_columns": null,
"flex": null,
"_model_name": "LayoutModel",
"justify_items": null,
"grid_row": null,
"max_height": null,
"align_content": null,
"visibility": null,
"align_self": null,
"height": null,
"min_height": null,
"padding": null,
"grid_auto_rows": null,
"grid_gap": null,
"max_width": null,
"order": null,
"_view_module_version": "1.2.0",
"grid_template_areas": null,
"object_position": null,
"object_fit": null,
"grid_auto_columns": null,
"margin": null,
"display": null,
"left": null
}
}
}
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/ngupta23/12dc80fc39f0a57ac9b7416953114ece/pycaret_ts_enfore_pi.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "v6fp55LVnX4J"
},
"source": [
"!pip install pycaret-ts-alpha -U\n",
"!pip install prophet"
],
"execution_count": 8,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 146
},
"id": "rAn-yHEen05j",
"outputId": "2af52587-4c85-4e7b-ea83-b44f19e916a7"
},
"source": [
"#### Load data ----\n",
"from pycaret.datasets import get_data\n",
"y = get_data(\"airline\")"
],
"execution_count": 2,
"outputs": [
{
"output_type": "display_data",
"data": {
"text/plain": [
"Period\n",
"1949-01 112.0\n",
"1949-02 118.0\n",
"1949-03 132.0\n",
"1949-04 129.0\n",
"1949-05 121.0\n",
"Freq: M, Name: Number of airline passengers, dtype: float64"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 695,
"referenced_widgets": [
"25366243c7894fe08accd90082b46137",
"2a2016733d6f45009b1f937e2e94c82d",
"490a5021cd25416ca204c8774f4681a0"
]
},
"id": "uVBx_uqBn2d-",
"outputId": "923a79db-fe74-4e4b-ecfd-a8474ba6c150"
},
"source": [
"#### Setup experiment ----\n",
"from pycaret.internal.pycaret_experiment import TimeSeriesExperiment\n",
"exp = TimeSeriesExperiment()\n",
"\n",
"#### Enforce usage of only those models that have a prediction interval ----\n",
"exp.setup(data=y, fh=12, enforce_pi=True, session_id=42)"
],
"execution_count": 3,
"outputs": [
{
"output_type": "display_data",
"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>Description</th>\n",
" <th>Value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>session_id</td>\n",
" <td>42</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Original Data</td>\n",
" <td>(144, 1)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Missing Values</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Transformed Train Set</td>\n",
" <td>(132,)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Transformed Test Set</td>\n",
" <td>(12,)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Fold Generator</td>\n",
" <td>ExpandingWindowSplitter</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Fold Number</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Enforce Prediction Interval</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Seasonal Period Tested</td>\n",
" <td>12</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Seasonality Detected</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Target Strictly Positive</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Target White Noise</td>\n",
" <td>No</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Recommended d</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>Recommended Seasonal D</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>CPU Jobs</td>\n",
" <td>-1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Use GPU</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>Log Experiment</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>Experiment Name</td>\n",
" <td>ts-default-name</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>USI</td>\n",
" <td>9610</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>Imputation Type</td>\n",
" <td>simple</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Description Value\n",
"0 session_id 42\n",
"1 Original Data (144, 1)\n",
"2 Missing Values False\n",
"3 Transformed Train Set (132,)\n",
"4 Transformed Test Set (12,)\n",
"5 Fold Generator ExpandingWindowSplitter\n",
"6 Fold Number 3\n",
"7 Enforce Prediction Interval True\n",
"8 Seasonal Period Tested 12\n",
"9 Seasonality Detected True\n",
"10 Target Strictly Positive True\n",
"11 Target White Noise No\n",
"12 Recommended d 1\n",
"13 Recommended Seasonal D 1\n",
"14 CPU Jobs -1\n",
"15 Use GPU False\n",
"16 Log Experiment False\n",
"17 Experiment Name ts-default-name\n",
"18 USI 9610\n",
"19 Imputation Type simple"
]
},
"metadata": {}
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<pycaret.internal.pycaret_experiment.time_series_experiment.TimeSeriesExperiment at 0x7f1a6f6b06d0>"
]
},
"metadata": {},
"execution_count": 3
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 300
},
"id": "D0RcW8sCn8ZR",
"outputId": "4dccf8fd-6e77-4342-b6d5-29e9fa595d6a"
},
"source": [
"# Available Models (only those having ability to generate prediction intervals) ----\n",
"exp.models()"
],
"execution_count": 4,
"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>Name</th>\n",
" <th>Reference</th>\n",
" <th>Turbo</th>\n",
" </tr>\n",
" <tr>\n",
" <th>ID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>arima</th>\n",
" <td>ARIMA</td>\n",
" <td>sktime.forecasting.arima.ARIMA</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>auto_arima</th>\n",
" <td>Auto ARIMA</td>\n",
" <td>sktime.forecasting.arima.AutoARIMA</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>ets</th>\n",
" <td>ETS</td>\n",
" <td>sktime.forecasting.ets.AutoETS</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>theta</th>\n",
" <td>Theta Forecaster</td>\n",
" <td>sktime.forecasting.theta.ThetaForecaster</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>tbats</th>\n",
" <td>TBATS</td>\n",
" <td>sktime.forecasting.tbats.TBATS</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>bats</th>\n",
" <td>BATS</td>\n",
" <td>sktime.forecasting.bats.BATS</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>prophet</th>\n",
" <td>Prophet</td>\n",
" <td>pycaret.containers.models.time_series.ProphetP...</td>\n",
" <td>False</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name ... Turbo\n",
"ID ... \n",
"arima ARIMA ... True\n",
"auto_arima Auto ARIMA ... True\n",
"ets ETS ... True\n",
"theta Theta Forecaster ... True\n",
"tbats TBATS ... False\n",
"bats BATS ... False\n",
"prophet Prophet ... False\n",
"\n",
"[7 rows x 3 columns]"
]
},
"metadata": {},
"execution_count": 4
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 731,
"referenced_widgets": [
"3f79bea2eea04d9d9109c662ccbb5146",
"7a77c23424244ba2b943f80d20c3e92a",
"d61de86a373f4a82941b60006f630b80"
]
},
"id": "gB4-ueGmoJHd",
"outputId": "89544374-7ca3-43c0-905b-30aa664a144f"
},
"source": [
"#### Create Model & plot predictions ----\n",
"model = exp.create_model(\"ets\")\n",
"exp.plot_model(model)"
],
"execution_count": 5,
"outputs": [
{
"output_type": "display_data",
"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>cutoff</th>\n",
" <th>MAE</th>\n",
" <th>RMSE</th>\n",
" <th>MAPE</th>\n",
" <th>SMAPE</th>\n",
" <th>R2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1956-12</td>\n",
" <td>14.5727</td>\n",
" <td>18.7858</td>\n",
" <td>0.0367</td>\n",
" <td>0.0377</td>\n",
" <td>0.8851</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1957-12</td>\n",
" <td>16.7941</td>\n",
" <td>19.3204</td>\n",
" <td>0.0458</td>\n",
" <td>0.0446</td>\n",
" <td>0.9022</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>1958-12</td>\n",
" <td>20.8905</td>\n",
" <td>23.4314</td>\n",
" <td>0.0495</td>\n",
" <td>0.0512</td>\n",
" <td>0.8772</td>\n",
" </tr>\n",
" <tr>\n",
" <th>Mean</th>\n",
" <td>NaN</td>\n",
" <td>17.4191</td>\n",
" <td>20.5125</td>\n",
" <td>0.0440</td>\n",
" <td>0.0445</td>\n",
" <td>0.8882</td>\n",
" </tr>\n",
" <tr>\n",
" <th>SD</th>\n",
" <td>NaN</td>\n",
" <td>2.6168</td>\n",
" <td>2.0755</td>\n",
" <td>0.0054</td>\n",
" <td>0.0055</td>\n",
" <td>0.0104</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" cutoff MAE RMSE MAPE SMAPE R2\n",
"0 1956-12 14.5727 18.7858 0.0367 0.0377 0.8851\n",
"1 1957-12 16.7941 19.3204 0.0458 0.0446 0.9022\n",
"2 1958-12 20.8905 23.4314 0.0495 0.0512 0.8772\n",
"Mean NaN 17.4191 20.5125 0.0440 0.0445 0.8882\n",
"SD NaN 2.6168 2.0755 0.0054 0.0055 0.0104"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/html": [
"<html>\n",
"<head><meta charset=\"utf-8\" /></head>\n",
"<body>\n",
" <div> <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script> <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
" <script src=\"https://cdn.plot.ly/plotly-2.4.2.min.js\"></script> <div id=\"82c57a6d-7129-4fd6-aa7f-461cf69d7493\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"82c57a6d-7129-4fd6-aa7f-461cf69d7493\")) { Plotly.newPlot( \"82c57a6d-7129-4fd6-aa7f-461cf69d7493\", [{\"line\":{\"width\":0},\"marker\":{\"color\":\"#68BBE3\"},\"mode\":\"lines\",\"name\":\"Lower Interval\",\"showlegend\":false,\"type\":\"scatter\",\"x\":[\"1960-01-01T00:00:00\",\"1960-02-01T00:00:00\",\"1960-03-01T00:00:00\",\"1960-04-01T00:00:00\",\"1960-05-01T00:00:00\",\"1960-06-01T00:00:00\",\"1960-07-01T00:00:00\",\"1960-08-01T00:00:00\",\"1960-09-01T00:00:00\",\"1960-10-01T00:00:00\",\"1960-11-01T00:00:00\",\"1960-12-01T00:00:00\"],\"y\":[399.1724,374.2371,441.7475,424.885,445.9866,512.4318,593.5584,597.6323,487.5193,423.1288,368.6979,405.3603]},{\"fill\":\"tonexty\",\"fillcolor\":\"#68BBE3\",\"line\":{\"color\":\"#1f77b4\"},\"marker\":{\"size\":5},\"mode\":\"lines+markers\",\"name\":\"Forecast | ETS\",\"showlegend\":true,\"type\":\"scatter\",\"x\":[\"1960-01-01T00:00:00\",\"1960-02-01T00:00:00\",\"1960-03-01T00:00:00\",\"1960-04-01T00:00:00\",\"1960-05-01T00:00:00\",\"1960-06-01T00:00:00\",\"1960-07-01T00:00:00\",\"1960-08-01T00:00:00\",\"1960-09-01T00:00:00\",\"1960-10-01T00:00:00\",\"1960-11-01T00:00:00\",\"1960-12-01T00:00:00\"],\"y\":[417.2265,394.0018,462.2049,448.3367,471.6366,539.3359,623.561,630.7469,515.2,449.7405,394.1071,433.6767]},{\"fill\":\"tonexty\",\"fillcolor\":\"#68BBE3\",\"line\":{\"width\":0},\"marker\":{\"color\":\"#68BBE3\"},\"mode\":\"lines\",\"name\":\"Prediction Interval | ETS\",\"showlegend\":true,\"type\":\"scatter\",\"x\":[\"1960-01-01T00:00:00\",\"1960-02-01T00:00:00\",\"1960-03-01T00:00:00\",\"1960-04-01T00:00:00\",\"1960-05-01T00:00:00\",\"1960-06-01T00:00:00\",\"1960-07-01T00:00:00\",\"1960-08-01T00:00:00\",\"1960-09-01T00:00:00\",\"1960-10-01T00:00:00\",\"1960-11-01T00:00:00\",\"1960-12-01T00:00:00\"],\"y\":[435.9598,415.3192,484.8106,472.5015,495.2967,565.8552,652.9493,664.4028,545.2246,475.8882,419.5679,461.5141]},{\"marker\":{\"color\":\"#3f3f3f\",\"size\":5},\"mode\":\"lines+markers\",\"name\":\"Original\",\"showlegend\":true,\"type\":\"scatter\",\"x\":[\"1949-01-01T00:00:00\",\"1949-02-01T00:00:00\",\"1949-03-01T00:00:00\",\"1949-04-01T00:00:00\",\"1949-05-01T00:00:00\",\"1949-06-01T00:00:00\",\"1949-07-01T00:00:00\",\"1949-08-01T00:00:00\",\"1949-09-01T00:00:00\",\"1949-10-01T00:00:00\",\"1949-11-01T00:00:00\",\"1949-12-01T00:00:00\",\"1950-01-01T00:00:00\",\"1950-02-01T00:00:00\",\"1950-03-01T00:00:00\",\"1950-04-01T00:00:00\",\"1950-05-01T00:00:00\",\"1950-06-01T00:00:00\",\"1950-07-01T00:00:00\",\"1950-08-01T00:00:00\",\"1950-09-01T00:00:00\",\"1950-10-01T00:00:00\",\"1950-11-01T00:00:00\",\"1950-12-01T00:00:00\",\"1951-01-01T00:00:00\",\"1951-02-01T00:00:00\",\"1951-03-01T00:00:00\",\"1951-04-01T00:00:00\",\"1951-05-01T00:00:00\",\"1951-06-01T00:00:00\",\"1951-07-01T00:00:00\",\"1951-08-01T00:00:00\",\"1951-09-01T00:00:00\",\"1951-10-01T00:00:00\",\"1951-11-01T00:00:00\",\"1951-12-01T00:00:00\",\"1952-01-01T00:00:00\",\"1952-02-01T00:00:00\",\"1952-03-01T00:00:00\",\"1952-04-01T00:00:00\",\"1952-05-01T00:00:00\",\"1952-06-01T00:00:00\",\"1952-07-01T00:00:00\",\"1952-08-01T00:00:00\",\"1952-09-01T00:00:00\",\"1952-10-01T00:00:00\",\"1952-11-01T00:00:00\",\"1952-12-01T00:00:00\",\"1953-01-01T00:00:00\",\"1953-02-01T00:00:00\",\"1953-03-01T00:00:00\",\"1953-04-01T00:00:00\",\"1953-05-01T00:00:00\",\"1953-06-01T00:00:00\",\"1953-07-01T00:00:00\",\"1953-08-01T00:00:00\",\"1953-09-01T00:00:00\",\"1953-10-01T00:00:00\",\"1953-11-01T00:00:00\",\"1953-12-01T00:00:00\",\"1954-01-01T00:00:00\",\"1954-02-01T00:00:00\",\"1954-03-01T00:00:00\",\"1954-04-01T00:00:00\",\"1954-05-01T00:00:00\",\"1954-06-01T00:00:00\",\"1954-07-01T00:00:00\",\"1954-08-01T00:00:00\",\"1954-09-01T00:00:00\",\"1954-10-01T00:00:00\",\"1954-11-01T00:00:00\",\"1954-12-01T00:00:00\",\"1955-01-01T00:00:00\",\"1955-02-01T00:00:00\",\"1955-03-01T00:00:00\",\"1955-04-01T00:00:00\",\"1955-05-01T00:00:00\",\"1955-06-01T00:00:00\",\"1955-07-01T00:00:00\",\"1955-08-01T00:00:00\",\"1955-09-01T00:00:00\",\"1955-10-01T00:00:00\",\"1955-11-01T00:00:00\",\"1955-12-01T00:00:00\",\"1956-01-01T00:00:00\",\"1956-02-01T00:00:00\",\"1956-03-01T00:00:00\",\"1956-04-01T00:00:00\",\"1956-05-01T00:00:00\",\"1956-06-01T00:00:00\",\"1956-07-01T00:00:00\",\"1956-08-01T00:00:00\",\"1956-09-01T00:00:00\",\"1956-10-01T00:00:00\",\"1956-11-01T00:00:00\",\"1956-12-01T00:00:00\",\"1957-01-01T00:00:00\",\"1957-02-01T00:00:00\",\"1957-03-01T00:00:00\",\"1957-04-01T00:00:00\",\"1957-05-01T00:00:00\",\"1957-06-01T00:00:00\",\"1957-07-01T00:00:00\",\"1957-08-01T00:00:00\",\"1957-09-01T00:00:00\",\"1957-10-01T00:00:00\",\"1957-11-01T00:00:00\",\"1957-12-01T00:00:00\",\"1958-01-01T00:00:00\",\"1958-02-01T00:00:00\",\"1958-03-01T00:00:00\",\"1958-04-01T00:00:00\",\"1958-05-01T00:00:00\",\"1958-06-01T00:00:00\",\"1958-07-01T00:00:00\",\"1958-08-01T00:00:00\",\"1958-09-01T00:00:00\",\"1958-10-01T00:00:00\",\"1958-11-01T00:00:00\",\"1958-12-01T00:00:00\",\"1959-01-01T00:00:00\",\"1959-02-01T00:00:00\",\"1959-03-01T00:00:00\",\"1959-04-01T00:00:00\",\"1959-05-01T00:00:00\",\"1959-06-01T00:00:00\",\"1959-07-01T00:00:00\",\"1959-08-01T00:00:00\",\"1959-09-01T00:00:00\",\"1959-10-01T00:00:00\",\"1959-11-01T00:00:00\",\"1959-12-01T00:00:00\",\"1960-01-01T00:00:00\",\"1960-02-01T00:00:00\",\"1960-03-01T00:00:00\",\"1960-04-01T00:00:00\",\"1960-05-01T00:00:00\",\"1960-06-01T00:00:00\",\"1960-07-01T00:00:00\",\"1960-08-01T00:00:00\",\"1960-09-01T00:00:00\",\"1960-10-01T00:00:00\",\"1960-11-01T00:00:00\",\"1960-12-01T00:00:00\"],\"y\":[112.0,118.0,132.0,129.0,121.0,135.0,148.0,148.0,136.0,119.0,104.0,118.0,115.0,126.0,141.0,135.0,125.0,149.0,170.0,170.0,158.0,133.0,114.0,140.0,145.0,150.0,178.0,163.0,172.0,178.0,199.0,199.0,184.0,162.0,146.0,166.0,171.0,180.0,193.0,181.0,183.0,218.0,230.0,242.0,209.0,191.0,172.0,194.0,196.0,196.0,236.0,235.0,229.0,243.0,264.0,272.0,237.0,211.0,180.0,201.0,204.0,188.0,235.0,227.0,234.0,264.0,302.0,293.0,259.0,229.0,203.0,229.0,242.0,233.0,267.0,269.0,270.0,315.0,364.0,347.0,312.0,274.0,237.0,278.0,284.0,277.0,317.0,313.0,318.0,374.0,413.0,405.0,355.0,306.0,271.0,306.0,315.0,301.0,356.0,348.0,355.0,422.0,465.0,467.0,404.0,347.0,305.0,336.0,340.0,318.0,362.0,348.0,363.0,435.0,491.0,505.0,404.0,359.0,310.0,337.0,360.0,342.0,406.0,396.0,420.0,472.0,548.0,559.0,463.0,407.0,362.0,405.0,417.0,391.0,419.0,461.0,472.0,535.0,622.0,606.0,508.0,461.0,390.0,432.0]}], {\"showlegend\":true,\"template\":{\"data\":{\"bar\":[{\"error_x\":{\"color\":\"rgb(51,51,51)\"},\"error_y\":{\"color\":\"rgb(51,51,51)\"},\"marker\":{\"line\":{\"color\":\"rgb(237,237,237)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"rgb(237,237,237)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"rgb(51,51,51)\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"rgb(51,51,51)\"},\"baxis\":{\"endlinecolor\":\"rgb(51,51,51)\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"rgb(51,51,51)\"},\"type\":\"carpet\"}],\"choropleth\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"type\":\"choropleth\"}],\"contour\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"contour\"}],\"contourcarpet\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"type\":\"contourcarpet\"}],\"heatmap\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"heatmap\"}],\"heatmapgl\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"heatmapgl\"}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"histogram2d\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"histogram2d\"}],\"histogram2dcontour\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"histogram2dcontour\"}],\"mesh3d\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"type\":\"mesh3d\"}],\"parcoords\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"parcoords\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}],\"scatter\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scatter\"}],\"scatter3d\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scatter3d\"}],\"scattercarpet\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scattercarpet\"}],\"scattergeo\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scattergeo\"}],\"scattergl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scattergl\"}],\"scattermapbox\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scattermapbox\"}],\"scatterpolar\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scatterpolar\"}],\"scatterpolargl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scatterpolargl\"}],\"scatterternary\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"type\":\"scatterternary\"}],\"surface\":[{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"},\"colorscale\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"type\":\"surface\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"rgb(237,237,237)\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"rgb(217,217,217)\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}]},\"layout\":{\"annotationdefaults\":{\"arrowhead\":0,\"arrowwidth\":1},\"autotypenumbers\":\"strict\",\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"tickcolor\":\"rgb(237,237,237)\",\"ticklen\":6,\"ticks\":\"inside\"}},\"colorscale\":{\"sequential\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]],\"sequentialminus\":[[0,\"rgb(20,44,66)\"],[1,\"rgb(90,179,244)\"]]},\"colorway\":[\"#F8766D\",\"#A3A500\",\"#00BF7D\",\"#00B0F6\",\"#E76BF3\"],\"font\":{\"color\":\"rgb(51,51,51)\"},\"geo\":{\"bgcolor\":\"white\",\"lakecolor\":\"white\",\"landcolor\":\"rgb(237,237,237)\",\"showlakes\":true,\"showland\":true,\"subunitcolor\":\"white\"},\"hoverlabel\":{\"align\":\"left\"},\"hovermode\":\"closest\",\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"rgb(237,237,237)\",\"polar\":{\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\"},\"bgcolor\":\"rgb(237,237,237)\",\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\"}},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"rgb(237,237,237)\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\",\"zerolinecolor\":\"white\"},\"yaxis\":{\"backgroundcolor\":\"rgb(237,237,237)\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\",\"zerolinecolor\":\"white\"},\"zaxis\":{\"backgroundcolor\":\"rgb(237,237,237)\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\",\"zerolinecolor\":\"white\"}},\"shapedefaults\":{\"fillcolor\":\"black\",\"line\":{\"width\":0},\"opacity\":0.3},\"ternary\":{\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\"},\"bgcolor\":\"rgb(237,237,237)\",\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\"}},\"xaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\"},\"yaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showgrid\":true,\"tickcolor\":\"rgb(51,51,51)\",\"ticks\":\"outside\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\"}}},\"title\":{\"text\":\"Actual vs. Forecast | Number of airline passengers\"},\"xaxis\":{\"title\":{\"text\":\"Time\"}},\"yaxis\":{\"title\":{\"text\":\"Values\"}}}, {\"responsive\": true} ).then(function(){\n",
" \n",
"var gd = document.getElementById('82c57a6d-7129-4fd6-aa7f-461cf69d7493');\n",
"var x = new MutationObserver(function (mutations, observer) {{\n",
" var display = window.getComputedStyle(gd).display;\n",
" if (!display || display === 'none') {{\n",
" console.log([gd, 'removed!']);\n",
" Plotly.purge(gd);\n",
" observer.disconnect();\n",
" }}\n",
"}});\n",
"\n",
"// Listen for the removal of the full notebook cells\n",
"var notebookContainer = gd.closest('#notebook-container');\n",
"if (notebookContainer) {{\n",
" x.observe(notebookContainer, {childList: true});\n",
"}}\n",
"\n",
"// Listen for the clearing of the current output cell\n",
"var outputEl = gd.closest('.output');\n",
"if (outputEl) {{\n",
" x.observe(outputEl, {childList: true});\n",
"}}\n",
"\n",
" }) }; </script> </div>\n",
"</body>\n",
"</html>"
]
},
"metadata": {}
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 490
},
"id": "gTkJ4gvboyif",
"outputId": "afc1cdb2-ff1e-4bc9-96f0-b549acbcdaf2"
},
"source": [
"#### Get Predictions (with prediction interval) ----\n",
"exp.predict_model(model, return_pred_int=True)"
],
"execution_count": 6,
"outputs": [
{
"output_type": "display_data",
"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>Model</th>\n",
" <th>MAE</th>\n",
" <th>RMSE</th>\n",
" <th>MAPE</th>\n",
" <th>SMAPE</th>\n",
" <th>R2</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ETS</td>\n",
" <td>9.5289</td>\n",
" <td>15.4601</td>\n",
" <td>0.0203</td>\n",
" <td>0.0199</td>\n",
" <td>0.9569</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Model MAE RMSE MAPE SMAPE R2\n",
"0 ETS 9.5289 15.4601 0.0203 0.0199 0.9569"
]
},
"metadata": {}
},
{
"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>y_pred</th>\n",
" <th>lower</th>\n",
" <th>upper</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1960-01</th>\n",
" <td>417.2265</td>\n",
" <td>399.1724</td>\n",
" <td>435.9598</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-02</th>\n",
" <td>394.0018</td>\n",
" <td>374.2371</td>\n",
" <td>415.3192</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-03</th>\n",
" <td>462.2049</td>\n",
" <td>441.7475</td>\n",
" <td>484.8106</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-04</th>\n",
" <td>448.3367</td>\n",
" <td>424.8850</td>\n",
" <td>472.5015</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-05</th>\n",
" <td>471.6366</td>\n",
" <td>445.9866</td>\n",
" <td>495.2967</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-06</th>\n",
" <td>539.3359</td>\n",
" <td>512.4318</td>\n",
" <td>565.8552</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-07</th>\n",
" <td>623.5610</td>\n",
" <td>593.5584</td>\n",
" <td>652.9493</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-08</th>\n",
" <td>630.7469</td>\n",
" <td>597.6323</td>\n",
" <td>664.4028</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-09</th>\n",
" <td>515.2000</td>\n",
" <td>487.5193</td>\n",
" <td>545.2246</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-10</th>\n",
" <td>449.7405</td>\n",
" <td>423.1288</td>\n",
" <td>475.8882</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-11</th>\n",
" <td>394.1071</td>\n",
" <td>368.6979</td>\n",
" <td>419.5679</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1960-12</th>\n",
" <td>433.6767</td>\n",
" <td>405.3603</td>\n",
" <td>461.5141</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" y_pred lower upper\n",
"1960-01 417.2265 399.1724 435.9598\n",
"1960-02 394.0018 374.2371 415.3192\n",
"1960-03 462.2049 441.7475 484.8106\n",
"1960-04 448.3367 424.8850 472.5015\n",
"1960-05 471.6366 445.9866 495.2967\n",
"1960-06 539.3359 512.4318 565.8552\n",
"1960-07 623.5610 593.5584 652.9493\n",
"1960-08 630.7469 597.6323 664.4028\n",
"1960-09 515.2000 487.5193 545.2246\n",
"1960-10 449.7405 423.1288 475.8882\n",
"1960-11 394.1071 368.6979 419.5679\n",
"1960-12 433.6767 405.3603 461.5141"
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 269,
"referenced_widgets": [
"8a091b5ddaaf46e6bb4d839a564f1974",
"43c33e71a37448de8b37c27713772f1a",
"8e67598e2a52408fb55fe146275caea7"
]
},
"id": "WMrkrKf8pFS5",
"outputId": "86594097-0574-4079-c1ad-9568284746bc"
},
"source": [
"#### Compare only those models that have a prediction interval ----\n",
"best = exp.compare_models(turbo=False)"
],
"execution_count": 7,
"outputs": [
{
"output_type": "display_data",
"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>Model</th>\n",
" <th>MAE</th>\n",
" <th>RMSE</th>\n",
" <th>MAPE</th>\n",
" <th>SMAPE</th>\n",
" <th>R2</th>\n",
" <th>TT (Sec)</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>ets</th>\n",
" <td>ETS</td>\n",
" <td>17.4191</td>\n",
" <td>20.5125</td>\n",
" <td>0.044</td>\n",
" <td>0.0445</td>\n",
" <td>0.8882</td>\n",
" <td>0.2800</td>\n",
" </tr>\n",
" <tr>\n",
" <th>arima</th>\n",
" <td>ARIMA</td>\n",
" <td>20.0069</td>\n",
" <td>22.2199</td>\n",
" <td>0.0501</td>\n",
" <td>0.0507</td>\n",
" <td>0.8677</td>\n",
" <td>0.0833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>auto_arima</th>\n",
" <td>Auto ARIMA</td>\n",
" <td>21.0297</td>\n",
" <td>23.4661</td>\n",
" <td>0.0525</td>\n",
" <td>0.0531</td>\n",
" <td>0.8509</td>\n",
" <td>4.8833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>tbats</th>\n",
" <td>TBATS</td>\n",
" <td>23.8716</td>\n",
" <td>28.4979</td>\n",
" <td>0.0586</td>\n",
" <td>0.0593</td>\n",
" <td>0.7707</td>\n",
" <td>33.1533</td>\n",
" </tr>\n",
" <tr>\n",
" <th>bats</th>\n",
" <td>BATS</td>\n",
" <td>27.9542</td>\n",
" <td>33.2127</td>\n",
" <td>0.0651</td>\n",
" <td>0.0685</td>\n",
" <td>0.6532</td>\n",
" <td>12.7967</td>\n",
" </tr>\n",
" <tr>\n",
" <th>theta</th>\n",
" <td>Theta Forecaster</td>\n",
" <td>28.3192</td>\n",
" <td>33.8639</td>\n",
" <td>0.067</td>\n",
" <td>0.07</td>\n",
" <td>0.671</td>\n",
" <td>0.0267</td>\n",
" </tr>\n",
" <tr>\n",
" <th>prophet</th>\n",
" <td>Prophet</td>\n",
" <td>30.239</td>\n",
" <td>35.6676</td>\n",
" <td>0.0782</td>\n",
" <td>0.0764</td>\n",
" <td>0.654</td>\n",
" <td>1.3500</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Model MAE RMSE MAPE SMAPE R2 \\\n",
"ets ETS 17.4191 20.5125 0.044 0.0445 0.8882 \n",
"arima ARIMA 20.0069 22.2199 0.0501 0.0507 0.8677 \n",
"auto_arima Auto ARIMA 21.0297 23.4661 0.0525 0.0531 0.8509 \n",
"tbats TBATS 23.8716 28.4979 0.0586 0.0593 0.7707 \n",
"bats BATS 27.9542 33.2127 0.0651 0.0685 0.6532 \n",
"theta Theta Forecaster 28.3192 33.8639 0.067 0.07 0.671 \n",
"prophet Prophet 30.239 35.6676 0.0782 0.0764 0.654 \n",
"\n",
" TT (Sec) \n",
"ets 0.2800 \n",
"arima 0.0833 \n",
"auto_arima 4.8833 \n",
"tbats 33.1533 \n",
"bats 12.7967 \n",
"theta 0.0267 \n",
"prophet 1.3500 "
]
},
"metadata": {}
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment