pyFTSex/tutorial/pyFTS/developer/GOOGLE COLAB - Ismail & Efendi - ImprovedWeightedFTS.ipynb

959 lines
722 KiB
Plaintext
Raw Permalink Normal View History

2024-08-15 12:15:32 +04:00
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "Ismail%20%26%20Efendi%20-%20ImprovedWeightedFTS.ipynb",
"version": "0.3.2",
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"[View in Colaboratory](https://colab.research.google.com/github/petroniocandido/pyFTS/blob/master/pyFTS/notebooks/GOOGLE%20COLAB%20-%20Ismail%20&%20Efendi%20-%20ImprovedWeightedFTS.ipynb)"
]
},
{
"metadata": {
"id": "JslYilggi0HL",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"# First Order Improved Weighted Fuzzy Time Series by Efendi, Ismail and Deris (2013)\n",
"\n",
"R. Efendi, Z. Ismail, and M. M. Deris, “Improved weight Fuzzy Time Series as used in the exchange rates forecasting of \n",
"US Dollar to Ringgit Malaysia,” Int. J. Comput. Intell. Appl., vol. 12, no. 1, p. 1350005, 2013."
]
},
{
"metadata": {
"id": "DzVVKHPNi0HP",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Environment Setup"
]
},
{
"metadata": {
"id": "JGMvfv1Fi0HR",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Library install/update"
]
},
{
"metadata": {
"id": "tlFMsqImi0HT",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"!pip3 install -U git+https://github.com/petroniocandido/pyFTS\n",
"!pip3 install dill"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "WyNTIoSli0Hb",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### External libraries import"
]
},
{
"metadata": {
"id": "dnImGFxmi0Hd",
"colab_type": "code",
"colab": {},
"outputId": "8f71febe-378a-4317-df3d-fa38fa23d9b0"
},
"cell_type": "code",
"source": [
"import warnings\n",
"warnings.filterwarnings('ignore')\n",
"\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pylab as plt\n",
"import seaborn as sns\n",
"\n",
"%pylab inline"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "qrj1Rykpi0Ho",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Common pyFTS imports "
]
},
{
"metadata": {
"id": "fMuSTFPki0Hp",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.common import Util as cUtil\n",
"from pyFTS.benchmarks import benchmarks as bchmk, Util as bUtil\n",
"from pyFTS.partitioners import Util as pUtil\n",
"\n",
"from pyFTS.models import ismailefendi\n"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "d74EgH_yi0Hu",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Common data transformations"
]
},
{
"metadata": {
"id": "Wc5adG6ji0Hx",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.common import Transformations\n",
"\n",
"tdiff = Transformations.Differential(1)\n",
"\n",
"boxcox = Transformations.BoxCox(0)"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "1qAPqLl-i0H8",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Datasets"
]
},
{
"metadata": {
"id": "SZ0QWfoPi0H_",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Data Loading"
]
},
{
"metadata": {
"id": "f92yR8w8i0IB",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.data import TAIEX, NASDAQ, SP500\n",
"\n",
"dataset_names = [\"TAIEX\", \"SP500\",\"NASDAQ\"]\n",
"\n",
"def get_dataset(name):\n",
" if dataset_name == \"TAIEX\":\n",
" return TAIEX.get_data()\n",
" elif dataset_name == \"SP500\":\n",
" return SP500.get_data()[11500:16000]\n",
" elif dataset_name == \"NASDAQ\":\n",
" return NASDAQ.get_data()\n",
"\n",
"\n",
"train_split = 2000\n",
"test_length = 200"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "GF-j8XPhi0IH",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Visualization"
]
},
{
"metadata": {
"id": "JYaHcBqWi0IJ",
"colab_type": "code",
"colab": {},
"outputId": "22c691db-8fb3-4e23-8625-73281801c929"
},
"cell_type": "code",
"source": [
"fig, ax = plt.subplots(nrows=2, ncols=3, figsize=[10,5])\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
" dataset_diff = tdiff.apply(dataset)\n",
"\n",
" ax[0][count].plot(dataset)\n",
" ax[1][count].plot(dataset_diff)\n",
" ax[0][count].set_title(dataset_name)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmoAAAE/CAYAAAD2ee+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzsnXd4FOX2x79n0yD0EjoYCAEEpIug\nFBGkesUuVvSiXK+9XQV7F7tiwWvB8ruKoGIF6V167yWE0EsIEEhC6p7fH/PO7ruzs32TnV3ez/Pk\nYeadsrMhM3PeU76HmBkKhUKhUCgUCuthi/QFKBQKhUKhUCjMUYaaQqFQKBQKhUVRhppCoVAoFAqF\nRVGGmkKhUCgUCoVFUYaaQqFQKBQKhUVRhppCoVAoFAqFRVGGmkKhUCgUCoVFUYZalEJEedKPnYjO\nSuu3SPvdQURMRDcajr+UiA5I6wuIqNBw3j/Etn8Q0REiqi3tP5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ohUKhCBo1b1CcK7zw+xbH\n8sFTZ3HLF8uROmYadh0947Jfed8TPg01Zl4E4IRheDiAb8TyN9B0nvTxb1ljOYCaQhdqEIDZzHyC\nmU8CmA1gsKwZJbwG30rnshxxtuCdfXbpP9JyLkOFQqHwA2bGij3a66Bzs5p+HSM6cmwSHThWi7Gw\nRWUUivJg7raj+EZyqmw+mIu/M3IAAJe/t8hl31MFmnd5YNv65XItweao1RdJzwBwBIB+dY0B7Jf2\n0zWgvI0HpBlFRKuJaHV2dvDerWAJwU6DbHCr+ai1eX36NkxcsifSl6FQWI4pq/djxGfLAQA3Xdgs\nkEP7iTB/N7Eez
"text/plain": [
"<matplotlib.figure.Figure at 0x7efc38b13a90>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"metadata": {
"id": "QHdi1WcDi0IR",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Statistics"
]
},
{
"metadata": {
"id": "sGSm6qO9i0IS",
"colab_type": "code",
"colab": {},
"outputId": "5a7c034a-bd1f-42ea-9a10-3ac33497353f"
},
"cell_type": "code",
"source": [
"from statsmodels.tsa.stattools import adfuller\n",
"\n",
"rows =[]\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" row = [dataset_name]\n",
" dataset = get_dataset(dataset_name)\n",
" result = adfuller(dataset)\n",
" row.extend([result[0],result[1]])\n",
" row.extend([value for key, value in result[4].items()])\n",
" rows.append(row)\n",
" \n",
"pd.DataFrame(rows,columns=['Dataset','ADF Statistic','p-value','Cr. Val. 1%','Cr. Val. 5%','Cr. Val. 10%'])\n"
],
"execution_count": 0,
"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>Dataset</th>\n",
" <th>ADF Statistic</th>\n",
" <th>p-value</th>\n",
" <th>Cr. Val. 1%</th>\n",
" <th>Cr. Val. 5%</th>\n",
" <th>Cr. Val. 10%</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>TAIEX</td>\n",
" <td>-2.656728</td>\n",
" <td>0.081830</td>\n",
" <td>-3.431601</td>\n",
" <td>-2.862093</td>\n",
" <td>-2.567064</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>SP500</td>\n",
" <td>-1.747171</td>\n",
" <td>0.406987</td>\n",
" <td>-3.431811</td>\n",
" <td>-2.862186</td>\n",
" <td>-2.567114</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>NASDAQ</td>\n",
" <td>0.476224</td>\n",
" <td>0.984132</td>\n",
" <td>-3.432022</td>\n",
" <td>-2.862279</td>\n",
" <td>-2.567163</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dataset ADF Statistic p-value Cr. Val. 1% Cr. Val. 5% Cr. Val. 10%\n",
"0 TAIEX -2.656728 0.081830 -3.431601 -2.862093 -2.567064\n",
"1 SP500 -1.747171 0.406987 -3.431811 -2.862186 -2.567114\n",
"2 NASDAQ 0.476224 0.984132 -3.432022 -2.862279 -2.567163"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
}
]
},
{
"metadata": {
"id": "S_oP3C1ri0Id",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Partitioning\n",
"\n",
"The best number of partitions of the Universe of Discourse is an optimization problem. The know more about partitioning schemes please look on the Partitioners notebook. To know more about benchmarking look on the Benchmarks notebook."
]
},
{
"metadata": {
"id": "PiYrN-Ygi0Ig",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.partitioners import Grid, Util as pUtil\n",
"from pyFTS.benchmarks import benchmarks as bchmk\n",
"from pyFTS.models import chen\n",
"\n",
"tag = 'partitioning'\n",
"_type = 'point'\n",
"\n",
"for dataset_name in dataset_names:\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,\n",
" methods=[ismailefendi.ImprovedWeightedFTS],\n",
" benchmark_models=False,\n",
" transformations=[None],\n",
" partitions=np.arange(10,100,2), \n",
" progress=False, type=_type,\n",
" file=\"benchmarks.db\", dataset=dataset_name, tag=tag)\n",
"\n",
" bchmk.sliding_window_benchmarks(dataset, 1000, train=0.8, inc=0.2,\n",
" methods=[ismailefendi.ImprovedWeightedFTS],\n",
" benchmark_models=False,\n",
" transformations=[tdiff],\n",
" partitions=np.arange(3,30,1), \n",
" progress=False, type=_type,\n",
" file=\"benchmarks.db\", dataset=dataset_name, tag=tag)\n"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "1bL5qdoei0Ik",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.benchmarks import Util as bUtil\n",
"\n",
"df1 = bUtil.get_dataframe_from_bd(\"benchmarks.db\",\n",
" \"tag = 'partitioning' and model = 'IWFTS' and measure = 'rmse'and transformation is null\")\n",
"\n",
"df2 = bUtil.get_dataframe_from_bd(\"benchmarks.db\",\n",
" \"tag = 'partitioning' and model = 'IWFTS' and measure = 'rmse' and transformation is not null\")\n",
"\n",
"fig, ax = plt.subplots(nrows=2, ncols=1, figsize=[15,7])\n",
"\n",
"g1 = sns.boxplot(x='Partitions', y='Value', hue='Dataset', data=df1, showfliers=False, ax=ax[0], \n",
" palette=\"Set3\")\n",
"box = g1.get_position()\n",
"g1.set_position([box.x0, box.y0, box.width * 0.85, box.height]) \n",
"g1.legend(loc='right', bbox_to_anchor=(1.15, 0.5), ncol=1)\n",
"ax[0].set_title(\"Original data\")\n",
"ax[0].set_ylabel(\"RMSE\")\n",
"ax[0].set_xlabel(\"\")\n",
"\n",
"g2 = sns.boxplot(x='Partitions', y='Value', hue='Dataset', data=df2, showfliers=False, ax=ax[1], \n",
" palette=\"Set3\")\n",
"box = g2.get_position()\n",
"g2.set_position([box.x0, box.y0, box.width * 0.85, box.height]) \n",
"g2.legend(loc='right', bbox_to_anchor=(1.15, 0.5), ncol=1)\n",
"ax[1].set_title(\"Differentiated data\")\n",
"ax[1].set_ylabel(\"RMSE\")\n",
"ax[1].set_xlabel(\"Number of partitions of the UoD\")"
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "TXygoLBIi0Iu",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### Comparing the partitioning schemas"
]
},
{
"metadata": {
"id": "ER5IwllQi0Iv",
"colab_type": "code",
"colab": {},
"outputId": "c55c71ec-6c62-4659-8404-de286539f5f4"
},
"cell_type": "code",
"source": [
"from pyFTS.partitioners import Grid, Util as pUtil\n",
"\n",
"fig, ax = plt.subplots(nrows=2, ncols=3, figsize=[20,5])\n",
"\n",
"\n",
"partitioners = {}\n",
"partitioners_diff = {}\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" partitioner = Grid.GridPartitioner(data=dataset, npart=30)\n",
" partitioners[dataset_name] = partitioner\n",
" partitioner_diff = Grid.GridPartitioner(data=dataset, npart=10, transformation=tdiff)\n",
" partitioners_diff[dataset_name] = partitioner_diff\n",
"\n",
" pUtil.plot_sets(dataset, [partitioner.sets], titles=[dataset_name], axis=ax[0][count])\n",
" pUtil.plot_sets(dataset, [partitioner_diff.sets], titles=[''], axis=ax[1][count])"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIQAAAFKCAYAAABsCIRVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLC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vby8vE6tCCGfudzf4TTI+wkvLy8vtbyfYPJ+wsvLy0stVz/hkTEvLy8vLy8vLy8vLy8vLy+vq0w+\nIeTl5eXl5eXl5eXl5eXl5eV1lcknhLy8vLy8vLy8vLy8vLy8vLyuMvmEkJeXl5eXl5eXl5eXl5eX\nl9dVJp8Q8vLy8vLy8vLy8vLy8vLy8rrK5BNCXl5eXl5eXl5eXl5eXl5eXleZrAkhQsivEEKeIIR8\nTPM6IYS8mhByPyHkbwkhX3jyX9PLy8vL67TK+wkvLy8vL5O8n/Dy8vI6nXLpEHodgOcbXv9aALfn\n/74TwC889a/l5eXl5XUF6XXwfsLLy8vLS6/XwfsJLy8vr1Mna0KIUnongInhkG8A8HrK9AEA24SQ\na0/qCz4ZUUoRp5n9wCQCKDUekmYp0iy1fh6NY+vHpYn9O2VZiszl8xx+X5IkDp+XgFLze1FKEWdm\nOwFA5PD7kCZAZj4uoxnizG5PGkXWY7I0A7V8d5plyFKzzQGAOvy+NE2RWX4fpRmyzP63iSzvAwBJ\nmiGz/W2yjNndojh1sHkcg9p+X0aROZyfaeLweWkGarlGsyxD6vD3yzL7+RJn1Pp5aUaRuIwvV5Gu\nRD8BOI5ZrtdPFlvPHcBx3Mqo/boGu4Zsn+nqL1zGLvbdHL4/pUgcvn/scH0DYL7aIhdfDTD7u9gs\ndbBZlqbW8RBw8
"text/plain": [
"<matplotlib.figure.Figure at 0x7efc3695aac8>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"metadata": {
"id": "RynRlaEri0I1",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Fitting models"
]
},
{
"metadata": {
"id": "dXw-ezB8i0I3",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### With original data"
]
},
{
"metadata": {
"id": "W2FeK2mDi0I3",
"colab_type": "code",
"colab": {},
"outputId": "f85ee988-a5aa-4e1d-80d6-7c0b0d080f73"
},
"cell_type": "code",
"source": [
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" model1 = ismailefendi.ImprovedWeightedFTS(partitioner=partitioners[dataset_name])\n",
" model1.name=dataset_name\n",
" model1.fit(dataset[:train_split], save_model=True, file_path='model1'+dataset_name, order=1)\n",
"\n",
" print(model1)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"TAIEX:\n",
"A1 -> A1(0.2),A2(0.8)\n",
"A10 -> A10(0.707),A11(0.114),A12(0.008),A9(0.171)\n",
"A11 -> A10(0.129),A11(0.782),A12(0.089)\n",
"A12 -> A11(0.091),A12(0.818),A13(0.091)\n",
"A13 -> A12(0.141),A13(0.798),A14(0.061)\n",
"A14 -> A13(0.07),A14(0.86),A15(0.07)\n",
"A15 -> A14(0.114),A15(0.743),A16(0.143)\n",
"A16 -> A15(0.113),A16(0.6),A17(0.275),A18(0.013)\n",
"A17 -> A15(0.008),A16(0.165),A17(0.685),A18(0.142)\n",
"A18 -> A16(0.009),A17(0.154),A18(0.684),A19(0.154)\n",
"A19 -> A18(0.176),A19(0.686),A20(0.137)\n",
"A2 -> A1(0.308),A2(0.462),A3(0.231)\n",
"A20 -> A19(0.175),A20(0.688),A21(0.125),A22(0.013)\n",
"A21 -> A20(0.18),A21(0.639),A22(0.164),A23(0.016)\n",
"A22 -> A21(0.175),A22(0.714),A23(0.111)\n",
"A23 -> A22(0.207),A23(0.655),A24(0.138)\n",
"A24 -> A21(0.033),A22(0.033),A23(0.067),A24(0.7),A25(0.167)\n",
"A25 -> A24(0.154),A25(0.538),A26(0.308)\n",
"A26 -> A24(0.067),A25(0.467),A26(0.467)\n",
"A3 -> A2(0.176),A3(0.706),A4(0.118)\n",
"A4 -> A3(0.095),A4(0.762),A5(0.143)\n",
"A5 -> A4(0.063),A5(0.794),A6(0.143)\n",
"A6 -> A5(0.081),A6(0.831),A7(0.089)\n",
"A7 -> A6(0.074),A7(0.832),A8(0.094)\n",
"A8 -> A6(0.01),A7(0.146),A8(0.688),A9(0.156)\n",
"A9 -> A10(0.164),A8(0.131),A9(0.705)\n",
"\n",
"SP500:\n",
"A1 -> A1(0.929),A2(0.071)\n",
"A10 -> A10(0.826),A11(0.094),A9(0.08)\n",
"A11 -> A10(0.167),A11(0.764),A12(0.069)\n",
"A12 -> A11(0.068),A12(0.743),A13(0.189)\n",
"A13 -> A12(0.084),A13(0.856),A14(0.06)\n",
"A14 -> A13(0.077),A14(0.877),A15(0.046)\n",
"A15 -> A14(0.095),A15(0.81),A16(0.095)\n",
"A16 -> A15(0.067),A16(0.831),A17(0.101)\n",
"A17 -> A16(0.106),A17(0.776),A18(0.118)\n",
"A18 -> A17(0.076),A18(0.811),A19(0.114)\n",
"A19 -> A18(0.155),A19(0.742),A20(0.103)\n",
"A2 -> A1(0.014),A2(0.929),A3(0.057)\n",
"A20 -> A19(0.105),A20(0.791),A21(0.105)\n",
"A21 -> A19(0.013),A20(0.103),A21(0.833),A22(0.051)\n",
"A22 -> A21(0.121),A22(0.879)\n",
"A3 -> A2(0.02),A3(0.967),A4(0.013)\n",
"A4 -> A3(0.026),A4(0.949),A5(0.026)\n",
"A5 -> A5(0.955),A6(0.045)\n",
"A6 -> A5(0.032),A6(0.889),A7(0.079)\n",
"A7 -> A6(0.052),A7(0.844),A8(0.104)\n",
"A8 -> A7(0.066),A8(0.811),A9(0.123)\n",
"A9 -> A10(0.077),A8(0.077),A9(0.845)\n",
"\n",
"NASDAQ:\n",
"A1 -> A1(0.81),A2(0.19)\n",
"A10 -> A10(0.885),A11(0.043),A9(0.072)\n",
"A11 -> A10(0.094),A11(0.859),A12(0.047)\n",
"A12 -> A11(1.0)\n",
"A2 -> A1(0.026),A2(0.91),A3(0.064)\n",
"A3 -> A2(0.098),A3(0.863),A4(0.039)\n",
"A4 -> A3(0.044),A4(0.85),A5(0.106)\n",
"A5 -> A4(0.076),A5(0.837),A6(0.087)\n",
"A6 -> A5(0.046),A6(0.894),A7(0.06)\n",
"A7 -> A6(0.056),A7(0.912),A8(0.033)\n",
"A8 -> A7(0.052),A8(0.9),A9(0.048)\n",
"A9 -> A10(0.047),A8(0.066),A9(0.887)\n",
"\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "b4lCC4R2i0I-",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"### With transformed data"
]
},
{
"metadata": {
"id": "cgfcC9aCi0JA",
"colab_type": "code",
"colab": {},
"outputId": "5ca77cbb-00a3-4be0-a572-00b9273b79d4"
},
"cell_type": "code",
"source": [
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" model2 = ismailefendi.ImprovedWeightedFTS(partitioner=partitioners_diff[dataset_name])\n",
" model2.name=dataset_name\n",
" model2.append_transformation(tdiff)\n",
" model2.fit(dataset[:train_split], save_model=True, file_path='model2'+dataset_name, order=1)\n",
"\n",
" print(model2)"
],
"execution_count": 0,
"outputs": [
{
"output_type": "stream",
"text": [
"TAIEX:\n",
"A0 -> A4(1.0)\n",
"A1 -> A4(0.667),A5(0.333)\n",
"A2 -> A2(0.273),A3(0.091),A4(0.364),A5(0.273)\n",
"A3 -> A2(0.016),A3(0.189),A4(0.465),A5(0.299),A6(0.024),A7(0.008)\n",
"A4 -> A1(0.003),A2(0.003),A3(0.054),A4(0.471),A5(0.402),A6(0.057),A7(0.006),A8(0.003),A9(0.001)\n",
"A5 -> A0(0.001),A2(0.003),A3(0.053),A4(0.326),A5(0.502),A6(0.1),A7(0.011),A8(0.003)\n",
"A6 -> A3(0.042),A4(0.295),A5(0.47),A6(0.151),A7(0.018),A8(0.018),A9(0.006)\n",
"A7 -> A3(0.13),A4(0.174),A5(0.391),A6(0.174),A7(0.13)\n",
"A8 -> A2(0.125),A3(0.375),A5(0.375),A6(0.125)\n",
"A9 -> A1(0.5),A7(0.5)\n",
"\n",
"SP500:\n",
"A2 -> A2(0.333),A4(0.333),A5(0.333)\n",
"A3 -> A3(0.167),A4(0.361),A5(0.389),A6(0.056),A7(0.028)\n",
"A4 -> A3(0.038),A4(0.351),A5(0.517),A6(0.09),A7(0.003)\n",
"A5 -> A2(0.001),A3(0.01),A4(0.114),A5(0.683),A6(0.186),A7(0.005),A8(0.001)\n",
"A6 -> A2(0.002),A3(0.009),A4(0.067),A5(0.451),A6(0.379),A7(0.084),A8(0.007)\n",
"A7 -> A3(0.05),A4(0.167),A5(0.25),A6(0.267),A7(0.233),A8(0.017),A9(0.017)\n",
"A8 -> A6(0.6),A7(0.4)\n",
"A9 -> A6(1.0)\n",
"\n",
"NASDAQ:\n",
"A0 -> A2(0.333),A3(0.333),A6(0.333)\n",
"A1 -> A2(0.333),A5(0.333),A6(0.333)\n",
"A2 -> A0(0.022),A2(0.043),A3(0.543),A4(0.348),A5(0.043)\n",
"A3 -> A1(0.001),A2(0.013),A3(0.464),A4(0.502),A5(0.016),A6(0.003)\n",
"A4 -> A0(0.001),A1(0.001),A2(0.022),A3(0.324),A4(0.61),A5(0.038),A6(0.004),A7(0.001)\n",
"A5 -> A1(0.014),A2(0.083),A3(0.111),A4(0.583),A5(0.167),A6(0.042)\n",
"A6 -> A0(0.077),A2(0.077),A3(0.231),A4(0.231),A5(0.231),A6(0.154)\n",
"A7 -> A4(1.0)\n",
"\n"
],
"name": "stdout"
}
]
},
{
"metadata": {
"id": "EH-S7TJti0JS",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Predicting with the models"
]
},
{
"metadata": {
"id": "H7RzpFIZi0JU",
"colab_type": "code",
"colab": {},
"outputId": "d28615ae-d26e-4c99-c3f1-6031e4983fc1"
},
"cell_type": "code",
"source": [
"fig, ax = plt.subplots(nrows=3, ncols=1, figsize=[20,10])\n",
"\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
" \n",
" ax[count].plot(dataset[train_split:train_split+200])\n",
"\n",
" model1 = cUtil.load_obj('model1'+dataset_name)\n",
"\n",
" forecasts = model1.predict(dataset[train_split:train_split+200])\n",
" \n",
" ax[count].plot(forecasts)\n",
" \n",
" ax[count].set_title(dataset_name)\n",
" \n",
"plt.tight_layout()"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABZgAAALICAYAAADyhJW9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xd81dX9x/HXyQ6ZZIeEEMKeYYSN\nguKiDpy4RRy0VX/W2mq12tbWUVtH1dZRF07UOlBUVHAAigIJe+8QMoCEQPa+5/fHvUiYWTcL3s/H\n4z5y7/d7vt/z+QaS+83nnvM5xlqLiIiIiIiIiIiIiEhDebR2ACIiIiIiIiIiIiLSPinBLCIiIiIi\nIiIiIiKNogSziIiIiIiIiIiIiDSKEswiIiIiIiIiIiIi0ihKMIuIiIiIiIiIiIhIoyjBLCIiIiIi\nIiIiIiKNogSziIiIiIiIiIiIiDSKEswiIiIiIocxxhTXejiMMWW1Xl9dq931xhhrjLn8sOPHG2My\na72eZ4wpP+y8n7r2nW+M2WWMCavVfpIxJssYE9IS1ysiIiIi0lhKMIuIiIiIHMZaG3jgAWQA59fa\n9natplOAfOC6epz2ttrntdae7+rrU+Bb4F8AxphQ4Hng19baAndel4iIiIiIu3m1dgAiIiIiIu2R\nMaYLMA64DHjPGBNjrd3VyNPdDqwzxpwNXAHMt9bOclOoIiIiIiLNRglmEREREZHGuQ5Is9Z+aIxZ\nD1wNPNGYE1lr84wxvwHeBizQ131hioiIiIg0H5XIEBERERFpnOuAGa7nM6i7TMYzxpj9tR4PHrZ/\nERACzLHW5ro5VhERERGRZqEEs4iIiIhIAxljxgBdgXddm2YAA4wxg45z2O3W2tBajz8dtv9F4A3g\nF8aYUe6PWkRERETE/VQiQ0RERESk4aYABlhhjDl8+4qGnswYcyPQGTgPSANeNsYMttZWuiFWERER\nEZFmoxHMIi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FVc0OpldVxz/uGQgwf7e/Obd5fUu2SFH\npwSziIiIiIiIiIiIHJPDYXn0iw3Ehfpz7aguTTrXRYPjCO3gzasLtx+zTY3D8uKCbSTHhzAqKbxJ\n/R1LeKAvj182kE27i3n0iw3N0sfJwtQ1HL21paSk2LS0tNYOQ0RERERERERE5OTz/RMUpL1P5r5S\n4kL9Ce3QuNHLte0urCCvuIIeUUH4eB1Z+qKgrJrMfaV0DutAsJ9Xk/s7npyCcvJLKunYwQdvT4On\nhweeHubnh0dgFL5TP27WGNoqY8xSa21KXe2a919IRERERERERERE2i27+EVKSiyFPon0jQkD0/Ra\nyMEdali1JQ/v6g70DA86tD8s6/fmU+MTRN+ocLf0dzxRQZaczP1sKK2ixnHkQNyyfMMFzRpB+6cE\ns4iIiIiIiIiIiBypMBtTvIsXq65j3HV/wvSKcstp/YFPZixj/qZcFv16AgG+B1OUP2zO5dqVS/jH\nJQMwwxLc0t/xeAJDXM8rqmsoKK1iX2kV+0or2VdSiWfbLv7QJijBLCIiIiIiIiIiIkdwZC7FA6iK\nHsT4npFuPffUMV35bFUOHy7L5LpRiT9vf37eVqKDfblwcJxb+6sPXy9PooI9iQr2a/G+2zMt8ici\nIiIiIiIiIiJH2LXhR6qsJ8NHj8O4uVTFkIRQkuNDeG1hOg5XaYqVO/fz49a93Di2K75enm7tT5qP\nEswiIiIiIiIiIiJyhJJtqWymM2cMSHT7uY0xTB3TlW15JczflAvAC/O3EuznxZXDm780hriPEswi\nIiIiIiIiIiJyi
"text/plain": [
"<matplotlib.figure.Figure at 0x7efc363de828>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"metadata": {
"id": "t6YyaycEi0Jg",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.benchmarks import Measures\n",
"\n",
"rows = []\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" row = [dataset_name]\n",
" \n",
" dataset = get_dataset(dataset_name)\n",
" \n",
" test = dataset[train_split:train_split+200]\n",
"\n",
" model1 = cUtil.load_obj('model1'+dataset_name)\n",
" \n",
" row.extend(Measures.get_point_statistics(test, model1))\n",
" \n",
" rows.append(row)\n",
" \n",
" \n",
"pd.DataFrame(rows,columns=[\"Dataset\",\"RMSE\",\"SMAPE\",\"Theil's U\"])\n",
" \n",
" \n",
" "
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "k1CjPyr7i0Jl",
"colab_type": "code",
"colab": {},
"outputId": "cdb05a10-275b-415e-a0b2-28cecc9f92e3"
},
"cell_type": "code",
"source": [
"fig, ax = plt.subplots(nrows=3, ncols=1, figsize=[20,10])\n",
"\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
" \n",
" ax[count].plot(dataset[train_split:train_split+200])\n",
"\n",
" model1 = cUtil.load_obj('model2'+dataset_name)\n",
"\n",
" forecasts = model1.predict(dataset[train_split:train_split+200])\n",
" \n",
" ax[count].plot(forecasts)\n",
" \n",
" ax[count].set_title(dataset_name)\n",
" \n",
"plt.tight_layout()"
],
"execution_count": 0,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABZgAAALICAYAAADyhJW9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xd0lMUexvHvbEmDFEroVUCQXiId\nRCyAIlgRRQQboiiWK4qKvVwviAUVERRBAcGK9CpVaui911BSCCGF1J37R+K9qAghbFgCz+ecPWzm\nnXfmeYHDCb/MzhhrLSIiIiIiIiIiIiIi58rh6wAiIiIiIiIiIiIiUjCpwCwiIiIiIiIiIiIieaIC\ns4iIiIiIiIiIiIjkiQrMIiIiIiIiIiIiIpInKjCLiIiIiIiIiIiISJ6owCwiIiIiIiIiIiIieaIC\ns4iIiIiIiIiIiIjkiQrMIiIiIiJ/YYxJOuXlMcacPOXrbqf062mMscaYu/9yfxtjzMFTvp5vjEn9\ny7iTc67dYow5Yowpekr/zsaYKGNM6IV4XhERERGRvFKBWURERETkL6y1hf94AfuBW05pG3tK1x7A\nMeD+XAz7xKnjWmtvyZlrMvAb8CGAMSYM+Bx4zFqb4M3nEhERERHxNpevA4iIiIiIFETGmIrANcBd\nwARjTClr7ZE8DtcX2GyMaQd0BRZYayd5KaqIiIiISL5RgVlEREREJG/uByKttT8ZY7YA3YDBeRnI\nWhtrjHkKGAtYoKb3YoqIiIiI5B9tkSEiIiIikjf3A+Ny3o/j7NtkDDHGHD/l9dZfri8DQoFZ1toY\nL2cVEREREckXKjCLiIiIiJwjY0wLoDIwPqdpHFDHGFP/DLf1tdaGnfJ65S/XhwPfADcZY5p5P7WI\niIiIiPdpiwwRERERkXPXAzDAWmPMX9vXnutgxpiHgPJARyAS+NIY08Bam+6FrCIiIiIi+UYrmEVE\nREREzoExJgDoAvQC6p/yehK41xhzTos4jDFlgEHAI9baNGAYEAe87M3cIiIiIiL5QQVmEREREZFz\ncytwEvjGWnvkjxcwkuxPCLb/h/s+NcYknfJaldM+FBhvrV0EYK21wCPA08aYWvn7KCIiIiIi58dk\nf/8qIiIiIiIiIiIiInJutIJZRERERERERERERPJEBWYRERERERERERERyRMVmEVEREREREREREQk\nT1RgFhEREREREREREZE8cfk6wNkUL17cVqpUydcxRERERERERERERC4bq1atirXWhp+t30VfYK5U\nqRKRkZG+jiEiIiIiIiIiIiJy2TDG7MtNP22RISIiIiIiIiIiIiJ5ogKziIiIiIiIiIiIiOSJCswi\nIiIiIiIiIiIikie5KjAbY/YaYzYYY9YaYyL/cu1fxhhrjCme87Uxxgwxxuw0xqw3xjQ8pW8PY8yO\nnFcP7z6KiIiIiIiIiIiIiFxI53LI37XW2thTG4wx5YEbgf2nNHcAquW8mgCfA02MMUWB14AIwAKr\njDGTrLXx55FfRERERERERERERHzkfLfI+BB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ykzALyCQoHxLcGlQgVlERERERERE\nREROKz3Tw/uztlGjZGHqxkyGso2gZM3zGrN704oMX7ibJeFdablxFDR/Aso0gLQk7Ph7Sc/I4M3g\nAYyuV9U7D3EGL7Svwe6YZD7ccYzk9Ky/XS8R7M+KfE9RsKnALCIiIiIiIiIiIqc1fuV+9sWl8GOn\nAMyszdDxw/Mes0xYIB1ql+K57W1YGjgZM/s16D4RJj4G0Vt4PK0fHW9qicNx/gf6nU2A28noBxsD\nkJaZRUJKBvEpG
"text/plain": [
"<matplotlib.figure.Figure at 0x7efc369e48d0>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"metadata": {
"id": "V3uOr7ZJi0Ju",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
"from pyFTS.benchmarks import Measures\n",
"\n",
"rows = []\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" row = [dataset_name]\n",
" \n",
" dataset = get_dataset(dataset_name)\n",
" \n",
" test = dataset[train_split:train_split+200]\n",
"\n",
" model1 = cUtil.load_obj('model2'+dataset_name)\n",
" \n",
" row.extend(Measures.get_point_statistics(test, model1))\n",
" \n",
" rows.append(row)\n",
" \n",
" \n",
"pd.DataFrame(rows,columns=[\"Dataset\",\"RMSE\",\"SMAPE\",\"Theil's U\"])\n",
" \n",
" \n",
" "
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "Q2TFkWXvi0J2",
"colab_type": "text"
},
"cell_type": "markdown",
"source": [
"## Residual Analysis"
]
},
{
"metadata": {
"id": "qBeFl9Mei0J7",
"colab_type": "code",
"colab": {},
"outputId": "168a9184-d638-4d32-a4d5-8a97b6983f52"
},
"cell_type": "code",
"source": [
"from pyFTS.benchmarks import ResidualAnalysis as ra\n",
"\n",
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
" \n",
" model1 = cUtil.load_obj('model1'+dataset_name)\n",
" model1 = cUtil.load_obj('model2'+dataset_name)\n",
"\n",
" ra.plot_resid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mhXasgqa5vM7CWioGZhGJ7YE/gqMJdoptazwD9CGWb2OCERkuhD7s90/gd7AVFew5vAb4Cr\nzOyBHK8xyXfD6/2TpI1E79NRmZXCsNhniD5A1gIfCo/L9brij3+ZKFHz+0Q/j/cQTaveUWR7G15P\n/z0pURNRoPImsIYoCPvXcOwh4HlguaRVoezTRLlMC4G/EQ2D3RyO/YToPXgGeJKoV6aVKEDsIt+1\nXSkKyTzOOeeccyUJPTM3mNneeStXkffkOOecc64oitYMOkNSi6QxRMNvv6l1uzJ5kOOcc66sJN2s\naEG352JlwyXNljQ/fB8WyiXpe4oWWnxGsXVTJE0L9edL6s7MOld+Ihq+W0s0XPUinUODdcOHq5xz\nzpWVpOOJ8ltuNbODQtk3iabjX6doivYwM/uipDOIcj/OIMpT+q6ZHRWSc+cCU4kSb+cBh5vZ2hq8\nJNegvCfHOedcWZnZX4gSW+POAW4Jt2+hc4Xcc4iCITOzOURrx+xBtFjjbDNbEwKb2UQrNTtXsF16\n47iRI0fa+PHja90MV2bz5s1bZWaj8tfcdfi13nM10PU+2syWhdvL6VwIcQzpi8YtCWXZynPya73n\nKuVa36WDnPHjxzN37txaN8OVmaSCVyHdVfi13nM14vVuZiapbLkSkqYTbbHAuHHj/FrvoUq51n24\nyjnnXDW8FYahCN9XhPKlpK+WOzaUZSvvwsxuNLOpZjZ11KhG6NRy1eJBjnPOuWqYRedCjtOINsRM\nlV8YZlkdDawPw1r3A6eE1YWHEa2Oe3+1G+0a2y49XOWcc678JN1OtEnmSElLiNZQuQ6YKekiolWD\nzwvV7yOaWbWAaO+njwGY2RpJXwGeCPWuMbPMZGbncvIgxznnXFmZ2QVZDnXZ9NKidUwuyXKem+nc\nRsC5ovlwlXPOO
"text/plain": [
"<matplotlib.figure.Figure at 0x7f1145edefd0>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAI4CAYAAABndZP2AAAABHNCSVQICAgIfAh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gFriRKwT4Zj9wLzgBWS1oSyi4n6Li0CHiJq+ro+HLuW6DV4BniSqDammSg57KS767tYFDrvOOec\nc87lLdTIXG1m+3Z7cgl5DY5zzjnncqZoTqDTJdVLGk3U5PbHpONK5zU4zjnnnMuZpP5EzbkHEfUt\nupOoKW1jooGl8QTHOeecc1XHm6icc845V3WqfjG44cOH29ixY5MOw5XY448/vsbMRnR/ZnXx6702\n+fXuakmu13vVJzhjx45l7ty5SYfhSkxSzrOMVhO/3muTX++uluR6vXsTlXPOOeeqjic4zjnnnKs6\nJUlwJF0vaZWk52Jlh4eFt56SNFfSUaFckn4qaaGkZxRbTl3SNEkLwk9vFt9zzjnnXBUrVQ3ODcCU\ntLLvA183s8OJptP+fig/jWjq7AlEy9H/AiC2fsfRwFHA5ZJ2L3rkzjnnnKs4JUlwzOxBorUvOhQD\nu4XtwbSv7jsVuMkic4iWlN8LOBWYZWZrzWwd0YJ86UmTc84551yio6g+C9wt6YdEidZxoXw0sDh2\n3pJQlq28E0nTiWp/2Gef9BXtnXPOOVftkuxk/Engc2a2N/A54LpC3bGZXWNmk8xs0ogRNTc1hKsQ\nmfqmpR3P2h/NOedc15JMcKYBd4Tt/yXqVwOwFNg7dt6YUJat3LlKdQNdN7Nm7I/mnHOue0kmOMuA\n48P2icCCsD0TODd8ez0G2GBmy4G7gVMk7R46F58SylyNumf+Sk784f0sXrs16VB6JEvftLhs/dGc\nc851oyR9cCTdD
"text/plain": [
"<matplotlib.figure.Figure at 0x7f11461d7dd8>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAI4CAYAAABndZP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xl8XFX9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CnWZm5WY2kuiS299yHVeMWnBERESk08ysN9Fl3UOI+hbdT3QpbXNOAwuU4IiIiEjR0SUqERER\nKTpFPxnckCFDvLq6OtdhSIbNnz9/rbsP7bhmadB5Xxp03relc7/4pXveF32CU11dzbx583IdhmSY\nmaU9mmgp0HlfGnTet6Vzv/ile97rEpWIiIgUHSU4IiIiUnSU4IiIiEjRUYIjIiIiRUcJjoiIiBQd\nJTgiIiJSdJTgiOSYmd1uZmvM7JUU283MbjazWjN7ycyOzHaMIiKFRgmOSO79Djilne2nAmPDzxTg\nlizEJCJS0JTgSF6pXbOFLTt3J9321OJ1nD/taRoam7IcVWa5++PA+naqTALu9MjTwEAzG56d6ERE\nClPRj2QsheXEGx7nXcP7869LP9xm21fufYFVm3eyessuRg7slYPocmYksCxufXkoWxlfycymELXw\nMHr06KwF1xkTJkwAYM6cOR2W53NdEYDqqfenXXfpdadnMBJJRi04kndeW7k5afmwAT0B6NdTeXky\n7j7N3WvcvWbo0LbTtEyYMKH5A7u9ss6Wd3YfxWBPX4fuqCsi7VOCI3nD3dvd/uKyjQD071mRjXDy\nyQpg37j1UaFMR
"text/plain": [
"<matplotlib.figure.Figure at 0x7f1145991940>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"metadata": {
"id": "vw90oLSBi0KA",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
},
{
"metadata": {
"id": "6H8SSa5Ri0KD",
"colab_type": "code",
"colab": {}
},
"cell_type": "code",
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}