{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" } }, "cells": [ { "cell_type": "code", "source": [ "pip install prophet" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "4vMywkKtc1AK", "outputId": "1365ebfd-1215-4cbc-831c-6ae394d8cd1d" }, "execution_count": 1, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Requirement already satisfied: prophet in /usr/local/lib/python3.10/dist-packages (1.1.5)\n", "Requirement already satisfied: cmdstanpy>=1.0.4 in /usr/local/lib/python3.10/dist-packages (from prophet) (1.2.0)\n", "Requirement already satisfied: numpy>=1.15.4 in /usr/local/lib/python3.10/dist-packages (from prophet) (1.23.5)\n", "Requirement already satisfied: matplotlib>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from prophet) (3.7.1)\n", "Requirement already satisfied: pandas>=1.0.4 in /usr/local/lib/python3.10/dist-packages (from prophet) (1.5.3)\n", "Requirement already satisfied: holidays>=0.25 in /usr/local/lib/python3.10/dist-packages (from prophet) (0.41)\n", "Requirement already satisfied: tqdm>=4.36.1 in /usr/local/lib/python3.10/dist-packages (from prophet) (4.66.1)\n", "Requirement already satisfied: importlib-resources in /usr/local/lib/python3.10/dist-packages (from prophet) (6.1.1)\n", "Requirement already satisfied: stanio~=0.3.0 in /usr/local/lib/python3.10/dist-packages (from cmdstanpy>=1.0.4->prophet) (0.3.0)\n", "Requirement already satisfied: python-dateutil in /usr/local/lib/python3.10/dist-packages (from holidays>=0.25->prophet) (2.8.2)\n", "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (1.2.0)\n", "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (0.12.1)\n", "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (4.47.2)\n", "Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (1.4.5)\n", "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (23.2)\n", "Requirement already satisfied: pillow>=6.2.0 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (9.4.0)\n", "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.10/dist-packages (from matplotlib>=2.0.0->prophet) (3.1.1)\n", "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas>=1.0.4->prophet) (2023.3.post1)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil->holidays>=0.25->prophet) (1.16.0)\n" ] } ] }, { "cell_type": "code", "source": [ "from prophet import Prophet" ], "metadata": { "id": "dyl5C37PnU33" }, "execution_count": 2, "outputs": [] }, { "cell_type": "code", "source": [ "import pandas as pd\n", "\n", "df_data = pd.read_csv(\"https://raw.githubusercontent.com/jonasdieckmann/prophet_tutorial/main/passengers.csv\")\n", "\n", "df_data_train = df_data[df_data[\"Month\"] < \"2023-01\"]\n", "df_data_test = df_data[df_data[\"Month\"] >= \"2023-01\"]\n", "\n", "display(df_data_train)" ], "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 424 }, "id": "J9xB-Ob4KzUg", "outputId": "8fc52ed4-aa0f-44e3-d94b-116b60f5680c" }, "execution_count": 3, "outputs": [ { "output_type": "display_data", "data": { "text/plain": [ " Month Passengers\n", "0 2012-01 112\n", "1 2012-02 118\n", "2 2012-03 132\n", "3 2012-04 129\n", "4 2012-05 121\n", ".. ... ...\n", "127 2022-08 559\n", "128 2022-09 463\n", "129 2022-10 407\n", "130 2022-11 362\n", "131 2022-12 405\n", "\n", "[132 rows x 2 columns]" ], "text/html": [ "\n", "
\n", " | Month | \n", "Passengers | \n", "
---|---|---|
0 | \n", "2012-01 | \n", "112 | \n", "
1 | \n", "2012-02 | \n", "118 | \n", "
2 | \n", "2012-03 | \n", "132 | \n", "
3 | \n", "2012-04 | \n", "129 | \n", "
4 | \n", "2012-05 | \n", "121 | \n", "
... | \n", "... | \n", "... | \n", "
127 | \n", "2022-08 | \n", "559 | \n", "
128 | \n", "2022-09 | \n", "463 | \n", "
129 | \n", "2022-10 | \n", "407 | \n", "
130 | \n", "2022-11 | \n", "362 | \n", "
131 | \n", "2022-12 | \n", "405 | \n", "
132 rows × 2 columns
\n", "\n", " | ds | \n", "
---|---|
0 | \n", "2012-01-01 | \n", "
1 | \n", "2012-02-01 | \n", "
2 | \n", "2012-03-01 | \n", "
3 | \n", "2012-04-01 | \n", "
4 | \n", "2012-05-01 | \n", "
... | \n", "... | \n", "
139 | \n", "2023-08-01 | \n", "
140 | \n", "2023-09-01 | \n", "
141 | \n", "2023-10-01 | \n", "
142 | \n", "2023-11-01 | \n", "
143 | \n", "2023-12-01 | \n", "
144 rows × 1 columns
\n", "\n", " | ds | \n", "yhat | \n", "yhat_lower | \n", "yhat_upper | \n", "
---|---|---|---|---|
139 | \n", "2023-08-01 | \n", "532.0 | \n", "507.0 | \n", "555.0 | \n", "
140 | \n", "2023-09-01 | \n", "484.0 | \n", "461.0 | \n", "509.0 | \n", "
141 | \n", "2023-10-01 | \n", "446.0 | \n", "421.0 | \n", "471.0 | \n", "
142 | \n", "2023-11-01 | \n", "416.0 | \n", "390.0 | \n", "443.0 | \n", "
143 | \n", "2023-12-01 | \n", "449.0 | \n", "423.0 | \n", "473.0 | \n", "