pyFTSex/tutorial/pyFTS/developer/Cheng - TrendWeightedFTS.ipynb

1068 lines
736 KiB
Plaintext
Raw Normal View History

2024-08-15 12:15:32 +04:00
{
"nbformat": 4,
"nbformat_minor": 0,
"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.6.3"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": true
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
},
"colab": {
"name": "Cheng - TrendWeightedFTS.ipynb",
"provenance": [],
"include_colab_link": true
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/PYFTS/notebooks/blob/master/Cheng%20-%20TrendWeightedFTS.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "MlD52EhraLen",
"colab_type": "text"
},
"source": [
"# Trend Weighted Fuzzy Time Series by Cheng, Chen and Wu (2009)\n",
"\n",
"C.-H. Cheng, Y.-S. Chen, and Y.-L. Wu, “Forecasting innovation diffusion of products using trend-weighted fuzzy time-series model,” \n",
"Expert Syst. Appl., vol. 36, no. 2, pp. 18261832, 2009."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "eD3INDn2aLev",
"colab_type": "text"
},
"source": [
"## Environment Setup"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "yCH4DKhSaLez",
"colab_type": "text"
},
"source": [
"### Library install/update"
]
},
{
"cell_type": "code",
"metadata": {
"id": "iQG1IaIEaLe3",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 211
},
"outputId": "9495c610-b91a-441b-f262-ef4b22a43808"
},
"source": [
"!pip3 install -U git+https://github.com/PYFTS/pyFTS"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Collecting git+https://github.com/PYFTS/pyFTS\n",
" Cloning https://github.com/PYFTS/pyFTS to /tmp/pip-req-build-gnxa9jyh\n",
" Running command git clone -q https://github.com/PYFTS/pyFTS /tmp/pip-req-build-gnxa9jyh\n",
"Building wheels for collected packages: pyFTS\n",
" Building wheel for pyFTS (setup.py) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for pyFTS: filename=pyFTS-1.6-cp36-none-any.whl size=197025 sha256=8b66da66f433712d5c383b263b25ba70a8ed0f21447bbfa4910f327a57311074\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-6yizw1gx/wheels/e7/32/a9/230470113df5a73242a5a6d05671cb646db97abf14bbce2644\n",
"Successfully built pyFTS\n",
"Installing collected packages: pyFTS\n",
"Successfully installed pyFTS-1.6\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ojhK_4hPaLfE",
"colab_type": "text"
},
"source": [
"### External libraries import"
]
},
{
"cell_type": "code",
"metadata": {
"id": "XDYBqSKoaLfH",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "5d8f1683-f3d9-42fa-c42b-3fe4738864b5"
},
"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": 6,
"outputs": [
{
"output_type": "stream",
"text": [
"Populating the interactive namespace from numpy and matplotlib\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "LfQjfxheaLfO",
"colab_type": "text"
},
"source": [
"### Common pyFTS imports "
]
},
{
"cell_type": "code",
"metadata": {
"id": "HJlbJ-CGaLfP",
"colab_type": "code",
"colab": {}
},
"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 cheng\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "Qim33pXQaLfV",
"colab_type": "text"
},
"source": [
"## Common data transformations"
]
},
{
"cell_type": "code",
"metadata": {
"id": "fxA_4i4gaLfX",
"colab_type": "code",
"colab": {}
},
"source": [
"from pyFTS.common import Transformations\n",
"\n",
"tdiff = Transformations.Differential(1)\n",
"\n",
"boxcox = Transformations.BoxCox(0)"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "1fzMnkb9aLfe",
"colab_type": "text"
},
"source": [
"## Datasets"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "hzVKwoAdaLfh",
"colab_type": "text"
},
"source": [
"### Data Loading"
]
},
{
"cell_type": "code",
"metadata": {
"id": "jSGmlkhDaLfi",
"colab_type": "code",
"colab": {}
},
"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": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "nU7HTU-qaLfp",
"colab_type": "text"
},
"source": [
"### Visualization"
]
},
{
"cell_type": "code",
"metadata": {
"id": "flCVsUxdaLfq",
"colab_type": "code",
"colab": {},
"outputId": "99d071c7-295d-4267-fd19-73b41cc64078"
},
"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/Etn8Q0REiqi3tP5yIDhJRjYr4vgqFPxBRLyJaSkS5\nRHSCiP4mogvFfVAm/q5PE9F6IrpCHJMq7hH5b/9Z6Z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vTxb1ljOYCaQhdqEIDZzHyC\nmU8CmA1gsKwZJbwG30rnshxxtuCdfXbpP9JyLkOFQqHwA2bGij3a66Bzs5p+HSM6cmwSHThWi7Gw\nRWUUivJg7raj+EZyqmw+mIu/M3IAAJe/t8hl31MFmnd5YNv65XItweao1RdJzwBwBIB+dY0B7Jf2\n0zWgvI0HpBlFRKuJaHV2dvDerWAJwU6DbHCr+ai1eX36NkxcsifSl6FQWI4pq/djxGfLAQA3Xdgs\nkEP7iTB/N7Eez
"text/plain": [
"<matplotlib.figure.Figure at 0x7fdb3b6d4eb8>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ziev89ZoaLfv",
"colab_type": "text"
},
"source": [
"### Statistics"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Ds8pkjy9aLfw",
"colab_type": "code",
"colab": {},
"outputId": "4400eda8-cf84-4262-e273-5b742861321a"
},
"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
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "YrAsqYvIaLf2",
"colab_type": "text"
},
"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."
]
},
{
"cell_type": "code",
"metadata": {
"id": "QLhm0lrlaLf4",
"colab_type": "code",
"colab": {}
},
"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 = 'cheng_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=[cheng.TrendWeightedFTS],\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=[cheng.TrendWeightedFTS],\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": []
},
{
"cell_type": "code",
"metadata": {
"id": "S5YAHPOQaLf9",
"colab_type": "code",
"colab": {}
},
"source": [
"from pyFTS.benchmarks import Util as bUtil\n",
"\n",
"df1 = bUtil.get_dataframe_from_bd(\"benchmarks.db\",\n",
" \"tag = 'cheng_partitioning' and measure = 'rmse'and transformation is null\")\n",
"\n",
"df2 = bUtil.get_dataframe_from_bd(\"benchmarks.db\",\n",
" \"tag = 'cheng_partitioning' 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": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "aq9WQjbCaLgB",
"colab_type": "text"
},
"source": [
"### Comparing the partitioning schemas"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Bhc6kikTaLgD",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 367
},
"outputId": "0243d8fc-ef71-484b-b2b8-a11303a76814"
},
"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": 8,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABIQAAAFKCAYAAABsCIRVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzsvXm8ZMlV3/mLzLw317dlv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q0w+\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": [
"<Figure size 1440x360 with 6 Axes>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "6Hnk7-VSaLgI",
"colab_type": "text"
},
"source": [
"## Fitting models"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "GUWKh7mFaLgK",
"colab_type": "text"
},
"source": [
"### With original data"
]
},
{
"cell_type": "code",
"metadata": {
"id": "rtCsD04xaLgL",
"colab_type": "code",
"colab": {}
},
"source": [
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" model1 = cheng.TrendWeightedFTS(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"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "RTIB8ZCMaLgP",
"colab_type": "text"
},
"source": [
"### With transformed data"
]
},
{
"cell_type": "code",
"metadata": {
"id": "4XleptoCaLgQ",
"colab_type": "code",
"colab": {}
},
"source": [
"for count,dataset_name in enumerate(dataset_names):\n",
" dataset = get_dataset(dataset_name)\n",
"\n",
" model2 = cheng.TrendWeightedFTS(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"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "1hyAaSmraLgW",
"colab_type": "text"
},
"source": [
"## Predicting with the models"
]
},
{
"cell_type": "code",
"metadata": {
"id": "M8bWiw5ZaLgX",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 749
},
"outputId": "7b3b4396-56e9-4a29-a022-895246047227"
},
"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": 11,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABZgAAALICAYAAADyhJW9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFU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wEqP/iz1HcEdY7rhjlLIB0oreebrTYzoGs6EPtFHrLPASwu2UlHl4O5zE9xyvJOprLbM\nXJ5J5r5iyquPnYjrVRrEo00bQqunBLOIiIiIiIiIiIgcK38rpqKQ9yuHc+HVv8ajR6RbdhsG5Gel\ncP+mPM6+bhyBvodTlIs25/H3fcv52xX98BjS0S3HOxlvYMpZzuflVdUUlFSyv6SS/SUV7C+uwNGy\niz+0CEowi4iIiIiIiIiIyDEcWSl4ADZ6AGO6R7h131NHduaz1Tl8lLKLm86K/2n5S/O3EhXiy2UD\n49x6vLrw9fIkMsSTyBC/U37s1syjuQMQERERERERERGRlmfPxqWUWW9GjRiJMe6tVTGoYxiJ7UOZ\nvjgDh2ua8KqdB/hx6z5uHdUZXy9Ptx5Pmo4SzCIiIiIiIiIiInKM0h0rWU9nzu/b3u37NsYwdWRn\ntu0tZsGmPABeXrCVED8vrh3a9KUxxH2UYBYREREREREREZEjlFdUEFW8gcK2fY+okexOF/aLITLY\nlzcWb2dbXhFfr
"text/plain": [
"<Figure size 1440x720 with 3 Axes>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "7aDQjrFOaLgb",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"outputId": "3b9aec08-e67c-49c9-fc1e-e4cabbf8d678"
},
"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"
],
"execution_count": 12,
"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>RMSE</th>\n",
" <th>SMAPE</th>\n",
" <th>Theil's U</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>TAIEX</td>\n",
" <td>94.31</td>\n",
" <td>1.62</td>\n",
" <td>1.43</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>SP500</td>\n",
" <td>14.90</td>\n",
" <td>1.17</td>\n",
" <td>2.68</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>NASDAQ</td>\n",
" <td>48.54</td>\n",
" <td>2.37</td>\n",
" <td>2.03</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dataset RMSE SMAPE Theil's U\n",
"0 TAIEX 94.31 1.62 1.43\n",
"1 SP500 14.90 1.17 2.68\n",
"2 NASDAQ 48.54 2.37 2.03"
]
},
"metadata": {
"tags": []
},
"execution_count": 12
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "0_eJ9WQAaLgg",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 749
},
"outputId": "bbed10a8-6e18-4f3f-a715-ba761d93a18b"
},
"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": 13,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAABZgAAALICAYAAADyhJW9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzs3Xd4lMXexvHvbHognRpaQi8iLRSl\nS5EmCCiCFRs2EMR2fPUU9di72MAOgqA06U2a0hM6SO+hphBCerLz/kHOOaggSdiwCbk/17UXu88z\nz8z9SHHz29kZY61FRERERERERERERCS/HO4OICIiIiIiIiIiIiLFkwrMIiIiIiIiIiIiIlIgKjCL\niIiIiIiIiIiISIGowCwiIiIiIiIiIiIiBaICs4iIiIiIiIiIiIgUiArMIiIiIiIiIiIiIlIgKjCL\niIiIiIiIiIiISIGowCwiIiIi8gfGmLPnPZzGmLTzXt9xXrvBxhhrjLntD9d3MMYcOe/1UmNM+h/6\nnZl77iZjzHFjTOh57fsYY2KNMUFX4n5FRERERApKBWYRERERkT+w1pb+zwM4BNx03rHx5zW9B0gA\n7s5Dt0PP79dae1PuWDOBxcB7AMaYYOBT4BFrbZIr70tERERExNU83R1ARERERKQ4MsZUA9oDtwKT\njDEVrLXHC9jd48B2Y8yNwEBgmbV2houiioiIiIgUGhWYRUREREQK5m4g2lo7xRjzG3AH8E5BOrLW\nxhljhgPjAQvUd11MEREREZHCoyUyREREREQK5m5gQu7zCVx6mYwPjTGnz3u8/Ifzq4EgYIG19pSL\ns4qIiIiIFAoVmEVERERE8skY0xqIBCbmHpoANDTGNP6Lyx631gaf9/j7H86PAcYCPYwx17k+tYiI\niIiI62mJDBERERGR/LsHMMBGY8wfj2/Mb2fGmPuBKkAvIBr4whjTxFqb6YKsIiIiIiKFRjOYRURE\nRETywRjjCwwAhgCNz3sMA243xuRrEocxJhx4C3jQWpsBfAbEA8+7MreIiIiISGFQgVlEREREJH9u\nBtKAsdba4/95AF9x7huC3S5y3UfGmLPnPWJyj38CTLTW/gJgrbXAg8AIY0yDwr0VEREREZHLY869\nfxURERERERERERERyR/NYBYRERERERERERGRAlGBWUREREREREREREQKRAVmERERERERERERESkQ\nFZhFREREREREREREpEA83R3gUsqUKWMjIiLcHUNERERERERERESkxIiJiYmz1pa9VLsiX2COiIgg\nOjra3TFERERERERERERESgxjzMG8tNMSGSIiIiIiIiIiIiJSICowi4iIiIiIiIiIiEiBqMAsIiIi\nIiIiIiIiIgWSpwKzMeaAMWaLMWajMSb6D+eeNMZYY0yZ3NfGGPOhMWaPMWazMabpeW3vMcbszn3c\n49pbEREREREREREREZErKT+b/HW01sadf8AYUwXoChw673B3oFbuoyXwKdDSGBMK/BOIAiwQY4yZ\nYa1NvIz8IiIiIiIiIiIiIuIml7tExnvAM5wrGP9HH2CsPWc1EGyMqQjcCCy01ibkFpUXAt0uc3wR\nERERERERERERcZO8FpgtsMAYE2OMGQJgjOkDxFprN/2hbSXg8Hmvj+Qeu9jxPzHGDDHGRBtjok+d\nOpXHiCIiIiIiIiIiIlJS5TgtP69YzfTpPxCXnO7uOCVGXpfIaGOtjTXGlAMWGmN2AP/HueUxXM5a\nOwYYAxAVFWUv0VxERERERERERERKqOwcJ0tX/IJd/g43ZC3Hw1hiNrzNzPpP07PHTZQL8HV3xKta\nngrM1trY3F9PGmOmAe2BSGCTMQagMrDeGNMCiAWqnHd55dxjsUCHPxxfennxRURERERERERExB0O\nxadyJDGVY4lniUtIIDExgaQziaSkZdCq5fUMbBGJw2EKbfysHCc/L1uK14p3uCF7BZnGm4O176V0\nhRrUWvkOzX57gFnbrmfvtSMZ2LUt5QNVaC4Mxtq/niBsjCkFOKy1ybnPFwIvWWvnndfmABBlrY0z\nxvQEhgI9OLfJ34fW2ha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eSvT7H1SKJr+i3BVGAWERERERERERGRi1v8EiY2hqcyHqB/pzYE+HoVqBsTVInY8BvpnL6A\nNTsO/mXblfO/pyaHyWz5GBhToPEumqNsHbK7vEIbxxaWj32J1Mxsl/Zf0qjALCIiIiIiIiIiIhe2\nawGsHMVs7+5sDe7AHa2qXlZ3Fbo+QaBJY9/CMRdtk5XjJHjjZ8Q7wqjeIW9rPeeX/3UPEF+5M/dn\njOWLH2cUyhglhae7A4iIiIiIiIiIiEgRteifnAmowchTt/HmwDr4eHpcVnc+ES04GtCQ6+Mnc+DU\nc0SUDfhTm1+XL6Kjcyu7rn2WME+fyxrvoowhbNAYkt9vQY+dz/PM9+GEhQQT4u9FsL83If7ehJby\nIrSUD5FlShVOhquECswiIiIiIiIiIiLyZwn74eR2vvG8l9qVynLTteEu6bZUu2GEzx7ChLkTiLj7\nod+ds9ZiVn5ICv7U7P6YS8a7eJAwfG/9nJoT+vLqzh6ctqVItAEkUprTtjS7bQBnfMoz5O8Xn20t\nKjCLiIiIiIiIiIjIheyaB8DklGt5bWBdHA7XrIUc1LQ/ifNfoPresZxJv4/A89Z0XhWznraZv7K3\n5mBq+wW5ZLy/4lX7Brj9BzwPrSYsNYGglHiqnI3HpibgSD9MtuehQs9Q3KnALCIiIiIiIiIiIn9i\nd87lgKlMlRr1aV2zjOs69vAkvcn9tFr3GlMX/0y/Ht3+e+r04g+wxkFkryddN96l1L4Rat+IAbxy\nH/9RSAt0XFW0yZ+IiIiIiIiIiIj8XnoS9sAK5mc1YWDzy9vY70IqdhxCOj54x4whx2kBWL9zHx1S\n5nGgYne8Qqq4f
"text/plain": [
"<Figure size 1440x720 with 3 Axes>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "kEojM8cnaLgk",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 143
},
"outputId": "707b3ea5-ba55-4147-a33d-26c8719bc5bd"
},
"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": 14,
"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>RMSE</th>\n",
" <th>SMAPE</th>\n",
" <th>Theil's U</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>TAIEX</td>\n",
" <td>65.69</td>\n",
" <td>1.13</td>\n",
" <td>1.00</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>SP500</td>\n",
" <td>5.19</td>\n",
" <td>0.37</td>\n",
" <td>0.94</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>NASDAQ</td>\n",
" <td>24.52</td>\n",
" <td>1.17</td>\n",
" <td>1.02</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Dataset RMSE SMAPE Theil's U\n",
"0 TAIEX 65.69 1.13 1.00\n",
"1 SP500 5.19 0.37 0.94\n",
"2 NASDAQ 24.52 1.17 1.02"
]
},
"metadata": {
"tags": []
},
"execution_count": 14
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "RC6t9ZKJaLgq",
"colab_type": "text"
},
"source": [
"## Residual Analysis"
]
},
{
"cell_type": "code",
"metadata": {
"id": "HErrYknJaLgs",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"outputId": "e37704bf-aac4-4b97-fbb1-1b7667660939"
},
"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_residuals_by_model(dataset, [model1, model2])"
],
"execution_count": 16,
"outputs": [
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAI4CAYAAACGHoanAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzs3XecVNX5x/HPl6aiKCCISFuiWLAb\nYvmliCWKWEg1GozYQBFjTWwYxUI0MdaoRIhGjWtLjEoUo4g9EQUVGzZEUVGK0kRU2vP7456Fu7NT\ntszMndl53q/XvHbuuXfufXbn7txnzjn3HJkZzjnnnHOVqEXSATjnnHPOJcUTIeecc85VLE+EnHPO\nOVexPBFyzjnnXMXyRMg555xzFcsTIeecc85VLE+EikjSG5L6Z1jXX9LHeTrOk5KOy8e+XPMg6QNJ\n+zbytd+X9Ha+Y3J1ZfuMcA5A0ihJtzfytUdJejbL+oclDUm3raSlkr7VmOM2MMaiX788EcogXDi+\nCm/+HEm3SNqgKfs0s23N7Mk8hejyKPzzLZS0TgNeY5K2KGRcSUj9vczsGTPbKsmYmot0CWn8glOf\nzwhJVeE9alXAUF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WbmU0FhobYFxKdn0dl2Pw3wC+J+r+NA1LvJKz1e6UcZ3n4\nHQ4gOv9uAI40s7caEq+rlwHAG+F/9xrgMDP7KjRtjQb+G96j3Yk6yv+dqJn8feBrwpcrM3sjPL+L\n6LxcCswjunhmkusccYV1OFEfmE+A+4ALwudLjQeAXxD9r/8K+ImZrTCz6UT9s54j+tzaHvhvyr6f\nJ7pOfUZ0Hv3Mz
"text/plain": [
"<Figure size 576x576 with 8 Axes>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkAAAAI4CAYAAACC61aaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzs3XmYFNXZ9/HvDxAQQQFBXBFU1KCP\nohI1iQvuiEbUJAribkRFEpe8MRjcHpTE+Ji4xCViNGIc95VEXBDFJXFDJS6oAREUBEQBEVHW+/2j\nTkNNT/f0DNPd1cv9ua6+puvU0vdM13Tdfc6pc2RmOOecc85Vk2ZJB+Ccc845V2yeADnnnHOu6ngC\n5Jxzzrmq4wmQc84556qOJ0DOOeecqzqeADnnnHOu6ngCVCCS3pPUJ8u6PpJm5ul1Jkj6eT6O5SqL\npOmSDlzLffeW9GG+Y3J11fdZ4VycpMsk3bWW+54s6aV61j8h6aRM20paLGmrtXndRsZY1OuZJ0Cs\nvlB8G97kOZLukNS2Kcc0sx3MbEKeQnQFEP7ZFkhq1Yh9TNI2hYwrCem/l5m9aGbbJRlTpciUiMYv\nMA35rJDULbxHLQoYqiuAtOvL3HxcXwrBzA41s9FZ1rU1s2kAIf4r1vZ18vH3yNf/gydAa/zYzNoC\nvYBdgAsTjscVkKRuwN6AAUckGkwOmf7J/ULo8snPp4JLXV92BXoDF6VvoEi1XJNz/j2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vV2b2Xnh+\nL9F5uRj4nOhimU2uc8QVx0CiPi6fAY8Al4bPmZTHgGOJ/udPAI42s+VmNpmoH9bLRJ9f/wP8K+3Y\nrxJdt74gOp9+a
"text/plain": [
"<Figure size 576x576 with 8 Axes>"
]
},
"metadata": {
"tags": []
}
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkIAAAI4CAYAAACGHoanAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzs3Xe8FNX5x/HPFxAURRBBg3QVNVhj\nsEWNKAYQNagxikHFEontF40mRsVEY0RNsyQRI0aiRhSxE0ssqLHEBnZQIza6gEgTG/D8/pizMHfv\n7t17L7s7e3ee9+u1r7tzZmbn7O7cOc+eOUVmhnPOOedcGjVLOgPOOeecc0nxQMg555xzqeWBkHPO\nOedSywMh55xzzqWWB0LOOeecSy0PhJxzzjmXWh4IlZGkKZL65lnXV9LMIh3nSUk/LsZrueog6UNJ\n+zdy370lvVPsPLna6rpGOAcg6SJJtzRy3+MkPVPH+ockDcu1raRlkjZvzHEbmMeyl18eCOURCo7P\nw5c/V9KNkjZYm9c0s23N7MkiZdEVUfjn+1RSqwbsY5K2LGW+kpD9vszsaTPbOsk8VYtcAWm8wKnP\nNUJSj/AdtShhVl0RZZUnHxejPCkFMzvAzG7Ks24DM3sfIOT/ksYepxifRzH/DzwQqtvBZrYBsBPw\nLeC8hPPjSkBSD2BvwIDvJ5qZAnL903uB6IrJz6eSyZQnOwN9gAuyN1AkLeVywc+jXNLyga8VM5sL\nPEwUECGplaQ/Spoeotm/SVovrOsg6X5JiyQtlPR05sSO/xqUtF6Igj+VNBXYJX7M7F/l8Qhc0kbh\nGPPD/vdL6pIr75K2lPQfSYslLZB0ewk+oqbuWOB54E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adata": {
"id": "kHyf4scQaLgv",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "kUN1rHtJaLg0",
"colab_type": "code",
"colab": {}
},
"source": [
""
],
"execution_count": 0,
"outputs": []
}
]
}