pyFTSex/tutorial/darts/quickstart.ipynb

870 lines
724 KiB
Plaintext
Raw Normal View History

2024-08-15 12:15:32 +04:00
{
"cells": [
{
"cell_type": "markdown",
"id": "aea917db",
"metadata": {},
"source": [
"# Darts: Quickstart\n",
"https://unit8co.github.io/darts/quickstart/00-quickstart.html "
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "initial_id",
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-15T10:48:48.119781Z",
"start_time": "2024-04-15T10:48:46.349468Z"
},
"collapsed": true
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from darts import TimeSeries\n",
"from darts.datasets import AirPassengersDataset\n",
"\n",
"series = AirPassengersDataset().load()"
]
},
{
"cell_type": "markdown",
"id": "f7794de6",
"metadata": {},
"source": [
"# Разделение данных"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "dd77e711c2745843",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-31T10:28:06.776388100Z",
"start_time": "2024-03-31T10:28:06.396651400Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACDJklEQVR4nO3dd3gU1foH8O9m0zaNEAIJKYRACL03AREpgjTpHZVYwlX5cdWroF5RESuIyr1XURGIVwMISIuiqLQrVXqVFkIaBEJCetkkO78/lpmdSTZhd7Ml5ft5Hh9mdyYzZ4/AvrznPeeoBEEQQEREROQgTo5uABEREdVvDEaIiIjIoRiMEBERkUMxGCEiIiKHYjBCRERED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aVh5syZaNu2LV544QVMmjSpwiqtRERkPvkwTUNvfXYEAAqLgUvJjmmTJSwKRr755huMHDkSDzzwAKZPny4tDx4TE4MhQ4Zg0KBBWLZsGeQjQOfOncPUqVPRr18/REdH48aNG9b5BFTjzZs3D9euXUNRURESEhLwySefwMPDw9HNIiKq9eQFrD4eQBNfw2tj035rKrODkfXr1+PgwYNYuXIl9u7di4ULF8LFxQX79u3Dhg0bEBMTg/Xr1+PAgQPYunUrAP2mZvPmzcPUqVOxa9cudO7cGQsWLLD6hyEiIqpPcvIN/+j38QS8Zf/Oq03BiFk1I2VlZVi1ahW+/vprabXRVq1aAdCvmzFu3DiEhIQAAGbOnIm4uDiMHTs
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# по процентам\n",
"series1, series2 = series.split_before(0.75)\n",
"series1.plot()\n",
"series2.plot()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "425207ef",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB8BUlEQVR4nO3dd3xUVfo/8M9k0ntCQiCFEHoTpCgCIlXpEpAOK0QEV3+7fFcXQV1ZaTZQFHVtCMTVIALSorFRZOlSpSMkEJKQkEAK6ZNk5vfHcO/cm0ySuVNTPu/Xyxd35t7ce+YIzMNznnOOSqfT6UBERETkIE6ObgARERE1bgxGiIiIyKEYjBAREZFDMRghIiIih2IwQkRERA7FYISIiIgcisEIERERORSDESIiInIoBiN1kFarxbVr16DVah3dlHqB/aUM+8t07Ctl2F/KsL8M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mjWNfsGzzz//HKGhoVWmdI0dOxazZ89GcnIyoqOjERISAm9vbzzwwAPYtWtXjfesPEzz+++/o3v37nB3d0evXr1w6tQp2fUVFRWYPXs2oqKi4OHhgfbt22P16tXi+cWLF+PLL7/Ejh07oFKpoFKp8Ntvvxkdptm3bx8efPBBuLm5oXnz5njppZdQXl4unh84cCDmzZuHBQsWIDAwEM2aNcPixYuVdxwREYmEqb1++gk1jScYIeuYOHEi7ty5g71794rvZWdn46effsK0adNQVFSEESNGYPfu3Th16hSGDx+OMWPGVLuzb2UFBQUYPXo0OnXqhBM
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# по дате\n",
"train, val = series.split_before(pd.Timestamp(\"19580101\"))\n",
"train.plot(label=\"training\")\n",
"val.plot(label=\"validation\")"
]
},
{
"cell_type": "markdown",
"id": "2457080a",
"metadata": {},
"source": [
"# Простая обработка"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "2aa69bb5273f2cf2",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-28T11:33:00.911470500Z",
"start_time": "2024-03-28T11:33:00.615384400Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACEXElEQVR4nO2deXgUVfr9T3f2PWSDQEJYAiggyiKoiCAgCLiAAqIwKi44ow6jjtvMyIz7z2VcZ1FkBBwHVxQVxR1UFFERQUUWE0IgLAGSQMiedNfvj3zrcqu6utPVqe7qJOfzPD5W19a3bje5p8/73vc6FEVRQAghhBBiE067G0AIIYS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ahcmTJ+PTTz/FypUrkZ6ebqoPCSHELOEiRtqLM2J6Nk1RUZFSX1+vKIqi/Pzzz8pZZ52lVFRUKGvXrlUmT56s7NmzRzl06JAyc+ZMZcWKFYqiNM8AmTx5srJixQqlrq5O+ec//6lcffXVlmXhtjfae0b6//73PyUqKkqpqamx5H7tvb+shv3lP+wrc3Sk/urXr5+YwfLAAw8EdA8r+mvt2rWaWZ36GZBtBdM5Iz169BDbDocDTU1NOHToEFatWoVp06YhJycHADBnzhysXLkSU6dOxffff4+oqChMnToVAHD11Vdj3Lhx2Lt3r2E4oqGhwaPCZmRkJKKjo802t02iJn+aSQINZ/773/+iV69e6NatGzZv3ow77rgDM2bMQExMjCXP2N76K9iwv/yHfWWOjtR
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"series_noise = TimeSeries.from_times_and_values(\n",
" series.time_index, np.random.randn(len(series))\n",
")\n",
"(series / 2 + 20 * series_noise - 10).plot()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "61b68acb9eeb8982",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-28T11:33:03.886439200Z",
"start_time": "2024-03-28T11:33:03.561839700Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAicAAAGwCAYAAABy28W7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAB+VElEQVR4nO3deVzUdf4H8NcM9ykKCqIIKoeWF155hHcqmtupHdaWWbqVS+q22paVtu2mlZZ27LZe7ZZWZllaHqlp5ZWad0oqKJdyCCKCwAAzvz/m9/30/Q4zMN9hLuD1fDx69GXmy3y/8x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yQsLAyxsbG1Xmfv3r0YNGiQ6FYBjNUGU4mJiUhMTMTf/vY3DBw4EGvXrhVdIPHx8YiPj8esWbPwwAMPYPXq1bjrrrvQu3dvnD592ux1rZWQkICPP/4YlZWV8PHxAQAcOnRIcU7v3r3xxRdfICYmRnXVw8/PDxMmTECPHj0wd+5c3HTTTTh58iR69+5t8z0TETUW8srJrFmz8NZbbwEAXnzxxUYVTjgg1k1ER0cjMDAQeXl5uOOOOxAVFYVff/0V99xzD2JjY2tNJbYkLi4Ohw8fxrZt23D27Fm8+OKLig//Cxcu4G9/+xv279+PjIwMfPfddzh37hy6du2K8vJyzJgxA7t370ZGRgb27t2LQ4cOie6auXPnYt++fZgxYwaOHTuGc+fO4euvv641ILYuDz74IPR6PaZNm4YzZ85g27Z
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"series.map(np.log).plot()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "31f0b660fb1bbb41",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-28T12:00:34.236946800Z",
"start_time": "2024-03-28T12:00:33.929114600Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACNVklEQVR4nO3dd3xUVfr48c9NI51AQhIgnSRU6U0CIkVYsAAqiOKusiquKz9W9+vq6qqr4rqWxbbrui4KuIoFsCCKHVCKKL3XEFKAUAIhPZNk7u+Pm5l7J42ZSWYm5Xm/XrxyZu6duWdOQu6Tc55zjqKqqooQQgghhId4eboCQgghhGjbJBgRQg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LQ05syZw6lTp5rmE4hm73//+x8bNmwgIyODTz/91LqGSFMEIkII0ZYZh2k6BMPQnvrj0+fdXx9nOZzAumzZMn766SfeeustoqKiOHr0KL6+vmzYsIHly5ezZMkS/P39uffee4mPj2fq1KmYTCYefPBB7rrrLiZNmsSbb77JY489xptvvumKzySamdzcXB5//HFyc3Pp3Lkz06dP529/+5unqyWEEC1efpH+R39YCLQPNh7zQIWc5FAwUlVVxaJFi3jzzTeta2qkpKQA2uyQadOmERMTA8Ctt97KqlWrmDp1Ktu2bcPX15epU6cCcMcddzBu3DhOnDhRZ6KmyWSqtfeIj48Pfn5+Dn/AlsgyLdaR6bH
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"series.map(np.sqrt).stack(series).plot()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "11c98812823b3e9b",
"metadata": {
"ExecuteTime": {
"end_time": "2024-03-31T10:46:17.602162900Z",
"start_time": "2024-03-31T10:46:17.108542400Z"
},
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAABwxklEQVR4nO3deVxU5f4H8M+BYRkWQUHZZREwl1TcFc1c0ly6arlGpaTSrfx5rV9p9dNuZbdbds3s1u2WqXSLMjWXuNrqllvlvpuCNCyKIArIOsCc3x+HmTPDOgOzAZ/36+WLM3POzHnmATlfvs/zfI8giqIIIiIiIhtxsHUDiIiIqG1jMEJEREQ2xWCEiIiIbIrBCBEREdkUgxEiIiKyKQYjREREZFMMRoiIiMimGIwQERGRTTEYsUM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0tLSsH37dl0NEXMEIkREbZl+ZqS9J9Bbb4pfbr7Vm9NkJk9g3bRpE44cOYJ169bBz88PKSkpcHJywsGDB7F582YkJibC1dUVTz/9NEJDQzFlyhSo1WosWbIECxYswPjx4/HJJ59g+fLl+OSTTyzxmcjOZGdn4+WXX0Z2djYCAgIwffp0/O1vf7N1s4iIWrz8IvmP/vaegLeHAKn0FVBQx0obe2VSMFJVVYX169fjk08+0dXUiIqKAiCtDpk6dSqCg4MBAI888giSk5MxZcoUHD9+HE5OTpgyZQoAYN68eRg9ejSysrLqnKipVqtr3XtEoVDA2dnZ5A/YEmmXxZq
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"series.map(lambda ts, x: x / ts.days_in_month).stack(series).plot()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "9235dd3d796f2581",
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='time'>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhwAAAGvCAYAAAAQSAw6AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAABdpElEQVR4nO3dd1hT5/sG8DvsJe6KKALuLcuJAqIVxSpqFVQcYB211m2rtg60Vat+3VtbwYEI7j1blqPuvUFkWNxaZZvk/P7g52lTBUWTHAj357q82jwn5+TJS4Cb9z05kQmCIICIiIhIg/SkboCIiIh0HwMHERERaRwDBxEREWkcAwcRERFpHAMHERERaRwDBxEREWkcAwcRERFpHAMHERERaZzOBw6lUomEhAQolUqpW9F5HGvt4VhrD8dauzje2qPtsdb5wEFERETSY+AgIiIijWPgICIiIo1j4CAiIiKNY+AgIiIijWPgICIiIo1j4CAiIiKNY+AgIi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8Px6RJk3DkyBE0a9bsncf71LF5l8aNG6NatWrYvHkzhg4dih07dqicazF37lwsWrQICxcuRIMGDWBubo5Ro0a9dZ2Z//aV39cgLS0Nzs7OCA0NfWvf8uXLi487ceJEHD58+IPGhoh0k1KpRLfhMdh1qRlgkBssZPLnmNg9DjPGSLiE8h88BViD3pzHsWDBAjFcvAkcUVFR8PDwyHNfIyMj8YTTgqhTpw5Onjyp8svs+PHjKFGiBCpXrgwg9xdWamqquP3ly5dISEhQOY6hoeFHPf7HkMl
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#Восстановление пропущенных значений\n",
"\n",
"from darts.utils.missing_values import fill_missing_values, extract_subseries\n",
"\n",
"values = np.arange(50, step=0.5)\n",
"values[10:30] = np.nan\n",
"values[60:95] = np.nan\n",
"series_ = TimeSeries.from_values(values)\n",
"\n",
"\n",
"fill_missing_values(series_).plot(label=\"without missing values\")\n",
"(series_).plot(label=\"with missing values (shifted below)\")\n",
"# extract_subseries(series_, mode=\"any\") # выбирает существующие отрезки"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "aa5e2e40",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACuI0lEQVR4nOydd3xT5f7HPydJR7r33qWFssoWRYaAgnCVIltURBS9Dhy4BQUXXlARx736c4ADWcpyK8ree8/uvfdKk5zfHyc5T9IkbZIm6eD7fr18ecZzznnytOV88p0cz/M8CIIgCIIg2glJe0+AIAiCIIjrGxIjBEEQBEG0KyRGCIIgCIJo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332Lv3r04e/Ys5syZYxCkGhMTg7///hsFBQVmvayt5fDhw3j77bdx7NgxZGVlYfPmzSguLkZSUhLS09Px0ksv4eDBg8jMzMTevXtx9epVJCUlWfWsHj16YOzYsZg/fz6OHDmCkydPYv78+ZDL5a0Gfs6ePRsnTpzAW2+9halTp8LFxUU8l5CQIFp3Ll68iIcffhiFhYUt3m/06NH4+OOPcfLkSRw7dgyPPPKInlVn9uzZCAgIwKRJk7B3716kp6dj165dWLBgAXJycgzW5s8//2zT2hAE0XEpKKkzOFbJ98bltNJ2mI31kBhpR0aOHAmVSiWKET8/P/Ts2RMhISGIi4szed2UKVMwfvx43HLLLQgMDGw1VVRLeHg4fv31Vxw5cgTJycl45JFHMG/ePCxatEgc89JLL2HkyJH417/+hYkTJyIlJQXx8fF
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# проверка восстановления более сложного ВР -> восстановление значений линейно между последними значениями\n",
"series_ = series.copy()\n",
"values_ = series_.all_values(copy=False)\n",
"values_[10:30] = np.nan\n",
"values_[60:102] = np.nan\n",
"\n",
"\n",
"fill_missing_values(series_).plot(label=\"without missing values\")\n",
"(series).plot(label=\"with missing values (shifted below)\")"
]
},
{
"cell_type": "markdown",
"id": "c3ac3894",
"metadata": {},
"source": [
"# Forecasting "
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "f7fd1585",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACcEklEQVR4nOydd3gU5drG763JpldIJQmE0DtKE5EiSC8iV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Sk0Js1axbWrFmD5ORki+9PEETdhxcjXl5eAFBrxYhFMSOA4UWFDd2ExMbGIjY21uS5Vq1aYf369ZY+jqgElUrF4nLsRUFBATIzMzFgwACEhIRYfR+NRlNr4oA4jsPy5cvx/vvvV3hNUVERnn76aVy7dg2HDh0yK1q8LGq1GoGBgZg3bx6++OILk9cEBARgwIAB+O677yr8d0cQRP2FT+3lY0VqqxipHZEtdZAnnngCM2fOxOzZs+Hn54egoCAsWLBAdM0XX3yBNm3awN3dHeHh4ZgxYwYKCgrYeaGbJjExERKJBFeuXCl3Dz52BwAuXLiAgQMHwsPDAw0bNsRzzz1XYavp/fv3s1/sPn36QCKRYP/+/QCAzZs3o1WrVnBxcUFkZCSWLl0q+mxkZCQWLVqE559/Hl5eXpg2bRoAQ2vrnj17QqVSITw8HDNnzhQFN6vVasyZMwfh4eFwcXFBdHQ0Vq5cCcBQ52bKlCmIioqCSqVCs2bNsGzZsnJjfvTRR+Hu7g4fHx/06NEDqampiIuLw8KFC3H27FlIJBJIJBLExcWZfO9Tp04
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"#наивное прогнозирование\n",
"from darts.models import NaiveSeasonal\n",
"\n",
"naive_model = NaiveSeasonal(K=1)\n",
"naive_model.fit(train)\n",
"naive_forecast = naive_model.predict(36)\n",
"\n",
"#подбор помог сильно повысить точность благодаря сильно выраженной сезонности \n",
"naive_model_podbor = NaiveSeasonal(K=12)\n",
"naive_model_podbor.fit(train)\n",
"naive_forecast_podbor = naive_model_podbor.predict(36)\n",
"\n",
"series.plot(label=\"actual\")\n",
"naive_forecast.plot(label=\"naive forecast (K=1)\")\n",
"naive_forecast_podbor.plot(label=\"naive forecast (K=12)\")"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "ab2da4d5",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0gAAAGrCAYAAAD6qLfeAAAAOXRFWHR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zNL37xC33qU5/SwoULM8eCwaDOOOMMSdLs2bP1N3/zN1q/fv2wAcnv95dMGBqNx+MpWAexLKugnbHSr1cshewzqAz0GYzHZOwv6ephqazgkl6jMtzP6SlhA0mjRFJKDAxWCkskpWTKyglBJiscpaecZYcWN8dkHkuWs+ZkmMX12etWfJ7Bxx53Cpg3MwUs/192Lbe1Xo9Xxt1Kc+Imf6EQbOOEectjFaTPpJXb35m8BKT58+crEono6NGjmjlzpiRp7969uvLKK0d8zY4dO7Ry5cpR39eyLJnRJpkCAICKl0yeukKYM/piFHfDTGLACTPpYJMZ0TGSnVVqOR1qhpMdTjwe93HWfZWvMAvtAeRXXgJSMBhUa2urtmzZov/6X/+r3njjDe3Zs0etra3Dnt/W1qbdu3frf//v/51z/I9//KOmTJmi5uZmHT9+XN///vd1ySWX5KPJAACgQGzbZKaPnSrkxBNOyIkPSPGEc588afQnPdIzXLBJhxePO9qSXTHMX+U8nw49g88RZoDJLG/L5TZs2KB7771Xy5cv16xZs7Rp0ybV19fr2Wef1fbt23PKe+/YsUOf/exn1dDQkPMeBw8e1Pe//311dXVpypQpuvTSS/Wf//N/zleTAQDAOBkzGHayp51lP47FjaJxKZqQYoncEZyT1+1kTz+TBkdoMjevc19dNfg4E3IINgAmQN4C0tSpU/Xwww8POb5ixYohG73
"text/plain": [
"<Figure size 1000x500 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from darts.utils.statistics import plot_acf, check_seasonality\n",
"\n",
"plot_acf(train, m=12, alpha=0.05, max_lag=24)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "560889da",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"There is seasonality of order 12.\n"
]
}
],
"source": [
"# проверка сезонности\n",
"for m in range(2, 25):\n",
" is_seasonal, period = check_seasonality(train, m=m, alpha=0.05)\n",
" if is_seasonal:\n",
" train_period = period\n",
" print(\"There is seasonality of order {}.\".format(period))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "898483cd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACO00lEQVR4nO3dd3xT5f4H8E9GR7o3nZQyC2UKyhYZUtlDpqBQUVR+XpwX0Asq4kBRFDcitF6tIHsogjLkggxZBQERaEsHUFq6m7ZJm5zfH+E8OSdN2iTN6Pi+X6/7uifJafLkgJxPv8+ScBzHgRBCCCHESaTObgAhhBBCmjcKI4QQQghxKgojhBBCCHEqCiOEEEIIcSoKI4QQQghxKgojhBBCCHEqCiOEEEIIcSoKI4QQQghxKgojDZBWq0V6ejq0Wq2zm9Io0PWyDF0v89G1sgxdL8vQ9dKjMEIIIYQQp6IwQgghhBCnojBCCCGEEKeiMEIIIYQQp6IwQgghhBCnojBCCCGEEKeiMEIIIYQQp6IwQgghhBCnojBCCCGEEKeiMEIIIYQQp6IwQgghhBCnojBCCCGEEKeiMEIIIYQQp6IwQmqYPXs2xo8f7+xmEEIIaSYojDRSb7zxBrp37+7sZhBCCHGyoqIiJCYmIjMz09lNsRqFEUIIIaQRmzt3Lh5//HE89NBD0Gq1zm6OVSiMONGePXswYMAA+Pn5ITAwEKNHj0Zqaip7PTs7G9OnT0dAQAA8PT3Rq1cvnDhxAklJSVi6dCnOnTsHiUQCiUSCpKQkXL9+HRKJBCkpKew9ioqKIJFI8PvvvwMANBoN5syZg5iYGCgUCnTo0AGrVq1y8DcnhBBiK/y/+X///TdOnz7t3MZYSe7sBthDr169kJOT4/DPDQ0NxalTp8w+X6lU4sUXX0TXrl1RVlaG1157DRMmTMCZM2egVCoxbt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Ts2RMqlQo7duyAWq3GunXr0LFjR6PjRYj5kpKS4OfnZ/fP2b59O9q2bQuZTIbnn3/e7p/XEKjVarRt2xZHjx51dlPq1KdPH2zZssXZzSCEOAEfRry9vSGVSptHGAGAhQsXoqioCMOGDcNzzz2Hp59+Gj169MCAAQMwadIkzJo1C5MmTUKfPn0wbtw4ALpulxUrVmD9+vUYPHgwzp49i2XLltn8yzQ3U6dOdciiNk899RQmTZqErKysRv3n9sYbb6B79+5mnfvVV18hJiYG/fr1Y89JJBJs376dPa6qqsL06dMRERGBCxcuWNyeW7du4ZFHHkH79u0hlUqNBr01a9Zg4MCB8Pf3h7+/P4YNG4Y///xTdM7ixYuxaNGiBjFqnhDiWHwY8fHxAYBGG0YsGjMC6L6ocEM3oYSEBCQkJBh9LS4uDhs2bLD040gtFAoFG5djL2VlZcjNzUV8fDzCw8Otfh+1Wt1oxgFxHIfPPvsMb775pslzysvL8fDDD+Pq1as4cuSIWaPFDalUKgQHB2Px4sX46KOPjJ7z+++/Y/r06ejXrx/c3d3x3nvvYfjw4bh48SKrLI4YMQJPPPEEfvnlF7ZHBSGkeeCn9vJjRRprGGkcI1uaoAceeADz58/HggULEBAQgNDQULzxxhuicz766CN06dIFnp6eiIqKwrx581BWVsZeF3bTXLlyBRKJBJcvX67xHvzYHQC4cOECRowYAS8vL7Ro0QKPPvqoya2mf//9d/YXe8iQIZBIJPj9998BAFu2bEFcXBzc3NzQqlUrfPjhh6KfbdWqFZYtW4bHHnsMPj4+mDt3LgDd1tYDBw6EQqFAVFQU5s+fLxrcrFKpsHDhQkRFRcHNzQ1t27bF2rVrAejWuZkzZw5iYmKgUCjQoUMHrFq1qkab77vvPnh6esLPzw/9+/d
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# использование поиска сезонности для автоматической подстановки\n",
"seasonal_model = NaiveSeasonal(K=train_period)\n",
"seasonal_model.fit(train)\n",
"seasonal_forecast = seasonal_model.predict(36)\n",
"\n",
"series.plot(label=\"actual\")\n",
"seasonal_forecast.plot(label=\"naive forecast (K=12)\")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "bf029400",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiMAAAGvCAYAAACJsNWPAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACUF0lEQVR4nO3dd3gU5doG8Htrsum9h4RegnREuhRBmhRpCgpIsx0+G2JDBdSjoCg2RATiUVABQUBRVJoUUVroNT2QkJBC+m6yO98fk3l3Jtkku5stKc/vus51ZndmZ94dYubOW2Ucx3EghBBCCHESubMLQAghhJCmjcIIIYQQQpyKwgghhBBCnIrCCCGEEEKcisIIIYQQQpyKwgghhBBCnIrCCCGEEEKcisIIIYQQQpyKwkg9ZDAYkJiYCIPB4OyiNAh0vyxD98t8dK8sQ/fLMnS/jCiMEEIIIcSpKIwQQgghxKkojBBCCCHEqSiMEEIIIcSpKIwQQgghxKkojBBCCCHEqSiMEEIIIcSpKIwQQgghxKkojBBCCCHEqSiMEEIIIcSpKIwQQgghxKkojBBCCCHEqSiMEEIIIcSpKIwQQgghxKkojNQDWVlZUKvVKCoqQllZGTw9PXHjxg22Pzo6GjKZDDKZDO7u7ujWrRu2bNnixBITQgipL/Ly8rBhwwakpKQ4uyhWozBSD/z999/o3Lkz3N3dcerUKfj5+SE8PFxyzNKlS5Geno7Tp0+jZ8+emDJlCo4ePeqkEjufTqdzdhEIIaRemDdvHh577DHcf//9MBgMzi6OVSiM1ANHjx5F3759AQCHDx9Gnz59qhzj6emJkJAQtGnTBp999hk0Gg127doFvV6P2bNno3nz5tBoNGjbti1WrVol+eyB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z9t9vd8+OGHYTAYMG/ePFy6dAl79uzB+++/DwCsduepp55CTk4OHnroIRw/fhzx8fHYs2cPZs2aBb1eX+25Y2NjsW7dOpw/fx4pKSnYuHEjNBoNoqKizC4fIYQ0ZKbCyOHDhyWjERsCCiNOdODAAfTs2ROurq74999/ERERIWmWMMf8+fMxYcIETJkyBb169UJ2draklsTNzQ2XL1/Ggw8+iDZt2mDevHl46qmnMH/+fCgUCmRnZ+PRRx9FmzZtMHnyZIwYMQJLliwBwPcFOXjwIK5evYr+/fuja9eueP311xEWFmZ2+by8vLBr1y7ExcWhS5cuePXVV/H6668DAOtHEhYWhiNHjkCv12PYsGG466678Mwzz8DHxwdyefU/oj4+Pli7di369++PkSNHYu/evdi1axf8/f0tuoeEENJQicOI8PvSYDDg559/dlaRrCLjOI5zdiGIlMFgQHJyMqKiomp8GDdUGzduxKxZs3Dnzh1oNJo6n6+x3y9bo/tlPrpXlqH7ZRlb3K/du3ezwQzDhg3D77//DgAYN24ctm/fbrOy2hv1GSF297///Q8tWrRAeHg4zpw5w+YQsUUQIYSQpuzOnTtse/jw4YiLi0NmZib27NmDkpKSBvN7lqIrsbuMjAxMnz4d7du3x7PPPotJkyZVmaWVEEKI5cTNNL6+vhg2bBgAoKSkBFevXnVWsSxmVRj5+uuvMWrUKAwYMAAPP/wwmx48NjYWQ4cOxeDBg7Fq1SqIW4AuXLiAqVOnom/fvpg3bx7S09Nt8w1Ivffiiy8iKSkJpaWlSExMxIcffgg3NzdnF4sQQho8cRjx8vJCUFAQe21q2G99ZXEY2bx5M/7++2+sW7cOBw8exJIlS6BSqXD48GFs2bIFsbGx2Lx5M44ePYodO3YA4Bc1e/HFFzF16lTs27cPnTt3xuLFi23+ZQghhJCmpHIY8fT0ZK8bUhixqM+IXq/H+vXr8dVXX7HZRlu3bg2
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Добавляем линейный тренд (drift)\n",
"from darts.models import NaiveDrift\n",
"\n",
"drift_model = NaiveDrift()\n",
"drift_model.fit(train)\n",
"drift_forecast = drift_model.predict(36)\n",
"\n",
"combined_forecast = drift_forecast + seasonal_forecast - train.last_value()\n",
"\n",
"series.plot()\n",
"combined_forecast.plot(label=\"combined\")\n",
"drift_forecast.plot(label=\"drift\")"
]
},
{
"cell_type": "markdown",
"id": "d73c6968",
"metadata": {},
"source": [
"## Метрики качества"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "d33d080f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Mean absolute percentage error for the combined naive drift + seasonal: 5.66%.\n"
]
}
],
"source": [
"from darts.metrics import mape\n",
"\n",
"print(\n",
" f\"Mean absolute percentage error for the combined naive drift + seasonal: {mape(series, combined_forecast):.2f}%.\"\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "5fb8943a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"model ExponentialSmoothing() obtains MAPE: 5.11%\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"model TBATS() obtains MAPE: 5.87%\n",
"model AutoARIMA() obtains MAPE: 11.65%\n",
"model Theta() obtains MAPE: 8.15%\n"
]
}
],
"source": [
"from darts.models import ExponentialSmoothing, TBATS, AutoARIMA, Theta\n",
"\n",
"def eval_model(model):\n",
" model.fit(train)\n",
" forecast = model.predict(len(val))\n",
" print(f\"model {model} obtains MAPE: {mape(val, forecast):.2f}%\")\n",
"\n",
"eval_model(ExponentialSmoothing())\n",
"eval_model(TBATS())\n",
"eval_model(AutoARIMA())\n",
"eval_model(Theta())"
]
},
{
"cell_type": "markdown",
"id": "255b5f32",
"metadata": {},
"source": [
"# Theta method\n",
"Данный метод не рассматривался для экономии времени"
]
},
{
"cell_type": "markdown",
"id": "8bccf5f0",
"metadata": {},
"source": [
"# Модели машинного обучения\n",
"Пример моделей:\n",
"- RegressionModel can wrap around any sklearn-compatible regression model to produce forecasts (it has its own section below).\n",
"- RNNModel is a flexible RNN implementation, which can be used like DeepAR.\n",
"- NBEATSModel implements the N-BEATS model.\n",
"- TFTModel implements the Temporal Fusion Transformer model.\n",
"- TCNModel implements temporal convolutional networks.\n",
"- …"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "22339b4b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAisAAAGwCAYAAABo5yU1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAClmklEQVR4nOydd3wUZf7HP7N9s+kJJIQ0IPQiVZoQRKTKTxBBigX0xIJynp6id4Kop3engnqnnhwqWEBFQRRFOUHgpBwIUoRQQoAQSgjpdfv8/thM3dnd2dQlfN+vly9nZ+Z55tmHZPeTb2VYlmVBEARBEAQRomiaewEEQRAEQRD+ILFCEARBEERIQ2KFIAiCIIiQhsQKQRAEQRAhDYkVgiAIgiBCGhIrBEEQBEGENCRWCIIgCIIIaUisEARBEAQR0pBYIQiCIAgipGmxYsXtduPMmTNwu93NvZRmh/ZCgPZCgPZCgPZCgPZCgPZCoLn3Iiix8uWXX2LWrFkYOHAgli1bJrm2YcMGjB8/HpmZmXj++efhcDj4a+fPn8e9996LoUOHYtasWTh58iR/ze12Y8mSJRgxYgRGjx6NVatW1fMtEQRBEATRkghKrMTHx2Pu3LkYOXKk5PypU6ewdOlSvPrqq/juu+9w+fJlvPfee/z1P/3pTxg4cCB++uknTJ48GU8++SScTicAYO3atdi/fz/WrVuH9957D5988gn27t3bAG+NIAiCIIiWQFBiZcSIEcjMzERERITk/A8//ICRI0eie/fuCA8Px7333ovvvvsOAHD27FmcOXMGc+bMgdFoxO233w63242DBw8CADZu3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rx8JAduFgBYPHPgBNZm9m3uJfnlmhQr+fn5uHDhQnMvwy86nQ7p6elYs2YNBgwYgF69emHnzp1ISEjA8OHDve5fsGABnn32WVitVoSHh+Nvf/sb37bgnXfewbJly5Cfn4+amhrY7Xa+3UFsbCxmz56NMWPG4Oabb8aoUaMwbdo0tGnTBgDw+OOP43e/+x0+/vhjjBo1ClOnTuVFzaFDh3D48GGsWrWKXwfLsnC73Thz5gwvenr16sVfZxgGiYmJKCgoAACcOHECvXr14oUNAK8KxocOHcLWrVsVxVlOTg4vVvr16ye5NnXqVLzxxhto3749xo4di/Hjx1MrB4Ig6kXu8nPIeuY4jAkGZP4yDDpL03+NVjidkteFVjviTep75gFAjSjWJbequkHW1Zhck2IlMTEx5J/bvXt35ObmwuFwwO12Izw8HE6nE06nE+Hh4UhLS8PRo0f5+5988knMnj2bj+ng3DifffYZnnzySTzzzDOYMGECoqKi8Oqrr2LPnj382BUrVmD+/Pn44Ycf8Pnnn+PZZ5/Fjz/+iEGDBmHx4sWYOXMmvvvuO3z//fd47rnn8Nlnn2Hy5MmorKzEAw88gPnz53utXxwAzLmNOBiGgdvtVr0XlZWVmDhxIv7+9797XeNEFQBYLBbJtZSUFJw4cQKbN2/Gjz/+iIcffhjt2rXDypUrVT+bIAhCTNYzxwEAtst2XNlSiDb/F/z3yeZLhfh39jnM7ZiKUW3igx5f4ZAG1Z4or0S8KTaoOWINwudyid3p587Q4JoUK2pdMc3Jxo0b4XA4cNNNN+GVV15Bv379MH36dMyePRtjx471EgDx8fHIyMjwmmfnzp0YMmQI7rrrLr5Mck6Ot4+zT58+6NOnD5555hkMHjwYq1evxqBBgwAAnTp1QqdOnfCHP/wBM2bMwIoVKzB58mT07dsXWVlZis9VS+fOnfHJJ5/AZrPBaPSYVH/55RfJPX379sXatWuRnp7O95RSi9lsxsSJEzFx4kTMmzcPXbp0wYkTJ+q1ZoIgCAC
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from darts.datasets import AirPassengersDataset, MonthlyMilkDataset\n",
"\n",
"series_air = AirPassengersDataset().load().astype(np.float32)\n",
"series_milk = MonthlyMilkDataset().load().astype(np.float32)\n",
"\n",
"# set aside last 36 months of each series as validation set:\n",
"train_air, val_air = series_air[:-36], series_air[-36:]\n",
"train_milk, val_milk = series_milk[:-36], series_milk[-36:]\n",
"\n",
"train_air.plot()\n",
"val_air.plot()\n",
"train_milk.plot()\n",
"val_milk.plot()"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "28e3676d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAiAAAAGvCAYAAABih26MAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAACbL0lEQVR4nO2deXwU9f3/X7PZbPbIScJNEu5DEYFiPQBjhSqnVhQ8aFWqQqv+UKsott5aC1XRarWloKAFtSpeKGjFr6AgCh6oFREImHAFQsh97TW/PzYz85nZmdmZ2SOb7Pv5ePDI7OzMZz87JDuvfb2PD8fzPA+CIAiCIIgEYmvvCRAEQRAEkXqQACEIgiAIIuGQACEIgiAIIuGQACEIgiAIIuGQACEIgiAIIuGQACEIgiAIIuGQACEIgiAIIuGQACEIgiAIIuF0CAESDAaxf/9+BIPB9p5K0kPXyhx0vYxD18ocdL2MQ9fKHJ3lenUIAUIQBEEQROeCBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAmHBAhBEARBEAnHlAB57bXXMHv2bJx++ulYunSp5nHBYBCPPfYY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TAwYMAAA8M033+Dbb7+VVS7xPI9gMIj9+/dj2LBhACCGa4CQUOrRoweOHTsGIBRaGTFihChWAITl/3zzzTf46KOPkJmZGfa+hbANAPzsZz+TPTdz5kw88cQT6N+/PyZNmoQpU6Zg+vTpsNvj8qscU9RcwNbW1naYCUEQnZmG9ou+mMLUp7bf70cgEEAwGEQgEEBrayvsdntYEt3kyZPx73//G2eccQYaGhrw5ptv4r777ovlvMP44osv4jp+LDj55JNRVlYGn8+HYDCIzMxM+P1++P1+ZGZmori4GN9//714/IIFC3D11VcjMzMT3bt3B8eFFO3LL7+M2267DY899hjOPPNMZGVl4ZFHHsHnn38unvvcc8/hpptuwnvvvYf//Oc/uOuuu/DBBx/gjDPOwH333YcrrrgC7777LtavX497770XL7/8Mi666CI0NDRg3rx5mD9/ftj8i4qKxO309HTZcxzHmUoga2howPTp07F48eKw5wShBEAWygOAwsJC/Pjjj9iwYQM++OADXH/99XjkkUewadOmsDklGyRACIJIBJ1SgDz77LOyZNHnnnsO9957L/r06YP58+fjk08+AQBccsklOHDgAC666CKkp6fjqquu0qyASSXWrVsHn8+HCRMm4K9//St+9rOf4bLLLsPVV1+NSZMmhd1ACwoKMHDgwLBxtmzZgrPOOgvXX3+9uK+0tDTsuFGjRmHUqFG48847ceaZZ+LFF18UwxWDBw/G4MGDccstt+Dyyy/HihUrcNFFF2H06NHYuXOn6usaZciQIVi1apWYQAuEEltZRo8ejTVr1qBv376m3QuXy4Xp06dj+vTpuOGGGzB06FB89913GD16tOU5JwISIARBJIITdTyAThaCmTdvHubNm6f6nCA+gFBc6tZbb8Wtt94a3ew6GcXFxaioqMDRo0dx4YUXguM4fP/997j44otl3/ojMWjQILzwwgt4//330a9fP/z73//G9u3bxczjAwcOYOnSpbjwwgvRq1cv/Pjjj9izZw+uvPJKNDc3Y8GCBbjkkkvQr18/HDx4ENu3b8fFF18MIBT2OeOMM3DjjTfi2muvhcfjwc6dO/HBBx/g73//u6H5XXHFFfjTn/6EuXPnYuHChSgvL8ejjz4KAKKLc8MNN2DZsmW4/PL
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# масштабирование\n",
"from darts.dataprocessing.transformers import Scaler\n",
"\n",
"scaler = Scaler()\n",
"train_air_scaled, train_milk_scaled = scaler.fit_transform([train_air, train_milk])\n",
"\n",
"train_air_scaled.plot()\n",
"train_milk_scaled.plot()"
]
},
{
"cell_type": "markdown",
"id": "4536efeb",
"metadata": {},
"source": [
"## Пример: N-BEATS\n",
"\n",
"Нужные параметры для настройки\n",
"- `input_chunk_length`: this is the “lookback window” of the model - i.e., how many time steps of history the neural network takes as input to produce its output in a forward pass.\n",
"\n",
"- `output_chunk_length`: this is the “forward window” of the model - i.e., how many time steps of future values the neural network outputs in a forward pass."
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "21cac240",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"GPU available: False, used: False\n",
"TPU available: False, using: 0 TPU cores\n",
"HPU available: False, using: 0 HPUs\n",
"\n",
" | Name | Type | Params | Mode \n",
"-------------------------------------------------------------\n",
"0 | criterion | MSELoss | 0 | train\n",
"1 | train_criterion | MSELoss | 0 | train\n",
"2 | val_criterion | MSELoss | 0 | train\n",
"3 | train_metrics | MetricCollection | 0 | train\n",
"4 | val_metrics | MetricCollection | 0 | train\n",
"5 | stacks | ModuleList | 6.2 M | train\n",
"-------------------------------------------------------------\n",
"6.2 M Trainable params\n",
"1.4 K Non-trainable params\n",
"6.2 M Total params\n",
"24.787 Total estimated model params size (MB)\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ce63a7a3fdfa4c8fa5065c81374a9ac3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Training: | | 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"`Trainer.fit` stopped: `max_epochs=50` reached.\n"
]
}
],
"source": [
"from darts.models import NBEATSModel\n",
"\n",
"model = NBEATSModel(input_chunk_length=24, output_chunk_length=12, random_state=42)\n",
"\n",
"model.fit([train_air_scaled, train_milk_scaled], epochs=50, verbose=True);"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "5e2f9580",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"GPU available: False, used: False\n",
"TPU available: False, using: 0 TPU cores\n",
"HPU available: False, using: 0 HPUs\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c9a6fdcbc4a24d419bb730cf849ab034",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Predicting: | | 0/? [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<Axes: xlabel='Month'>"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA0IAAAIMCAYAAADYexzcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAADfJklEQVR4nOydd3gc5b39z+xKWq167902xgUbsDEYG0wvBoIJvQUIF3JJAmlAuFwglJtAIJAAv4QEAphQQ4AAwVRjDNgYYwwuuFuy1SxLVpd2JW2b3x+jadu0szuyV9b5PA+P3p32TpHFnD3fIoiiKIIQQgghhBBCxhGWA30ChBBCCCGEELK/oRAihBBCCCGEjDsohAghhBBCCCHjDgohQgghhBBCyLiDQogQQgghhBAy7qAQIoQQQgghhIw7KIQIIYQQQggh4w4KIUIIIYQQQsi4g0KIEEIIIYQQMu4YF0LI5/Nh165d8Pl8B/pUSAj4jOIfPqP4hs8n/uEzin/4jOIfPqP4Zqw9n3EhhAghhBBCCCFEC4UQIYQQQgghZNxBIUQIIYQQQggZd1AIEUIIIYQQQsYdFE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vjhhyIA8ZNPPlH2u/rqq8XMzEwxKytLvOGGG8TbbrtNnDlzpjLvVVddJZ577rlhz/8vf/mLeMwxx+iWvfTSS2JVVZVos9nEuXPnim+//bYIQPz2229Fr9crvvTSSyIAsaurSxRFUXz22WfFzMz
"text/plain": [
"<Figure size 1000x600 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"pred_air, pred_milk = model.predict(series=[train_air_scaled, train_milk_scaled], n=36)\n",
"\n",
"# scale back:\n",
"pred_air, pred_milk = scaler.inverse_transform([pred_air, pred_milk])\n",
"\n",
"plt.figure(figsize=(10, 6))\n",
"series_air.plot(label=\"actual (air)\")\n",
"series_milk.plot(label=\"actual (milk)\")\n",
"pred_air.plot(label=\"forecast (air)\")\n",
"pred_milk.plot(label=\"forecast (milk)\")"
]
}
],
"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.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}