607 lines
1.3 MiB
Plaintext
607 lines
1.3 MiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Multivariate FTS "
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# TAIEX Experiments"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Data loading"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Populating the interactive namespace from numpy and matplotlib\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py:161: UserWarning: pylab import has clobbered these variables: ['plt']\n",
|
||
|
"`%matplotlib` prevents importing * from pylab and numpy\n",
|
||
|
" \"\\n`%matplotlib` prevents importing * from pylab and numpy\"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pylab as plt\n",
|
||
|
"from pyFTS.data import TAIEX as tx\n",
|
||
|
"\n",
|
||
|
"%pylab inline"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df = tx.get_dataframe()\n",
|
||
|
"df = df.dropna()\n",
|
||
|
"\n",
|
||
|
"train = df.iloc[2000:2500]\n",
|
||
|
"test = df.iloc[2500:3000]"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Variable, partitioning and model definitions"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABCwAAALICAYAAAC0F2E+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xd4VNX28PHvmbRJ7wkJKYQECEkg\nCV0sSEcUEZTeq9iu2PsV7FevXUF6rwICioCooIB0kpBAaCEhvfc+mdnvH8Hfy1UQkkwyk8n+PI8P\nMjPnnMU80/baa6+tCCGQJEmSJEmSJEmSJEkyJipDByBJkiRJkiRJkiRJkvRXMmEhSZIkSZIkSZIk\nSZLRkQkLSZIkSZIkSZIkSZKMjkxYSJIkSZIkSZIkSZJkdGTCQpIkSZIkSZIkSZIkoyMTFpIkSZIk\nSZIkSZIkGR2ZsJAkSZIkqVlTFGW3oihTbnJfG0VRhKIo5k0dlyRJkiRJDSMTFpIkSZLUgimKMlVR\nlFhFUcoVRclUFGWhoihOBopFURTlSUVRzlwXzwFFUcb+03FCiPuEEKuaKk5JkiRJkpqGTFhIkiRJ\nUgulKMpzwH+AFwBHoBfgD+xTFMXSACF9AcwFngNcgdbA68CQGz34WoJD/paRJEmSJBMlv+QlSZIk\nqQVSFMUBmA88JYTYI4TQCCGSgNFAG2DitcfNUxRli6IomxRFKVEU5bSiKOHXncdbUZStiqLkKIqS\nqCjKv667b56iKJsVRVl97diziqJ0u0k87YHHgbFCiH1CiAohhFYIcUgIMfW6xx1QFOVdRVEOA+VA\n22u3zbx2v5miKP9VFCVXUZQrwP16feIkSZIkSWoyMmEhS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
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from pyFTS.partitioners import Grid, Util as pUtil\n",
|
||
|
"from pyFTS.common import Transformations\n",
|
||
|
"from pyFTS.models.multivariate import common, variable, mvfts\n",
|
||
|
"\n",
|
||
|
"bc = Transformations.BoxCox(0)\n",
|
||
|
"diff = Transformations.Differential(1)\n",
|
||
|
"\n",
|
||
|
"np = 10\n",
|
||
|
"\n",
|
||
|
"model = mvfts.MVFTS(\"\")\n",
|
||
|
"\n",
|
||
|
"fig, axes = plt.subplots(nrows=5, ncols=1,figsize=[15,10])\n",
|
||
|
"\n",
|
||
|
"vopen = variable.Variable(\"Open\", data_label=\"Openly\", partitioner=Grid.GridPartitioner, npart=np, data=train,\n",
|
||
|
" transformation=diff)\n",
|
||
|
"model.append_variable(vopen)\n",
|
||
|
"vopen.partitioner.plot(axes[0])\n",
|
||
|
"vhigh = variable.Variable(\"High\", data_label=\"Highest\", partitioner=Grid.GridPartitioner, npart=np, data=train,\n",
|
||
|
" transformation=diff)\n",
|
||
|
"model.append_variable(vhigh)\n",
|
||
|
"vhigh.partitioner.plot(axes[1])\n",
|
||
|
"vlow = variable.Variable(\"Low\", data_label=\"Lowermost\", partitioner=Grid.GridPartitioner, npart=np, data=train,\n",
|
||
|
" transformation=diff)\n",
|
||
|
"model.append_variable(vlow)\n",
|
||
|
"vlow.partitioner.plot(axes[2])\n",
|
||
|
"vclose = variable.Variable(\"Close\", data_label=\"Close\", partitioner=Grid.GridPartitioner, npart=np, data=train,\n",
|
||
|
" transformation=diff)\n",
|
||
|
"model.append_variable(vclose)\n",
|
||
|
"vclose.partitioner.plot(axes[3])\n",
|
||
|
"vvol = variable.Variable(\"Volume\", data_label=\"Volume\", partitioner=Grid.GridPartitioner, npart=40, data=train,\n",
|
||
|
" transformation=diff)#train)\n",
|
||
|
"model.append_variable(vvol)\n",
|
||
|
"vvol.partitioner.plot(axes[4])\n",
|
||
|
"\n",
|
||
|
"model.target_variable = vvol\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3kAAAJJCAYAAAAX/f7MAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzsvXm0JdlV3vnFHd6YmTVrAGGVAAGW\nm2HZMmDANLZ7uSVoQ2O6aaCX3XTDwm5ks4wRk22Gli2jBhqQrAEECEkghEojkkAlVINUs6SsIbMq\ns7JyHl4OL1/mm9+dIuKc/iNin9gn7om4N+6NO73av7Vq5at374t7bgznnL33t/f2tNYQBEEQBEEQ\nBEEQ9geVSQ9AEARBEARBEARBKA8x8gRBEARBEARBEPYRYuQJgiAIgiAIgiDsI8TIEwRBEARBEARB\n2EeIkScIgiAIgiAIgrCPECNPEARBEARBEARhHzFTRp7nee/xPO+653nP9fHeV3qed7/neUc9z/u8\n53mvGMcYBUEQBEEQBEEQJslMGXkA3gvgdX2+97cBvF9r/U0A3gTgN0Y1KEEQBEEQBEEQhGlhpow8\nrfVDANb57zzP+xrP8+71PO9Jz/Me9jzvG+KXXgPggfjnBwH8wBiHKgiCIAiCIAiCMBFmysjL4N0A\n/q3W+u8BeCOAd8a/PwLgn8c//yCAg57n3TGB8QmCIAiCIAiCIIyN2qQHMAye5x0A8B0APux5Hv16\nPv73jQDe7nnejwN4CMBlAOG4xygIgiAIgiAIgjBOZtrIQxSJ3NRaf0v6Ba31FcSRvNgY/CGt9eaY\nxycIgiAIgiAIgjBWZlquqbXeBnDO87z/FQC8iG+Of77T8zz6f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zHyJsDMyTXZOIMpGbNE8gRBEARBmAaMXDMnkqdH5ODXU9biSpgexMib\nAKbC0ow8k3xCmpZInjLSCDHyBEEQBEGYHKHqvScZVSRP6dkJGgjjRYy8CUAP47QYTL3gw5ScPEEQ\nBEEQhISwD8fzqHLylETyhAxKN/I8z3uP53nXPc97LuN1z/O8t3med9rzvKOe5/3dsscw7YQzVkZX\nT3F1TTHyBEEQBEGYJEl1zT4Kr5S891NaGqwLbkYRyXsvgNflvP56AK+O//spAO8awRimGj0ib86o\n4OOcljEbIy+YjvEIgiAIgvDipJ9I3qhaKCglkTzBTelGntb6IQDrOW/5AQDv1xFPALjV87yXlz2O\naYaCTzMSyLPlmlMykSTVNUfnvWoHofThEwRBEAQhl/5y8kaTqqO0npqieMJ0MYmcvK8EcIn9/0r8\nOwvP837K87zDnucdXltbG9vgxsGodNmjgss1p6Xtg+pjQh2WN3zgafynTzw7suMLgiAIgjD70N6o\nlSvXjP4t2yCTwitCFlNbeEVr/W6t9Wu11q+96667Jj2cUiEDZVZy8vjcMS3eomAMOXnXtpu4stka\n2fHHxdMXN/BLHz1qGeuCIAiCIJQDbUXy5ZrSQkEYL5Mw8i4D+Cr2/6+If/eigZ7FWdl0h1NYeEWN\nwcgL1f4o7PLAiev4iy9fQiunSasgCIIgCIORtHXK65MX/Vv2PiqUnDwhg0kYeZ8E8C/jKpvfDmBL\na311AuOYGOGMyTW5fnxaCjglOXmjO4dK7Q+d+3bTBwD403LxBEEQBGEfkVTXnEwLhf2wVxHKp1b2\nAT3P+yCA7wFwp+d5KwB+DUAdALTWvw/grwF8L4DTABoA/s+yxzDtJHLNCQ+kT3jAcVokphRgG2Vh\nlFDrfRHJ24qNvHBWbjhBEARBmCH665MXv7dkg0xLTp6QQelGntb6R3u8rgG8oezPnSXImzMrck1l\nyTWnw+ihMXVCBa01PM8
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x7f5499b007b8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fig, ax = plt.subplots(nrows=2, ncols=1,figsize=[15,10])\n",
|
||
|
"ax[0].plot(diff.apply(train[\"Volume\"].values), label=\"Volume\")\n",
|
||
|
"\n",
|
||
|
"ax[1].plot(diff.apply(train[\"Openly\"].values, label=\"Open\"))\n",
|
||
|
"ax[1].plot(diff.apply(train[\"Highest\"].values, label=\"Higher\"))\n",
|
||
|
"ax[1].plot(diff.apply(train[\"Lowermost\"].values, label=\"Lower\"))\n",
|
||
|
"ax[1].plot(diff.apply(train[\"Close\"].values, label=\"Close\"))\n",
|
||
|
"\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Model training and test"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"2018-03-04 18:30:36 pycos - version 4.6.5 with epoll I/O notifier\n",
|
||
|
"2018-03-04 18:30:36 dispy - dispy client version: 4.8.4\n",
|
||
|
"2018-03-04 18:30:36 dispy - Storing fault recovery information in \"_dispy_20180304183036\"\n",
|
||
|
"2018-03-04 18:30:36 dispy - Started HTTP server at ('0.0.0.0', 8181)\n",
|
||
|
"[ 18:30:36] Distrituted Train Started\n",
|
||
|
"[ 18:30:36] Processing batch 1\n",
|
||
|
"[ 18:30:37] Finished batch 1\n",
|
||
|
"[ 18:30:37] Processing batch 2\n",
|
||
|
"[ 18:30:37] Finished batch 2\n",
|
||
|
"[ 18:30:37] Processing batch 3\n",
|
||
|
"[ 18:30:37] Finished batch 3\n",
|
||
|
"[ 18:30:37] Processing batch 4\n",
|
||
|
"[ 18:30:38] Finished batch 4\n",
|
||
|
"[ 18:30:38] Processing batch 5\n",
|
||
|
"[ 18:30:38] Finished batch 5\n",
|
||
|
"[ 18:30:38] Processing batch 6\n",
|
||
|
"[ 18:30:38] Finished batch 6\n",
|
||
|
"[ 18:30:38] Processing batch 7\n",
|
||
|
"[ 18:30:39] Finished batch 7\n",
|
||
|
"[ 18:30:39] Processing batch 8\n",
|
||
|
"[ 18:30:39] Finished batch 8\n",
|
||
|
"[ 18:30:39] Processing batch 9\n",
|
||
|
"[ 18:30:39] Finished batch 9\n",
|
||
|
"[ 18:30:39] Processing batch 10\n",
|
||
|
"[ 18:30:39] Finished batch 10\n",
|
||
|
"[ 18:30:39] Distrituted Train Finished\n",
|
||
|
"\n",
|
||
|
" Node | CPUs | Jobs | Sec/Job | Node Time Sec\n",
|
||
|
"------------------------------------------------------------------------------\n",
|
||
|
" 192.168.0.110 (petronio-notebo | 3 | 10 | 0.810 | 8.096\n",
|
||
|
"\n",
|
||
|
"Total job time: 8.096 sec, wall time: 3.277 sec, speedup: 2.471\n",
|
||
|
"\n",
|
||
|
"2018-03-04 18:30:39 dispy - HTTP server waiting for 10 seconds for client updates before quitting\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/usr/local/lib/python3.6/dist-packages/pyFTS/models/multivariate/mvfts.py:119: RuntimeWarning: invalid value encountered in double_scalars\n",
|
||
|
" ret.append(np.dot(mv,mp.T)/np.sum(mv))\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"model.fit(train, num_batches=10, distributed=True, nodes=['192.168.0.110'], save=False)\n",
|
||
|
"forecasted = model.forecast(test, distributed=True, nodes=['192.168.0.110'])"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA3kAAAJJC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R2v9dq31nVrrO1dWVqY4upx48RHgA2/m\nBomQeSAN18xZ5I0SrqkiIGyM/4TJCTc3QYSQeUMpAJrzG5kp8grX/GYAPyiEeA7AewF8pxDiPTmN\npRicvRd49H1AayPvkRBCxqUATh6UHK3wiownE2KZFCRgOBMhZN5IIxUKLvK++A7g07+R9yjG4rc/\nfhr3fOVy3sOYC3IReVrrX9Ja36S1vg3AfwfgHq31/5DHWAqD4ik4IXNDEXLyVIxOIvJ2dfLq4z+f\nnJFNECGk+Dz5YeC//Oh0KgOPwqyIvNN3A098MO9RjMW7PncOf/fYpbyHMRfkXV2TJCSn3+xnRcjs\nkzh4ebYUULIr8oY5inJC4Zo8qCKETIqti8BTf2tyhotAMq8VPVJBS8DJs9zG+MRKoRMXRNzPOLmL\nPK31J7XW35/3OHKH+SyEzA+6COGaMaJRmqGrGJDh+JsXzmGEkEmxdNJ8rRfE0ZkVJ0/FgOPmPYqx\niKVGO6LhMQlyF3nEIkPztegTCCFkOFoXovCK6MnJ28XJA8Z385iTRwiZFIunzNdaUURecnBX8D2a\nimfeyQslnbxJQZFXFFh+vND84aefxds+dSbvYZBZINuOIM/Ps44zIm/IxkRNSOQxJ48QMikSJ68w\nIm9G5jelZl7kxVKhQydvIlDkFQWGOhWau758CR/7ckEWG9JLpw685Rjwud/NeySGrLDL3ckzi70a\n6uTZOWfcCpvMySOETIi7zpmv8daL+Q4kYVZy8lQMiNnd2kuloTTo5E2I2b0S5g2GaxaaRidGJHMs\nokEGkzaoFXmPxJAVdjk
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x7f548aa62198>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fig, ax = plt.subplots(nrows=2, ncols=1,figsize=[15,10])\n",
|
||
|
"ax[0].plot(test[\"Volume\"].values, label=\"Volume\")\n",
|
||
|
"\n",
|
||
|
"ax[1].plot(diff.apply(test[\"Openly\"].values, label=\"Open\"))\n",
|
||
|
"ax[1].plot(diff.apply(test[\"Highest\"].values, label=\"Higher\"))\n",
|
||
|
"ax[1].plot(diff.apply(test[\"Lowermost\"].values, label=\"Lower\"))\n",
|
||
|
"ax[1].plot(diff.apply(test[\"Close\"].values, label=\"Close\"))\n",
|
||
|
"\n",
|
||
|
"ax[0].plot(forecasted)\n",
|
||
|
"\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# SONDA Experiments"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Data loading"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Populating the interactive namespace from numpy and matplotlib\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/usr/lib/python3/dist-packages/IPython/core/magics/pylab.py:161: UserWarning: pylab import has clobbered these variables: ['plt']\n",
|
||
|
"`%matplotlib` prevents importing * from pylab and numpy\n",
|
||
|
" \"\\n`%matplotlib` prevents importing * from pylab and numpy\"\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pylab as plt\n",
|
||
|
"\n",
|
||
|
"%pylab inline\n",
|
||
|
"\n",
|
||
|
"from pyFTS.data import SONDA\n",
|
||
|
"df = SONDA.get_dataframe()\n",
|
||
|
"train = df.iloc[0:1578241] #three years\n",
|
||
|
"test = df.iloc[1578241:] #ears\n",
|
||
|
"del df"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Variable, partitioning and model definitions"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABDAAAALICAYAAACJhQBYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Xd0VNXax/HvnkkhhfROSIcUEhL6\nRWwgxQIoLXQS7IpgR6UbEHvDgoBAEqo0FcUGSBeQllACIY30Bum9nfePyfhyryIBpmTC+ayVpcnM\n7OcJazIz53f22VtIkoRMJpPJZDKZTCaTyWQyWWum0HcDMplMJpPJZDKZTCaTyWTXIwcYMplMJpPJ\nZDKZTCaTyVo9OcCQyWQymUwmk8lkMplM1urJAYZMJpPJZDKZTCaTyWSyVk8OMGQymUwmk8lkMplM\nJpO1enKAIZPJZDKZTCaTyWQymazVkwMMmUwmk8lkt0wIIQkh/DQwjocQokIIodREX5oghJgohPjt\nX27fK4R4XJc9yWQymUx2O5IDDJlMJpPJ2hAhxCUhRJ0QwuF/fn6qOWTw0kCNmz5gF0J81RxQVDT3\nWX/V9z9LkpQhSZKlJEmNt9rnNer3FEL8KIQoFkKUCCEShBBvCSFsr/UYSZLWSZI0WBv9yGQymUwm\nazk5wJDJZDKZrO1JA8arvxFChADm+mvn/0mS9HRzQGEJLAa+UX8vSdID2qwthLgD2AscAgIkSbIB\n7gcagNBrPMZImz3JZDKZTCZrOTnAkMlkMpms7VkDTLnq+wgg9uo7CCGshRCxQohCIUS6EGKOEELR\nfFukEOKgEOKD5pkKaUKIB5pvewu4C/i8edbE51cNO1AIkdQ8s+ELIY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
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from pyFTS.partitioners import Grid, Util as pUtil\n",
|
||
|
"from pyFTS.common import Transformations\n",
|
||
|
"from pyFTS.models.multivariate import common, variable, mvfts\n",
|
||
|
"from pyFTS.models.seasonal import partitioner as seasonal\n",
|
||
|
"from pyFTS.models.seasonal.common import DateTime\n",
|
||
|
"\n",
|
||
|
"bc = Transformations.BoxCox(0)\n",
|
||
|
"diff = Transformations.Differential(1)\n",
|
||
|
"\n",
|
||
|
"np = 10\n",
|
||
|
"\n",
|
||
|
"model = mvfts.MVFTS(\"\")\n",
|
||
|
"\n",
|
||
|
"fig, axes = plt.subplots(nrows=5, ncols=1,figsize=[15,10])\n",
|
||
|
"\n",
|
||
|
"sp = {'seasonality': DateTime.day_of_year , 'names': ['Jan','Feb','Mar','Apr','May','Jun','Jul', 'Aug','Sep','Oct','Nov','Dec']}\n",
|
||
|
"\n",
|
||
|
"vmonth = variable.Variable(\"Month\", data_label=\"datahora\", partitioner=seasonal.TimeGridPartitioner, npart=12, \n",
|
||
|
" data=train, partitioner_specific=sp)\n",
|
||
|
"model.append_variable(vmonth)\n",
|
||
|
"vmonth.partitioner.plot(axes[0])\n",
|
||
|
"\n",
|
||
|
"sp = {'seasonality': DateTime.minute_of_day}\n",
|
||
|
"\n",
|
||
|
"vhour = variable.Variable(\"Hour\", data_label=\"datahora\", partitioner=seasonal.TimeGridPartitioner, npart=24, \n",
|
||
|
" data=train, partitioner_specific=sp)\n",
|
||
|
"model.append_variable(vhour)\n",
|
||
|
"vhour.partitioner.plot(axes[1])\n",
|
||
|
"\n",
|
||
|
"vhumid = variable.Variable(\"Humidity\", data_label=\"humid\", partitioner=Grid.GridPartitioner, npart=np, data=train)\n",
|
||
|
"model.append_variable(vhumid)\n",
|
||
|
"vhumid.partitioner.plot(axes[2])\n",
|
||
|
"\n",
|
||
|
"vpress = variable.Variable(\"AtmPress\", data_label=\"press\", partitioner=Grid.GridPartitioner, npart=np, data=train)\n",
|
||
|
"model.append_variable(vpress)\n",
|
||
|
"vpress.partitioner.plot(axes[3])\n",
|
||
|
"\n",
|
||
|
"vrain = variable.Variable(\"Rain\", data_label=\"rain\", partitioner=Grid.GridPartitioner, npart=20, data=train)#train)\n",
|
||
|
"model.append_variable(vrain)\n",
|
||
|
"vrain.partitioner.plot(axes[4])\n",
|
||
|
"\n",
|
||
|
"model.target_variable = vrain\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABDAAAALICAYAAACJhQBYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3XV4FNfXB/DvxBPcvQR3d3dNkXop\n8KvRFuqlQqBAgSJ56w6lpU5b2kKhNEhxtxDcAoTgJCQQIS7z/rE7k5nZmZVkN7sJ38/z9CnZrEyS\n3Zl7zz3nXEEURRAREREREREReTIvdx8AEREREREREZEtDGAQERERERERkcdjAIOIiIiIiIiIPB4D\nGERERERERETk8RjAICIiIiIiIiKPxwAGEREREREREXk8BjCIiIjIIwiCME0QhG+tfD9GEISB9tyX\niIiISh5BFEV3HwMRERF5KEEQYgBMEEVxo+K2J8y39XT3sZhvDwZwAYCvKIo5RXlMREREVHSYgUFE\nREREREREHo8BDCIiIiowQRBEQRAaKr7+QRCEueZ/9xUE4YogCG8JghAnCMJ1QRBGC4IwXBCEKEEQ\nbgmCME3x2FmCIPyi+Hq8IAgXBUFIEAThbc3rKu+73fz/REEQ7giC0Mf83K0U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AREREREZGMAQwX8uTsAiIiI8w+IiIiIiJPxACG\nCwhMvC4SWTl5WLz9PLJ
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x7f6d2215c6d8>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from pyFTS.common import Transformations\n",
|
||
|
"diff = Transformations.Differential(1)\n",
|
||
|
"\n",
|
||
|
"fig, ax = plt.subplots(nrows=3, ncols=1,figsize=[15,10])\n",
|
||
|
"\n",
|
||
|
"x = train[\"datahora\"].values\n",
|
||
|
"\n",
|
||
|
"ax[0].set_title(\"Humidity\")\n",
|
||
|
"ax[0].plot(x, diff.apply(train[\"humid\"].values))\n",
|
||
|
"\n",
|
||
|
"ax[1].set_title(\"Atm. Pressure\")\n",
|
||
|
"ax[1].plot(x, diff.apply(train[\"press\"].values))\n",
|
||
|
"\n",
|
||
|
"ax[2].set_title(\"Rain\")\n",
|
||
|
"ax[2].plot(x, train[\"rain\"].values)\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABZgAAAWYCAYAAAA7raPEAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3X90ZGd95/nPV+VrKPHD1Ybmh0Q3\nTQwjL6YxCoI2x8kOeMMRcWKjacxAB7OBk4nPzDI75IRVxg0ONlln2jmasJMM2bAm4QRi0wHsRjHg\njE4SPAN4cRO15UY0oDgQ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AAANC/Lpf0TklXmNkD1a8r0w4KAAAAqDkv7QAAAAAAhHP3r0qy\ntOMAAAAAmmEGMwAAAAAAAAAgFhLMAAAAAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAAAAAAiIUEMwAA\nAAAAAAAgFhLMAAAAAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAAAAAAiIUEMwAAAAAAAAAgFhLMAAAA\nAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAAAAAAiIUEMwAAAAAAAAAgFhLMAAAAAAAAAIBYSDADAAAA\nAAAAAGIhwQwAAAAAAAAAiIUEMwAAAAAAAAAgFhLMAAAAAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAA\nAAAAiIUEMwAAAAAAAAAgFhLMAAAAAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAAAAAAiIUEMwAAAAAA\nAAAgFhLMAAAAAAAAAIBYSDADAAAAAAAAAGIhwQwAAAAAAAAAiOW8tAMAAADAOfNLec0trOhUoaix\nXFaz0xOamRxPOywAAAA
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x7fe55a7eda90>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def comparevars(ax, x,y, x_lab, y_lab, title):\n",
|
||
|
" ax.scatter(x,y)\n",
|
||
|
" ax.set_title(title)\n",
|
||
|
" ax.set_xlabel(x_lab)\n",
|
||
|
" ax.set_ylabel(y_lab)\n",
|
||
|
" \n",
|
||
|
"from pyFTS.common import Transformations\n",
|
||
|
"diff = Transformations.Differential(1)\n",
|
||
|
"\n",
|
||
|
"data = test\n",
|
||
|
"\n",
|
||
|
"rain_diff = diff.apply(data[\"rain\"].values)\n",
|
||
|
"humid_diff = diff.apply(data[\"humid\"].values)\n",
|
||
|
"press_diff = diff.apply(data[\"press\"].values)\n",
|
||
|
" \n",
|
||
|
"fig, ax = plt.subplots(nrows=3, ncols=2,figsize=[20,20])\n",
|
||
|
"\n",
|
||
|
"comparevars(ax[0][0],data[\"humid\"].values,data[\"rain\"].values,\"humid\",\"rain\",\"Humidity x Rain\")\n",
|
||
|
"comparevars(ax[0][1],humid_diff,rain_diff,\"humid diff\",\"rain diff\",\"Humidity x Rain\")\n",
|
||
|
"comparevars(ax[1][0],data[\"press\"].values,data[\"rain\"].values,\"press\",\"press\",\"Atm. Pressure x Rain\")\n",
|
||
|
"comparevars(ax[1][1],press_diff,rain_diff,\"press diff\",\"rain diff\",\"Atm. Pressure x Rain\")\n",
|
||
|
"comparevars(ax[2][0],data[\"humid\"].values,data[\"press\"].values,\"humid\",\"press\",\"Humidity x Atm. Pressure\")\n",
|
||
|
"comparevars(ax[2][1],humid_diff, press_diff,\"humid diff\",\"press diff\",\"Humidity x Atm. Pressure\")\n",
|
||
|
"\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Model training and test"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"This model take time (a couple of hours) to be learned, so it is advisable to run it in distributed mode. The distributed mode use the dispy tool.\n",
|
||
|
"\n",
|
||
|
"- Install dispy on all computer nodes:\n",
|
||
|
"```python\n",
|
||
|
"$sudo pip3 install dispy\n",
|
||
|
"```\n",
|
||
|
"\n",
|
||
|
"- Run the dispynode on all computer nodes:\n",
|
||
|
"```python\n",
|
||
|
"$sudo python3 /usr/local/lib/python3.6/dist-packages/dispy/dispynode.py -i [MACHINE IP]\n",
|
||
|
"```\n",
|
||
|
"\n",
|
||
|
"The *save* parameter save the fitted model on disk on *file_path* file."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"model.fit(train, num_batches=200, save=True, batch_save=True, file_path='mvfts_sonda', \n",
|
||
|
" distributed=True, nodes=['192.168.0.110','192.168.0.106'], \n",
|
||
|
" batch_save_interval=10)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"from pyFTS.common import Util\n",
|
||
|
"\n",
|
||
|
"model = Util.load_obj('mvfts_sonda')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"For one-year data the prediction task also takes time. Same approach of the training method is used here."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"2018-03-06 12:07:39.412804\n",
|
||
|
"2018-03-06 12:07:39 pycos - version 4.6.5 with epoll I/O notifier\n",
|
||
|
"2018-03-06 12:07:39 dispy - dispy client version: 4.8.4\n",
|
||
|
"2018-03-06 12:07:39 dispy - Storing fault recovery information in \"_dispy_20180306120739\"\n",
|
||
|
"2018-03-06 12:07:39 dispy - Started HTTP server at ('0.0.0.0', 8181)\n",
|
||
|
"\n",
|
||
|
" Node | CPUs | Jobs | Sec/Job | Node Time Sec\n",
|
||
|
"------------------------------------------------------------------------------\n",
|
||
|
" 192.168.1.22 (petronio-noteboo | 3 | 20 | 0.741 | 14.815\n",
|
||
|
"\n",
|
||
|
"Total job time: 14.815 sec, wall time: 5.951 sec, speedup: 2.489\n",
|
||
|
"\n",
|
||
|
"2018-03-06 12:07:45 dispy - HTTP server waiting for 10 seconds for client updates before quitting\n",
|
||
|
"2018-03-06 12:07:56.086223\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"from datetime import datetime\n",
|
||
|
"data = test \n",
|
||
|
"_range = data['datahora'].values\n",
|
||
|
"print(datetime.now())\n",
|
||
|
"forecasted = model.predict(data, num_batches=20, distributed=True, nodes=['192.168.1.22'])\n",
|
||
|
"print(datetime.now())"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"[<matplotlib.lines.Line2D at 0x7f6d1d7e7f28>]"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAA20AAAEyCAYAAABptTjBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzs3Wd0XNX19/HvVe+SLXfLvYEBm2IM\nNi30XkNPCCSE8gQSAgn5p5OeENITUgghQEICoSVA6BB6NWDABhv33m1JlmT1+7zYc3TvjEbSSJY0\nI+n3WcvrTteRYGbuPnuffTzf9xEREREREZHUlJbsAYiIiIiIiEjbFLSJiIiIiIikMAVtIiIiIiIi\nKUxBm4iIiIiISApT0CYiIiIiIpLCFLSJiIiIiIikMAVtIiIiIiIiKUxBm4iIiIiISApT0CYiIiIi\nIpLCMpL1g4cMGeKPHz8+WT9eREREREQkqd56662tvu8P7ehxSQvaxo8fz7x585L140VERERERJLK\n87xViTxO5ZEiIiIiIiIpTEGbiIiIiIhIClPQJiIiIiIiksIUtImIiIiIiKQwBW0iIiIiIiIpTEGb\niIiIiIhIClPQJiIiIiIiksISCto8zzvB87zFnuct9Tzvq3Huv8TzvC2e582P/Pts9w9VR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w/fTuf+1xc+HahTBq3+jb3ZqFzDwYtZ9d7o1MW1flDYl/GWyG\n95jvwqb3Yf4/endcIiK7o6HaMmnZBdH7U9ZXhzJtccojwSoPyldb0JZdYLdVRZpLufLIrHwL1Moj\n5fBdDdoKR1pmbdsyy9a
|
||
|
"text/plain": [
|
||
|
"<matplotlib.figure.Figure at 0x7f6d1ca8fb00>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"fig, ax = plt.subplots(nrows=1, ncols=1, figsize=[15,5])\n",
|
||
|
"plot(_range,data['rain'].values)\n",
|
||
|
"plot(_range[:-1],forecasted)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": []
|
||
|
}
|
||
|
],
|
||
|
"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"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|