{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook\n", "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import data" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pricePh-24Ph-25Ph-26Ph-27Ph-28Ph-29Ph-30Ph-31Ph-32...month_Decembermonth_Februarymonth_Januarymonth_Julymonth_Junemonth_Marchmonth_Maymonth_Novembermonth_Octobermonth_September
fecha_hora
09/08/2016 00:0095.326454.846145.198244.712346.299542.942244.355146.344045.682642.6676...0000000001
09/08/2016 01:0082.853252.217954.846145.198244.712346.299542.942244.355146.344045.6826...0000000001
09/08/2016 02:0057.976461.919852.217954.846145.198244.712346.299542.942244.355146.3440...0000000001
09/08/2016 03:0067.640736.810561.919852.217954.846145.198244.712346.299542.942244.3551...0000000001
09/08/2016 04:0066.489234.827436.810561.919852.217954.846145.198244.712346.299542.9422...0000000001
\n", "

5 rows × 94 columns

\n", "
" ], "text/plain": [ " price Ph-24 Ph-25 Ph-26 Ph-27 Ph-28 \\\n", "fecha_hora \n", "09/08/2016 00:00 95.3264 54.8461 45.1982 44.7123 46.2995 42.9422 \n", "09/08/2016 01:00 82.8532 52.2179 54.8461 45.1982 44.7123 46.2995 \n", "09/08/2016 02:00 57.9764 61.9198 52.2179 54.8461 45.1982 44.7123 \n", "09/08/2016 03:00 67.6407 36.8105 61.9198 52.2179 54.8461 45.1982 \n", "09/08/2016 04:00 66.4892 34.8274 36.8105 61.9198 52.2179 54.8461 \n", "\n", " Ph-29 Ph-30 Ph-31 Ph-32 ... \\\n", "fecha_hora ... \n", "09/08/2016 00:00 44.3551 46.3440 45.6826 42.6676 ... \n", "09/08/2016 01:00 42.9422 44.3551 46.3440 45.6826 ... \n", "09/08/2016 02:00 46.2995 42.9422 44.3551 46.3440 ... \n", "09/08/2016 03:00 44.7123 46.2995 42.9422 44.3551 ... \n", "09/08/2016 04:00 45.1982 44.7123 46.2995 42.9422 ... \n", "\n", " month_December month_February month_January month_July \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "\n", " month_June month_March month_May month_November \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "\n", " month_October month_September \n", "fecha_hora \n", "09/08/2016 00:00 0 1 \n", "09/08/2016 01:00 0 1 \n", "09/08/2016 02:00 0 1 \n", "09/08/2016 03:00 0 1 \n", "09/08/2016 04:00 0 1 \n", "\n", "[5 rows x 94 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fname = \"lbrprices_transformed_v2.csv\"\n", "prices = pd.read_csv(fname, index_col=\"fecha_hora\").dropna()\n", "prices.head(5)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pricePh-24Ph-25Ph-26Ph-27Ph-28Ph-29Ph-30Ph-31Ph-32...month_Decembermonth_Februarymonth_Januarymonth_Julymonth_Junemonth_Marchmonth_Maymonth_Novembermonth_Octobermonth_September
count20520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.000000...20520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.00000020520.000000
mean72.09387372.05337172.05126272.04838872.04358372.03996972.03583172.03290472.02973872.025476...0.0771930.0701750.0771930.0771930.0748540.0771930.0771930.0970760.1005850.097076
std34.18361534.17671434.17703634.17685434.17354434.17270034.17091134.17053934.16997134.168179...0.2669040.2554490.2669040.2669040.2631620.2669040.2669040.2960680.3007850.296068
min18.70490018.70490018.70490018.70490018.70490018.70490018.70490018.70490018.70490018.704900...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
25%48.16440048.15647548.15417548.15225048.14730048.14537548.14050048.13460048.13250048.130500...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
50%65.08430065.01010065.00850065.00725065.00225064.99660064.99510064.99360064.98955064.985950...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
75%88.62092588.54180088.54180088.53145088.52645088.52142588.51782588.51672588.51367588.496425...0.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.0000000.000000
max329.440000329.440000329.440000329.440000329.440000329.440000329.440000329.440000329.440000329.440000...1.0000001.0000001.0000001.0000001.0000001.0000001.0000001.0000001.0000001.000000
\n", "

8 rows × 94 columns

\n", "
" ], "text/plain": [ " price Ph-24 Ph-25 Ph-26 Ph-27 \\\n", "count 20520.000000 20520.000000 20520.000000 20520.000000 20520.000000 \n", "mean 72.093873 72.053371 72.051262 72.048388 72.043583 \n", "std 34.183615 34.176714 34.177036 34.176854 34.173544 \n", "min 18.704900 18.704900 18.704900 18.704900 18.704900 \n", "25% 48.164400 48.156475 48.154175 48.152250 48.147300 \n", "50% 65.084300 65.010100 65.008500 65.007250 65.002250 \n", "75% 88.620925 88.541800 88.541800 88.531450 88.526450 \n", "max 329.440000 329.440000 329.440000 329.440000 329.440000 \n", "\n", " Ph-28 Ph-29 Ph-30 Ph-31 Ph-32 \\\n", "count 20520.000000 20520.000000 20520.000000 20520.000000 20520.000000 \n", "mean 72.039969 72.035831 72.032904 72.029738 72.025476 \n", "std 34.172700 34.170911 34.170539 34.169971 34.168179 \n", "min 18.704900 18.704900 18.704900 18.704900 18.704900 \n", "25% 48.145375 48.140500 48.134600 48.132500 48.130500 \n", "50% 64.996600 64.995100 64.993600 64.989550 64.985950 \n", "75% 88.521425 88.517825 88.516725 88.513675 88.496425 \n", "max 329.440000 329.440000 329.440000 329.440000 329.440000 \n", "\n", " ... month_December month_February month_January \\\n", "count ... 20520.000000 20520.000000 20520.000000 \n", "mean ... 0.077193 0.070175 0.077193 \n", "std ... 0.266904 0.255449 0.266904 \n", "min ... 0.000000 0.000000 0.000000 \n", "25% ... 0.000000 0.000000 0.000000 \n", "50% ... 0.000000 0.000000 0.000000 \n", "75% ... 0.000000 0.000000 0.000000 \n", "max ... 1.000000 1.000000 1.000000 \n", "\n", " month_July month_June month_March month_May month_November \\\n", "count 20520.000000 20520.000000 20520.000000 20520.000000 20520.000000 \n", "mean 0.077193 0.074854 0.077193 0.077193 0.097076 \n", "std 0.266904 0.263162 0.266904 0.266904 0.296068 \n", "min 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "25% 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "50% 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "75% 0.000000 0.000000 0.000000 0.000000 0.000000 \n", "max 1.000000 1.000000 1.000000 1.000000 1.000000 \n", "\n", " month_October month_September \n", "count 20520.000000 20520.000000 \n", "mean 0.100585 0.097076 \n", "std 0.300785 0.296068 \n", "min 0.000000 0.000000 \n", "25% 0.000000 0.000000 \n", "50% 0.000000 0.000000 \n", "75% 0.000000 0.000000 \n", "max 1.000000 1.000000 \n", "\n", "[8 rows x 94 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "prices.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Choosing features and targe" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "X = prices.drop([\"price\"], axis=1)\n", "y = prices[\"price\"]" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "fecha_hora\n", "09/08/2016 00:00 95.3264\n", "09/08/2016 01:00 82.8532\n", "09/08/2016 02:00 57.9764\n", "09/08/2016 03:00 67.6407\n", "09/08/2016 04:00 66.4892\n", "Name: price, dtype: float64" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "y.head(5)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Ph-24Ph-25Ph-26Ph-27Ph-28Ph-29Ph-30Ph-31Ph-32Ph-33...month_Decembermonth_Februarymonth_Januarymonth_Julymonth_Junemonth_Marchmonth_Maymonth_Novembermonth_Octobermonth_September
fecha_hora
09/08/2016 00:0054.846145.198244.712346.299542.942244.355146.344045.682642.667639.0872...0000000001
09/08/2016 01:0052.217954.846145.198244.712346.299542.942244.355146.344045.682642.6676...0000000001
09/08/2016 02:0061.919852.217954.846145.198244.712346.299542.942244.355146.344045.6826...0000000001
09/08/2016 03:0036.810561.919852.217954.846145.198244.712346.299542.942244.355146.3440...0000000001
09/08/2016 04:0034.827436.810561.919852.217954.846145.198244.712346.299542.942244.3551...0000000001
\n", "

5 rows × 93 columns

\n", "
" ], "text/plain": [ " Ph-24 Ph-25 Ph-26 Ph-27 Ph-28 Ph-29 \\\n", "fecha_hora \n", "09/08/2016 00:00 54.8461 45.1982 44.7123 46.2995 42.9422 44.3551 \n", "09/08/2016 01:00 52.2179 54.8461 45.1982 44.7123 46.2995 42.9422 \n", "09/08/2016 02:00 61.9198 52.2179 54.8461 45.1982 44.7123 46.2995 \n", "09/08/2016 03:00 36.8105 61.9198 52.2179 54.8461 45.1982 44.7123 \n", "09/08/2016 04:00 34.8274 36.8105 61.9198 52.2179 54.8461 45.1982 \n", "\n", " Ph-30 Ph-31 Ph-32 Ph-33 ... \\\n", "fecha_hora ... \n", "09/08/2016 00:00 46.3440 45.6826 42.6676 39.0872 ... \n", "09/08/2016 01:00 44.3551 46.3440 45.6826 42.6676 ... \n", "09/08/2016 02:00 42.9422 44.3551 46.3440 45.6826 ... \n", "09/08/2016 03:00 46.2995 42.9422 44.3551 46.3440 ... \n", "09/08/2016 04:00 44.7123 46.2995 42.9422 44.3551 ... \n", "\n", " month_December month_February month_January month_July \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "\n", " month_June month_March month_May month_November \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "\n", " month_October month_September \n", "fecha_hora \n", "09/08/2016 00:00 0 1 \n", "09/08/2016 01:00 0 1 \n", "09/08/2016 02:00 0 1 \n", "09/08/2016 03:00 0 1 \n", "09/08/2016 04:00 0 1 \n", "\n", "[5 rows x 93 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Train/test split" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Training features/target: (15390, 93) (15390,)\n", "Testing freatures/targe: (5130, 93) (5130,)\n" ] } ], "source": [ "from sklearn.model_selection import train_test_split\n", "X_train, X_test, y_train, y_test = train_test_split(X,y, random_state = 1)\n", "print(\"Training features/target: \", X_train.shape, y_train.shape)\n", "print(\"Testing freatures/targe: \", X_test.shape, y_test.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reshape Arrays for model" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "y_train = y_train.values.reshape(-1 ,1)\n", "y_test = y_test.values.reshape(-1 , 1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Cross-Validation and Hyper-parameters | SVR" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "# Import Pipeline and GridSearchCV\n", "from sklearn.pipeline import Pipeline\n", "from sklearn.model_selection import GridSearchCV\n", "from sklearn.preprocessing import StandardScaler\n", "from sklearn.svm import SVR" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Base SVR kernel='rbf'" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "pipe = Pipeline([\n", " ('standarscaler', StandardScaler()),\n", " ('regressor', SVR(kernel='rbf'))\n", "])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\data.py:625: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.partial_fit(X, y)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\base.py:465: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.fit(X, y, **fit_params).transform(X)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:761: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", " y = column_or_1d(y, warn=True)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 31.7 s\n" ] }, { "data": { "text/plain": [ "Pipeline(memory=None,\n", " steps=[('standarscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('regressor', SVR(C=1.0, cache_size=200, coef0=0.0, degree=3, epsilon=0.1,\n", " gamma='auto_deprecated', kernel='rbf', max_iter=-1, shrinking=True,\n", " tol=0.001, verbose=False))])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "pipe.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\pipeline.py:511: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " Xt = transform.transform(Xt)\n" ] }, { "data": { "text/plain": [ "0.6202242338800369" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pipe.score(X_test, y_test.ravel())" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\pipeline.py:331: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " Xt = transform.transform(Xt)\n" ] }, { "data": { "text/plain": [ "(5130,)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%timeit\n", "y_pred_1 = pipe.predict(X_test)\n", "y_pred_1.shape\n" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MAE: 13.305437540771377\n", "MSE: 434.06748706043726\n", "RMSE: 20.8342863343201\n" ] } ], "source": [ "from sklearn.metrics import mean_absolute_error, mean_squared_error\n", "mae1 = mean_absolute_error(y_test, y_pred_1)\n", "mse1 = mean_squared_error(y_test, y_pred_1)\n", "print(\"MAE: {}\".format(mae1))\n", "print(\"MSE: {}\".format(mse1))\n", "print(\"RMSE: {}\".format(np.sqrt(mse1)))" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.bar(np.arange(len(explained_variance)),explained_variance)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 90.8 ms\n" ] } ], "source": [ "%%time\n", "pca = PCA(0.95)\n", "pca_train = pca.fit_transform(X_train)\n", "pca_test = pca.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.54292225, 0.12577256, 0.06716 , 0.05823625, 0.04924647,\n", " 0.02196185, 0.02014353, 0.01457182, 0.01425445, 0.00985014,\n", " 0.00591487, 0.00408719, 0.00333382, 0.00288473, 0.00278578,\n", " 0.00255025, 0.00251787, 0.00225158])" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pca.explained_variance_ratio_" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.scatter(pca_train[:,0], pca_train[:,1], alpha=0.2)\n", "plt.xlabel=\"Component 1\"\n", "plt.ylabel=\"Component 2\"\n", "plt.title=\"Principal Components\"\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 61, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\data.py:625: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.partial_fit(X, y)\n", "C:\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:4: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " after removing the cwd from sys.path.\n", "C:\\anaconda3\\lib\\site-packages\\ipykernel_launcher.py:5: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " \"\"\"\n" ] } ], "source": [ "scaler = StandardScaler()\n", "scaler.fit(X_train)\n", "\n", "X_train_sc = scaler.transform(X_train)\n", "X_test_sc = scaler.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 70.5 ms\n" ] } ], "source": [ "%%time\n", "pca = PCA(0.95)\n", "pca_train = pca.fit_transform(X_train_sc)\n", "pca_test = pca.transform(X_test_sc)" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.plot(y_test[100:300], \"o\")\n", "plt.plot(y_pred_2[100:300], linewidth=1)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 74, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 23 s\n" ] } ], "source": [ "%%time\n", "svr2 = SVR(kernel='rbf', gamma='auto', C=15)\n", "svr2.fit(pca_train, y_train.ravel())" ] }, { "cell_type": "code", "execution_count": 75, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.829300757254184" ] }, "execution_count": 75, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svr2.score(pca_test, y_test.ravel())" ] }, { "cell_type": "code", "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.plot(y_test[300:324], \"o\")\n", "plt.plot(y_pred_2[300:324], linewidth=1)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 98, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MAE: 7.531617341722956\n", "MSE: 195.10194686406336\n", "RMSE: 13.967889850083418\n" ] } ], "source": [ "mae2 = mean_absolute_error(y_test, y_pred_2)\n", "mse2 = mean_squared_error(y_test, y_pred_2)\n", "print(\"MAE: {}\".format(mae2))\n", "print(\"MSE: {}\".format(mse2))\n", "print(\"RMSE: {}\".format(np.sqrt(mse2)))" ] }, { "cell_type": "code", "execution_count": 89, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 35 s\n" ] } ], "source": [ "%%time\n", "svr3 = SVR(kernel='rbf', C=15, gamma=0.05)\n", "svr3.fit(pca_train, y_train.ravel())" ] }, { "cell_type": "code", "execution_count": 90, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/plain": [ "0.8449547039001476" ] }, "execution_count": 90, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svr3.score(pca_test, y_test.ravel())" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "y_pred_3 = svr3.predict(pca_test)" ] }, { "cell_type": "code", "execution_count": 102, "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "window.mpl = {};\n", "\n", "\n", "mpl.get_websocket_type = function() {\n", " if (typeof(WebSocket) !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof(MozWebSocket) !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert('Your browser does not have WebSocket support.' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.');\n", " };\n", "}\n", "\n", "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = (this.ws.binaryType != undefined);\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById(\"mpl-warnings\");\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent = (\n", " \"This browser does not support binary websocket messages. \" +\n", " \"Performance may be slow.\");\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = $('
');\n", " this._root_extra_style(this.root)\n", " this.root.attr('style', 'display: inline-block');\n", "\n", " $(parent_element).append(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n", " fig.send_message(\"send_image_mode\", {});\n", " if (mpl.ratio != 1) {\n", " fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n", " }\n", " fig.send_message(\"refresh\", {});\n", " }\n", "\n", " this.imageObj.onload = function() {\n", " if (fig.image_mode == 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function() {\n", " fig.ws.close();\n", " }\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "}\n", "\n", "mpl.figure.prototype._init_header = function() {\n", " var titlebar = $(\n", " '
');\n", " var titletext = $(\n", " '
');\n", " titlebar.append(titletext)\n", " this.root.append(titlebar);\n", " this.header = titletext[0];\n", "}\n", "\n", "\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "\n", "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n", "\n", "}\n", "\n", "mpl.figure.prototype._init_canvas = function() {\n", " var fig = this;\n", "\n", " var canvas_div = $('
');\n", "\n", " canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n", "\n", " function canvas_keyboard_event(event) {\n", " return fig.key_event(event, event['data']);\n", " }\n", "\n", " canvas_div.keydown('key_press', canvas_keyboard_event);\n", " canvas_div.keyup('key_release', canvas_keyboard_event);\n", " this.canvas_div = canvas_div\n", " this._canvas_extra_style(canvas_div)\n", " this.root.append(canvas_div);\n", "\n", " var canvas = $('');\n", " canvas.addClass('mpl-canvas');\n", " canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n", "\n", " this.canvas = canvas[0];\n", " this.context = canvas[0].getContext(\"2d\");\n", "\n", " var backingStore = this.context.backingStorePixelRatio ||\n", "\tthis.context.webkitBackingStorePixelRatio ||\n", "\tthis.context.mozBackingStorePixelRatio ||\n", "\tthis.context.msBackingStorePixelRatio ||\n", "\tthis.context.oBackingStorePixelRatio ||\n", "\tthis.context.backingStorePixelRatio || 1;\n", "\n", " mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband = $('');\n", " rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n", "\n", " var pass_mouse_events = true;\n", "\n", " canvas_div.resizable({\n", " start: function(event, ui) {\n", " pass_mouse_events = false;\n", " },\n", " resize: function(event, ui) {\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " stop: function(event, ui) {\n", " pass_mouse_events = true;\n", " fig.request_resize(ui.size.width, ui.size.height);\n", " },\n", " });\n", "\n", " function mouse_event_fn(event) {\n", " if (pass_mouse_events)\n", " return fig.mouse_event(event, event['data']);\n", " }\n", "\n", " rubberband.mousedown('button_press', mouse_event_fn);\n", " rubberband.mouseup('button_release', mouse_event_fn);\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " rubberband.mousemove('motion_notify', mouse_event_fn);\n", "\n", " rubberband.mouseenter('figure_enter', mouse_event_fn);\n", " rubberband.mouseleave('figure_leave', mouse_event_fn);\n", "\n", " canvas_div.on(\"wheel\", function (event) {\n", " event = event.originalEvent;\n", " event['data'] = 'scroll'\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " mouse_event_fn(event);\n", " });\n", "\n", " canvas_div.append(canvas);\n", " canvas_div.append(rubberband);\n", "\n", " this.rubberband = rubberband;\n", " this.rubberband_canvas = rubberband[0];\n", " this.rubberband_context = rubberband[0].getContext(\"2d\");\n", " this.rubberband_context.strokeStyle = \"#000000\";\n", "\n", " this._resize_canvas = function(width, height) {\n", " // Keep the size of the canvas, canvas container, and rubber band\n", " // canvas in synch.\n", " canvas_div.css('width', width)\n", " canvas_div.css('height', height)\n", "\n", " canvas.attr('width', width * mpl.ratio);\n", " canvas.attr('height', height * mpl.ratio);\n", " canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n", "\n", " rubberband.attr('width', width);\n", " rubberband.attr('height', height);\n", " }\n", "\n", " // Set the figure to an initial 600x600px, this will subsequently be updated\n", " // upon first draw.\n", " this._resize_canvas(600, 600);\n", "\n", " // Disable right mouse context menu.\n", " $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n", " return false;\n", " });\n", "\n", " function set_focus () {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "}\n", "\n", "mpl.figure.prototype._init_toolbar = function() {\n", " var fig = this;\n", "\n", " var nav_element = $('
')\n", " nav_element.attr('style', 'width: 100%');\n", " this.root.append(nav_element);\n", "\n", " // Define a callback function for later on.\n", " function toolbar_event(event) {\n", " return fig.toolbar_button_onclick(event['data']);\n", " }\n", " function toolbar_mouse_event(event) {\n", " return fig.toolbar_button_onmouseover(event['data']);\n", " }\n", "\n", " for(var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " // put a spacer in here.\n", " continue;\n", " }\n", " var button = $('');\n", " button.click(method_name, toolbar_event);\n", " button.mouseover(tooltip, toolbar_mouse_event);\n", " nav_element.append(button);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = $('');\n", " nav_element.append(status_bar);\n", " this.message = status_bar[0];\n", "\n", " // Add the close button to the window.\n", " var buttongrp = $('
');\n", " var button = $('');\n", " button.click(function (evt) { fig.handle_close(fig, {}); } );\n", " button.mouseover('Stop Interaction', toolbar_mouse_event);\n", " buttongrp.append(button);\n", " var titlebar = this.root.find($('.ui-dialog-titlebar'));\n", " titlebar.prepend(buttongrp);\n", "}\n", "\n", "mpl.figure.prototype._root_extra_style = function(el){\n", " var fig = this\n", " el.on(\"remove\", function(){\n", "\tfig.close_ws(fig, {});\n", " });\n", "}\n", "\n", "mpl.figure.prototype._canvas_extra_style = function(el){\n", " // this is important to make the div 'focusable\n", " el.attr('tabindex', 0)\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " }\n", " else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "\n", "}\n", "\n", "mpl.figure.prototype._key_event_extra = function(event, name) {\n", " var manager = IPython.notebook.keyboard_manager;\n", " if (!manager)\n", " manager = IPython.keyboard_manager;\n", "\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which == 13) {\n", " this.canvas_div.blur();\n", " event.shiftKey = false;\n", " // Send a \"J\" for go to next cell\n", " event.which = 74;\n", " event.keyCode = 74;\n", " manager.command_mode();\n", " manager.handle_keydown(event);\n", " }\n", "}\n", "\n", "mpl.figure.prototype.handle_save = function(fig, msg) {\n", " fig.ondownload(fig, null);\n", "}\n", "\n", "\n", "mpl.find_output_cell = function(html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i=0; i= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] == html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "}\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel != null) {\n", " IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plt.style.use('seaborn-whitegrid')\n", "plt.plot(y_test[300:400], \"o\")\n", "#plt.plot(y_pred_3[300:400], '-o', linewidth=1, alpha=0.4, label='gamma=0.05, C=15')\n", "plt.plot(y_pred_4[300:400], linewidth=1, alpha=0.7, label='gamma=0.05, C=100')\n", "plt.legend()\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MAE: 5.16079216440072\n", "MSE: 102.12787663038642\n", "RMSE: 10.105833791943464\n" ] } ], "source": [ "mae4 = mean_absolute_error(y_test, y_pred_4)\n", "mse4 = mean_squared_error(y_test, y_pred_4)\n", "print(\"MAE: {}\".format(mae4))\n", "print(\"MSE: {}\".format(mse4))\n", "print(\"RMSE: {}\".format(np.sqrt(mse4)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SVR Pipeline" ] }, { "cell_type": "code", "execution_count": 116, "metadata": {}, "outputs": [], "source": [ "svrpipe = Pipeline([\n", " ('standarscaler', StandardScaler()),\n", " ('pca', pca),\n", " ('regressor', SVR(kernel='rbf', C=100, gamma=0.05))\n", "])" ] }, { "cell_type": "code", "execution_count": 117, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Ph-24Ph-25Ph-26Ph-27Ph-28Ph-29Ph-30Ph-31Ph-32Ph-33...month_Decembermonth_Februarymonth_Januarymonth_Julymonth_Junemonth_Marchmonth_Maymonth_Novembermonth_Octobermonth_September
fecha_hora
24/10/2018 04:0062.033663.708570.244470.794690.679596.1702102.8210110.3368104.6051114.0036...0000000010
07/09/2018 05:0079.103063.944366.258296.2362116.4281128.8701119.1240119.6116120.0424153.5935...0001000000
09/01/2017 19:0039.268338.485230.358330.016830.214830.167932.722933.105831.282629.9553...0000000001
05/12/2016 06:0029.655230.003529.968630.293630.558530.309135.311439.826546.531951.0830...0000001000
13/11/2018 10:00108.4272106.416998.905579.617862.648445.018338.011837.673838.303744.2274...0000000100
30/06/2018 19:00202.7817120.2459114.5061118.5899142.3258121.7742137.6828126.3751122.2330122.1453...0000100000
21/09/2018 05:00100.6811101.8826106.8609113.6781127.7593124.2647118.1552125.8922130.8899132.8493...0000000001
19/11/2018 14:0067.276668.380068.196567.689166.216859.549953.357949.338049.597749.1862...0000000100
14/02/2017 13:0055.050154.727351.889952.225051.125246.252536.792630.183826.694925.2166...0100000000
26/07/2017 23:0064.658876.996177.465270.374469.086473.581873.772372.215270.805774.5895...0001000000
12/04/2018 07:0079.932373.594657.432954.424555.432464.994879.880488.5397148.9334160.0158...1000000000
23/04/2018 06:0053.544352.748151.754553.253753.633855.372950.864459.888462.731671.1976...0000000000
21/12/2017 05:0032.989030.629630.529631.482535.106744.911058.007384.979381.082086.4752...1000000000
27/08/2016 04:0039.122138.646852.588263.019763.251760.714554.429758.491853.736958.8155...0000000000
24/01/2017 04:0027.563027.767728.077729.126130.786634.754543.713050.170051.112449.5433...0010000000
06/05/2017 22:0066.983176.551783.545867.6796112.809261.538257.761662.323375.092280.8659...0000100000
11/10/2018 05:0052.775468.885268.889971.013967.194678.5905130.7685144.0459156.5956155.5354...0000000100
28/11/2016 09:0022.926721.892722.058422.071922.110722.098122.157221.784721.672823.1965...0000000100
02/08/2018 01:00124.9033125.3632124.9229135.4568127.0489170.1710157.4442161.6390164.6942164.4391...0100000000
06/12/2018 21:00112.1568120.6247104.5916116.191599.3905120.343396.254495.223689.1608102.8244...0000100000
29/03/2018 22:00133.4957120.7033136.0745136.8717109.8511132.0239138.0859122.5554136.6549136.3353...0000010000
26/10/2018 14:0099.604096.0196104.7548106.3062105.3224104.6004101.931493.914692.446179.1929...0000000010
16/05/2018 01:00115.3171123.373085.034298.4894102.672693.3665100.270296.298083.1847102.5194...0000001000
01/11/2016 05:0027.162324.504124.723825.368127.065928.133227.585134.542240.065342.4801...0010000000
10/01/2018 19:0055.376753.494652.135652.400353.699553.762954.513452.661453.633951.5521...0000000010
30/01/2017 03:0027.709627.932828.386630.152435.305743.169850.783052.439953.516053.2125...0010000000
15/10/2016 20:0071.051871.935876.578772.349173.664373.839169.748874.110281.902271.6206...0000000010
11/09/2017 12:0041.289440.606140.757538.152337.700437.664938.275639.011139.178341.1988...0000000100
12/12/2016 13:0047.250248.008747.084447.045646.555241.399434.545624.375723.919223.8307...1000000000
11/10/2017 11:0093.359694.490186.707992.760187.024684.636666.745456.963258.790272.6529...0000000100
..................................................................
10/09/2017 01:0050.680250.348355.154455.582454.635353.185654.337955.827855.140858.0781...0000000010
06/01/2017 06:0035.144532.736030.417830.780133.070635.859641.873841.357048.124647.6485...0000100000
20/10/2018 13:00145.1181147.9180140.2396131.9554100.5518111.5067110.958588.613163.412954.6246...0000000010
08/02/2017 23:0059.424683.449892.5576105.5635108.678090.5841106.629391.365693.544491.8023...0000000000
20/09/2016 23:0067.106565.757370.280564.128067.290266.379467.566679.360268.814465.9954...0000000001
27/04/2017 21:0095.712697.083883.492485.616286.588698.699298.589198.205183.532781.7933...0000000000
24/09/2016 06:0032.688335.704440.762438.237776.666168.348671.112271.478071.034179.2917...0000000001
09/09/2018 08:0083.890481.907474.4707102.2899128.3038113.4641103.1726113.9104127.9198125.3119...0000000001
11/12/2017 06:0028.233228.994029.199929.396329.518229.864632.537250.331860.979468.4285...0000000100
24/07/2018 01:0082.3517137.490958.557660.634461.289259.990053.200959.086556.601060.9025...0001000000
27/10/2018 17:0076.711485.032884.201084.891085.664282.917687.767582.046884.390685.4864...0000000010
16/07/2018 02:0052.742552.034852.291174.562184.544284.386185.780976.809480.822976.4394...0001000000
23/02/2017 12:0051.089848.740848.414046.975543.346541.772830.052026.047425.344525.3546...0100000000
18/11/2018 02:0056.690863.836974.069179.962980.636581.433893.274898.795293.488587.7945...0000000100
26/07/2017 20:0070.374469.086473.581873.772372.215270.805774.589573.100376.461474.8614...0001000000
05/10/2018 12:0091.672685.894872.858161.698757.722855.207539.246033.366033.323332.8713...0000001000
10/12/2016 10:0054.742951.940243.302436.275533.651933.212231.625431.320933.504834.2628...0000000010
17/01/2018 21:0075.435477.221374.919975.494870.878170.597168.983569.851066.802468.6738...0010000000
31/12/2016 06:0030.353027.518326.772423.555527.753530.126531.477237.338842.733744.3704...1000000000
09/11/2017 21:00137.5995140.4195143.7565157.0596137.6391144.3892134.6086144.6498148.8185145.7671...0000000001
27/06/2017 23:0059.860563.223564.405661.211066.229151.259961.570153.296864.137267.8108...0000100000
20/06/2018 12:0079.052175.818575.576380.490375.800572.021170.648778.420576.250872.1556...0000100000
15/08/2016 00:0032.509947.806346.814848.008054.334544.099142.365045.949450.996149.5766...0000000000
21/10/2018 07:0076.778464.631662.559461.967365.484767.810168.941476.1713104.8215136.8151...0000000010
30/06/2017 13:00155.9874133.2397128.6575133.6157134.626196.4450137.208285.546885.039977.3693...0000100000
08/11/2017 11:00161.3238162.2232131.1620136.682691.962667.821052.763747.158047.165451.0023...0000000000
30/07/2018 09:0085.240971.949362.988485.438388.711587.9971103.572499.306597.7276102.8581...0001000000
13/03/2017 08:0032.661628.782629.922929.889330.129031.671532.857035.469547.557350.1168...0000010000
29/12/2017 04:0033.154135.216937.917440.419243.735947.561464.363764.080566.040268.3345...1000000000
18/08/2016 19:0046.070148.412449.357155.713651.440951.351153.759149.438148.859843.5985...0000000000
\n", "

15390 rows × 93 columns

\n", "
" ], "text/plain": [ " Ph-24 Ph-25 Ph-26 Ph-27 Ph-28 Ph-29 \\\n", "fecha_hora \n", "24/10/2018 04:00 62.0336 63.7085 70.2444 70.7946 90.6795 96.1702 \n", "07/09/2018 05:00 79.1030 63.9443 66.2582 96.2362 116.4281 128.8701 \n", "09/01/2017 19:00 39.2683 38.4852 30.3583 30.0168 30.2148 30.1679 \n", "05/12/2016 06:00 29.6552 30.0035 29.9686 30.2936 30.5585 30.3091 \n", "13/11/2018 10:00 108.4272 106.4169 98.9055 79.6178 62.6484 45.0183 \n", "30/06/2018 19:00 202.7817 120.2459 114.5061 118.5899 142.3258 121.7742 \n", "21/09/2018 05:00 100.6811 101.8826 106.8609 113.6781 127.7593 124.2647 \n", "19/11/2018 14:00 67.2766 68.3800 68.1965 67.6891 66.2168 59.5499 \n", "14/02/2017 13:00 55.0501 54.7273 51.8899 52.2250 51.1252 46.2525 \n", "26/07/2017 23:00 64.6588 76.9961 77.4652 70.3744 69.0864 73.5818 \n", "12/04/2018 07:00 79.9323 73.5946 57.4329 54.4245 55.4324 64.9948 \n", "23/04/2018 06:00 53.5443 52.7481 51.7545 53.2537 53.6338 55.3729 \n", "21/12/2017 05:00 32.9890 30.6296 30.5296 31.4825 35.1067 44.9110 \n", "27/08/2016 04:00 39.1221 38.6468 52.5882 63.0197 63.2517 60.7145 \n", "24/01/2017 04:00 27.5630 27.7677 28.0777 29.1261 30.7866 34.7545 \n", "06/05/2017 22:00 66.9831 76.5517 83.5458 67.6796 112.8092 61.5382 \n", "11/10/2018 05:00 52.7754 68.8852 68.8899 71.0139 67.1946 78.5905 \n", "28/11/2016 09:00 22.9267 21.8927 22.0584 22.0719 22.1107 22.0981 \n", "02/08/2018 01:00 124.9033 125.3632 124.9229 135.4568 127.0489 170.1710 \n", "06/12/2018 21:00 112.1568 120.6247 104.5916 116.1915 99.3905 120.3433 \n", "29/03/2018 22:00 133.4957 120.7033 136.0745 136.8717 109.8511 132.0239 \n", "26/10/2018 14:00 99.6040 96.0196 104.7548 106.3062 105.3224 104.6004 \n", "16/05/2018 01:00 115.3171 123.3730 85.0342 98.4894 102.6726 93.3665 \n", "01/11/2016 05:00 27.1623 24.5041 24.7238 25.3681 27.0659 28.1332 \n", "10/01/2018 19:00 55.3767 53.4946 52.1356 52.4003 53.6995 53.7629 \n", "30/01/2017 03:00 27.7096 27.9328 28.3866 30.1524 35.3057 43.1698 \n", "15/10/2016 20:00 71.0518 71.9358 76.5787 72.3491 73.6643 73.8391 \n", "11/09/2017 12:00 41.2894 40.6061 40.7575 38.1523 37.7004 37.6649 \n", "12/12/2016 13:00 47.2502 48.0087 47.0844 47.0456 46.5552 41.3994 \n", "11/10/2017 11:00 93.3596 94.4901 86.7079 92.7601 87.0246 84.6366 \n", "... ... ... ... ... ... ... \n", "10/09/2017 01:00 50.6802 50.3483 55.1544 55.5824 54.6353 53.1856 \n", "06/01/2017 06:00 35.1445 32.7360 30.4178 30.7801 33.0706 35.8596 \n", "20/10/2018 13:00 145.1181 147.9180 140.2396 131.9554 100.5518 111.5067 \n", "08/02/2017 23:00 59.4246 83.4498 92.5576 105.5635 108.6780 90.5841 \n", "20/09/2016 23:00 67.1065 65.7573 70.2805 64.1280 67.2902 66.3794 \n", "27/04/2017 21:00 95.7126 97.0838 83.4924 85.6162 86.5886 98.6992 \n", "24/09/2016 06:00 32.6883 35.7044 40.7624 38.2377 76.6661 68.3486 \n", "09/09/2018 08:00 83.8904 81.9074 74.4707 102.2899 128.3038 113.4641 \n", "11/12/2017 06:00 28.2332 28.9940 29.1999 29.3963 29.5182 29.8646 \n", "24/07/2018 01:00 82.3517 137.4909 58.5576 60.6344 61.2892 59.9900 \n", "27/10/2018 17:00 76.7114 85.0328 84.2010 84.8910 85.6642 82.9176 \n", "16/07/2018 02:00 52.7425 52.0348 52.2911 74.5621 84.5442 84.3861 \n", "23/02/2017 12:00 51.0898 48.7408 48.4140 46.9755 43.3465 41.7728 \n", "18/11/2018 02:00 56.6908 63.8369 74.0691 79.9629 80.6365 81.4338 \n", "26/07/2017 20:00 70.3744 69.0864 73.5818 73.7723 72.2152 70.8057 \n", "05/10/2018 12:00 91.6726 85.8948 72.8581 61.6987 57.7228 55.2075 \n", "10/12/2016 10:00 54.7429 51.9402 43.3024 36.2755 33.6519 33.2122 \n", "17/01/2018 21:00 75.4354 77.2213 74.9199 75.4948 70.8781 70.5971 \n", "31/12/2016 06:00 30.3530 27.5183 26.7724 23.5555 27.7535 30.1265 \n", "09/11/2017 21:00 137.5995 140.4195 143.7565 157.0596 137.6391 144.3892 \n", "27/06/2017 23:00 59.8605 63.2235 64.4056 61.2110 66.2291 51.2599 \n", "20/06/2018 12:00 79.0521 75.8185 75.5763 80.4903 75.8005 72.0211 \n", "15/08/2016 00:00 32.5099 47.8063 46.8148 48.0080 54.3345 44.0991 \n", "21/10/2018 07:00 76.7784 64.6316 62.5594 61.9673 65.4847 67.8101 \n", "30/06/2017 13:00 155.9874 133.2397 128.6575 133.6157 134.6261 96.4450 \n", "08/11/2017 11:00 161.3238 162.2232 131.1620 136.6826 91.9626 67.8210 \n", "30/07/2018 09:00 85.2409 71.9493 62.9884 85.4383 88.7115 87.9971 \n", "13/03/2017 08:00 32.6616 28.7826 29.9229 29.8893 30.1290 31.6715 \n", "29/12/2017 04:00 33.1541 35.2169 37.9174 40.4192 43.7359 47.5614 \n", "18/08/2016 19:00 46.0701 48.4124 49.3571 55.7136 51.4409 51.3511 \n", "\n", " Ph-30 Ph-31 Ph-32 Ph-33 ... \\\n", "fecha_hora ... \n", "24/10/2018 04:00 102.8210 110.3368 104.6051 114.0036 ... \n", "07/09/2018 05:00 119.1240 119.6116 120.0424 153.5935 ... \n", "09/01/2017 19:00 32.7229 33.1058 31.2826 29.9553 ... \n", "05/12/2016 06:00 35.3114 39.8265 46.5319 51.0830 ... \n", "13/11/2018 10:00 38.0118 37.6738 38.3037 44.2274 ... \n", "30/06/2018 19:00 137.6828 126.3751 122.2330 122.1453 ... \n", "21/09/2018 05:00 118.1552 125.8922 130.8899 132.8493 ... \n", "19/11/2018 14:00 53.3579 49.3380 49.5977 49.1862 ... \n", "14/02/2017 13:00 36.7926 30.1838 26.6949 25.2166 ... \n", "26/07/2017 23:00 73.7723 72.2152 70.8057 74.5895 ... \n", "12/04/2018 07:00 79.8804 88.5397 148.9334 160.0158 ... \n", "23/04/2018 06:00 50.8644 59.8884 62.7316 71.1976 ... \n", "21/12/2017 05:00 58.0073 84.9793 81.0820 86.4752 ... \n", "27/08/2016 04:00 54.4297 58.4918 53.7369 58.8155 ... \n", "24/01/2017 04:00 43.7130 50.1700 51.1124 49.5433 ... \n", "06/05/2017 22:00 57.7616 62.3233 75.0922 80.8659 ... \n", "11/10/2018 05:00 130.7685 144.0459 156.5956 155.5354 ... \n", "28/11/2016 09:00 22.1572 21.7847 21.6728 23.1965 ... \n", "02/08/2018 01:00 157.4442 161.6390 164.6942 164.4391 ... \n", "06/12/2018 21:00 96.2544 95.2236 89.1608 102.8244 ... \n", "29/03/2018 22:00 138.0859 122.5554 136.6549 136.3353 ... \n", "26/10/2018 14:00 101.9314 93.9146 92.4461 79.1929 ... \n", "16/05/2018 01:00 100.2702 96.2980 83.1847 102.5194 ... \n", "01/11/2016 05:00 27.5851 34.5422 40.0653 42.4801 ... \n", "10/01/2018 19:00 54.5134 52.6614 53.6339 51.5521 ... \n", "30/01/2017 03:00 50.7830 52.4399 53.5160 53.2125 ... \n", "15/10/2016 20:00 69.7488 74.1102 81.9022 71.6206 ... \n", "11/09/2017 12:00 38.2756 39.0111 39.1783 41.1988 ... \n", "12/12/2016 13:00 34.5456 24.3757 23.9192 23.8307 ... \n", "11/10/2017 11:00 66.7454 56.9632 58.7902 72.6529 ... \n", "... ... ... ... ... ... \n", "10/09/2017 01:00 54.3379 55.8278 55.1408 58.0781 ... \n", "06/01/2017 06:00 41.8738 41.3570 48.1246 47.6485 ... \n", "20/10/2018 13:00 110.9585 88.6131 63.4129 54.6246 ... \n", "08/02/2017 23:00 106.6293 91.3656 93.5444 91.8023 ... \n", "20/09/2016 23:00 67.5666 79.3602 68.8144 65.9954 ... \n", "27/04/2017 21:00 98.5891 98.2051 83.5327 81.7933 ... \n", "24/09/2016 06:00 71.1122 71.4780 71.0341 79.2917 ... \n", "09/09/2018 08:00 103.1726 113.9104 127.9198 125.3119 ... \n", "11/12/2017 06:00 32.5372 50.3318 60.9794 68.4285 ... \n", "24/07/2018 01:00 53.2009 59.0865 56.6010 60.9025 ... \n", "27/10/2018 17:00 87.7675 82.0468 84.3906 85.4864 ... \n", "16/07/2018 02:00 85.7809 76.8094 80.8229 76.4394 ... \n", "23/02/2017 12:00 30.0520 26.0474 25.3445 25.3546 ... \n", "18/11/2018 02:00 93.2748 98.7952 93.4885 87.7945 ... \n", "26/07/2017 20:00 74.5895 73.1003 76.4614 74.8614 ... \n", "05/10/2018 12:00 39.2460 33.3660 33.3233 32.8713 ... \n", "10/12/2016 10:00 31.6254 31.3209 33.5048 34.2628 ... \n", "17/01/2018 21:00 68.9835 69.8510 66.8024 68.6738 ... \n", "31/12/2016 06:00 31.4772 37.3388 42.7337 44.3704 ... \n", "09/11/2017 21:00 134.6086 144.6498 148.8185 145.7671 ... \n", "27/06/2017 23:00 61.5701 53.2968 64.1372 67.8108 ... \n", "20/06/2018 12:00 70.6487 78.4205 76.2508 72.1556 ... \n", "15/08/2016 00:00 42.3650 45.9494 50.9961 49.5766 ... \n", "21/10/2018 07:00 68.9414 76.1713 104.8215 136.8151 ... \n", "30/06/2017 13:00 137.2082 85.5468 85.0399 77.3693 ... \n", "08/11/2017 11:00 52.7637 47.1580 47.1654 51.0023 ... \n", "30/07/2018 09:00 103.5724 99.3065 97.7276 102.8581 ... \n", "13/03/2017 08:00 32.8570 35.4695 47.5573 50.1168 ... \n", "29/12/2017 04:00 64.3637 64.0805 66.0402 68.3345 ... \n", "18/08/2016 19:00 53.7591 49.4381 48.8598 43.5985 ... \n", "\n", " month_December month_February month_January month_July \\\n", "fecha_hora \n", "24/10/2018 04:00 0 0 0 0 \n", "07/09/2018 05:00 0 0 0 1 \n", "09/01/2017 19:00 0 0 0 0 \n", "05/12/2016 06:00 0 0 0 0 \n", "13/11/2018 10:00 0 0 0 0 \n", "30/06/2018 19:00 0 0 0 0 \n", "21/09/2018 05:00 0 0 0 0 \n", "19/11/2018 14:00 0 0 0 0 \n", "14/02/2017 13:00 0 1 0 0 \n", "26/07/2017 23:00 0 0 0 1 \n", "12/04/2018 07:00 1 0 0 0 \n", "23/04/2018 06:00 0 0 0 0 \n", "21/12/2017 05:00 1 0 0 0 \n", "27/08/2016 04:00 0 0 0 0 \n", "24/01/2017 04:00 0 0 1 0 \n", "06/05/2017 22:00 0 0 0 0 \n", "11/10/2018 05:00 0 0 0 0 \n", "28/11/2016 09:00 0 0 0 0 \n", "02/08/2018 01:00 0 1 0 0 \n", "06/12/2018 21:00 0 0 0 0 \n", "29/03/2018 22:00 0 0 0 0 \n", "26/10/2018 14:00 0 0 0 0 \n", "16/05/2018 01:00 0 0 0 0 \n", "01/11/2016 05:00 0 0 1 0 \n", "10/01/2018 19:00 0 0 0 0 \n", "30/01/2017 03:00 0 0 1 0 \n", "15/10/2016 20:00 0 0 0 0 \n", "11/09/2017 12:00 0 0 0 0 \n", "12/12/2016 13:00 1 0 0 0 \n", "11/10/2017 11:00 0 0 0 0 \n", "... ... ... ... ... \n", "10/09/2017 01:00 0 0 0 0 \n", "06/01/2017 06:00 0 0 0 0 \n", "20/10/2018 13:00 0 0 0 0 \n", "08/02/2017 23:00 0 0 0 0 \n", "20/09/2016 23:00 0 0 0 0 \n", "27/04/2017 21:00 0 0 0 0 \n", "24/09/2016 06:00 0 0 0 0 \n", "09/09/2018 08:00 0 0 0 0 \n", "11/12/2017 06:00 0 0 0 0 \n", "24/07/2018 01:00 0 0 0 1 \n", "27/10/2018 17:00 0 0 0 0 \n", "16/07/2018 02:00 0 0 0 1 \n", "23/02/2017 12:00 0 1 0 0 \n", "18/11/2018 02:00 0 0 0 0 \n", "26/07/2017 20:00 0 0 0 1 \n", "05/10/2018 12:00 0 0 0 0 \n", "10/12/2016 10:00 0 0 0 0 \n", "17/01/2018 21:00 0 0 1 0 \n", "31/12/2016 06:00 1 0 0 0 \n", "09/11/2017 21:00 0 0 0 0 \n", "27/06/2017 23:00 0 0 0 0 \n", "20/06/2018 12:00 0 0 0 0 \n", "15/08/2016 00:00 0 0 0 0 \n", "21/10/2018 07:00 0 0 0 0 \n", "30/06/2017 13:00 0 0 0 0 \n", "08/11/2017 11:00 0 0 0 0 \n", "30/07/2018 09:00 0 0 0 1 \n", "13/03/2017 08:00 0 0 0 0 \n", "29/12/2017 04:00 1 0 0 0 \n", "18/08/2016 19:00 0 0 0 0 \n", "\n", " month_June month_March month_May month_November \\\n", "fecha_hora \n", "24/10/2018 04:00 0 0 0 0 \n", "07/09/2018 05:00 0 0 0 0 \n", "09/01/2017 19:00 0 0 0 0 \n", "05/12/2016 06:00 0 0 1 0 \n", "13/11/2018 10:00 0 0 0 1 \n", "30/06/2018 19:00 1 0 0 0 \n", "21/09/2018 05:00 0 0 0 0 \n", "19/11/2018 14:00 0 0 0 1 \n", "14/02/2017 13:00 0 0 0 0 \n", "26/07/2017 23:00 0 0 0 0 \n", "12/04/2018 07:00 0 0 0 0 \n", "23/04/2018 06:00 0 0 0 0 \n", "21/12/2017 05:00 0 0 0 0 \n", "27/08/2016 04:00 0 0 0 0 \n", "24/01/2017 04:00 0 0 0 0 \n", "06/05/2017 22:00 1 0 0 0 \n", "11/10/2018 05:00 0 0 0 1 \n", "28/11/2016 09:00 0 0 0 1 \n", "02/08/2018 01:00 0 0 0 0 \n", "06/12/2018 21:00 1 0 0 0 \n", "29/03/2018 22:00 0 1 0 0 \n", "26/10/2018 14:00 0 0 0 0 \n", "16/05/2018 01:00 0 0 1 0 \n", "01/11/2016 05:00 0 0 0 0 \n", "10/01/2018 19:00 0 0 0 0 \n", "30/01/2017 03:00 0 0 0 0 \n", "15/10/2016 20:00 0 0 0 0 \n", "11/09/2017 12:00 0 0 0 1 \n", "12/12/2016 13:00 0 0 0 0 \n", "11/10/2017 11:00 0 0 0 1 \n", "... ... ... ... ... \n", "10/09/2017 01:00 0 0 0 0 \n", "06/01/2017 06:00 1 0 0 0 \n", "20/10/2018 13:00 0 0 0 0 \n", "08/02/2017 23:00 0 0 0 0 \n", "20/09/2016 23:00 0 0 0 0 \n", "27/04/2017 21:00 0 0 0 0 \n", "24/09/2016 06:00 0 0 0 0 \n", "09/09/2018 08:00 0 0 0 0 \n", "11/12/2017 06:00 0 0 0 1 \n", "24/07/2018 01:00 0 0 0 0 \n", "27/10/2018 17:00 0 0 0 0 \n", "16/07/2018 02:00 0 0 0 0 \n", "23/02/2017 12:00 0 0 0 0 \n", "18/11/2018 02:00 0 0 0 1 \n", "26/07/2017 20:00 0 0 0 0 \n", "05/10/2018 12:00 0 0 1 0 \n", "10/12/2016 10:00 0 0 0 0 \n", "17/01/2018 21:00 0 0 0 0 \n", "31/12/2016 06:00 0 0 0 0 \n", "09/11/2017 21:00 0 0 0 0 \n", "27/06/2017 23:00 1 0 0 0 \n", "20/06/2018 12:00 1 0 0 0 \n", "15/08/2016 00:00 0 0 0 0 \n", "21/10/2018 07:00 0 0 0 0 \n", "30/06/2017 13:00 1 0 0 0 \n", "08/11/2017 11:00 0 0 0 0 \n", "30/07/2018 09:00 0 0 0 0 \n", "13/03/2017 08:00 0 1 0 0 \n", "29/12/2017 04:00 0 0 0 0 \n", "18/08/2016 19:00 0 0 0 0 \n", "\n", " month_October month_September \n", "fecha_hora \n", "24/10/2018 04:00 1 0 \n", "07/09/2018 05:00 0 0 \n", "09/01/2017 19:00 0 1 \n", "05/12/2016 06:00 0 0 \n", "13/11/2018 10:00 0 0 \n", "30/06/2018 19:00 0 0 \n", "21/09/2018 05:00 0 1 \n", "19/11/2018 14:00 0 0 \n", "14/02/2017 13:00 0 0 \n", "26/07/2017 23:00 0 0 \n", "12/04/2018 07:00 0 0 \n", "23/04/2018 06:00 0 0 \n", "21/12/2017 05:00 0 0 \n", "27/08/2016 04:00 0 0 \n", "24/01/2017 04:00 0 0 \n", "06/05/2017 22:00 0 0 \n", "11/10/2018 05:00 0 0 \n", "28/11/2016 09:00 0 0 \n", "02/08/2018 01:00 0 0 \n", "06/12/2018 21:00 0 0 \n", "29/03/2018 22:00 0 0 \n", "26/10/2018 14:00 1 0 \n", "16/05/2018 01:00 0 0 \n", "01/11/2016 05:00 0 0 \n", "10/01/2018 19:00 1 0 \n", "30/01/2017 03:00 0 0 \n", "15/10/2016 20:00 1 0 \n", "11/09/2017 12:00 0 0 \n", "12/12/2016 13:00 0 0 \n", "11/10/2017 11:00 0 0 \n", "... ... ... \n", "10/09/2017 01:00 1 0 \n", "06/01/2017 06:00 0 0 \n", "20/10/2018 13:00 1 0 \n", "08/02/2017 23:00 0 0 \n", "20/09/2016 23:00 0 1 \n", "27/04/2017 21:00 0 0 \n", "24/09/2016 06:00 0 1 \n", "09/09/2018 08:00 0 1 \n", "11/12/2017 06:00 0 0 \n", "24/07/2018 01:00 0 0 \n", "27/10/2018 17:00 1 0 \n", "16/07/2018 02:00 0 0 \n", "23/02/2017 12:00 0 0 \n", "18/11/2018 02:00 0 0 \n", "26/07/2017 20:00 0 0 \n", "05/10/2018 12:00 0 0 \n", "10/12/2016 10:00 1 0 \n", "17/01/2018 21:00 0 0 \n", "31/12/2016 06:00 0 0 \n", "09/11/2017 21:00 0 1 \n", "27/06/2017 23:00 0 0 \n", "20/06/2018 12:00 0 0 \n", "15/08/2016 00:00 0 0 \n", "21/10/2018 07:00 1 0 \n", "30/06/2017 13:00 0 0 \n", "08/11/2017 11:00 0 0 \n", "30/07/2018 09:00 0 0 \n", "13/03/2017 08:00 0 0 \n", "29/12/2017 04:00 0 0 \n", "18/08/2016 19:00 0 0 \n", "\n", "[15390 rows x 93 columns]" ] }, "execution_count": 117, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X_train" ] }, { "cell_type": "code", "execution_count": 118, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\data.py:625: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.partial_fit(X, y)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\base.py:465: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.fit(X, y, **fit_params).transform(X)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:761: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", " y = column_or_1d(y, warn=True)\n" ] }, { "data": { "text/plain": [ "Pipeline(memory=None,\n", " steps=[('standarscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=0.95, random_state=None,\n", " svd_solver='auto', tol=0.0, whiten=False)), ('regressor', SVR(C=100, cache_size=200, coef0=0.0, degree=3, epsilon=0.1, gamma=0.05,\n", " kernel='rbf', max_iter=-1, shrinking=True, tol=0.001, verbose=False))])" ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svrpipe.fit(X_train, y_train)" ] }, { "cell_type": "code", "execution_count": 119, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\pipeline.py:511: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " Xt = transform.transform(Xt)\n" ] }, { "data": { "text/plain": [ "0.9106459392935141" ] }, "execution_count": 119, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svrpipe.score(X_test, y_test)" ] }, { "cell_type": "code", "execution_count": 121, "metadata": {}, "outputs": [], "source": [ "import pickle\n", "\n", "pickle.dump(svrpipe, open(\"../models/lbrprice_model_svr.pkl\",\"wb\"))" ] }, { "cell_type": "code", "execution_count": 127, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Ph-24Ph-25Ph-26Ph-27Ph-28Ph-29Ph-30Ph-31Ph-32Ph-33...month_Decembermonth_Februarymonth_Januarymonth_Julymonth_Junemonth_Marchmonth_Maymonth_Novembermonth_Octobermonth_September
fecha_hora
09/08/2016 00:0054.846145.198244.712346.299542.942244.355146.344045.682642.667639.0872...0000000001
09/08/2016 01:0052.217954.846145.198244.712346.299542.942244.355146.344045.682642.6676...0000000001
09/08/2016 02:0061.919852.217954.846145.198244.712346.299542.942244.355146.344045.6826...0000000001
09/08/2016 03:0036.810561.919852.217954.846145.198244.712346.299542.942244.355146.3440...0000000001
09/08/2016 04:0034.827436.810561.919852.217954.846145.198244.712346.299542.942244.3551...0000000001
09/08/2016 05:0034.582434.827436.810561.919852.217954.846145.198244.712346.299542.9422...0000000001
09/08/2016 06:0049.448134.582434.827436.810561.919852.217954.846145.198244.712346.2995...0000000001
09/08/2016 07:0055.672149.448134.582434.827436.810561.919852.217954.846145.198244.7123...0000000001
09/08/2016 08:0057.097455.672149.448134.582434.827436.810561.919852.217954.846145.1982...0000000001
09/08/2016 09:0067.036857.097455.672149.448134.582434.827436.810561.919852.217954.8461...0000000001
09/08/2016 10:0054.468167.036857.097455.672149.448134.582434.827436.810561.919852.2179...0000000001
09/08/2016 11:0054.445054.468167.036857.097455.672149.448134.582434.827436.810561.9198...0000000001
09/08/2016 12:0054.025054.445054.468167.036857.097455.672149.448134.582434.827436.8105...0000000001
09/08/2016 13:0056.339254.025054.445054.468167.036857.097455.672149.448134.582434.8274...0000000001
09/08/2016 14:0066.547356.339254.025054.445054.468167.036857.097455.672149.448134.5824...0000000001
09/08/2016 15:0058.873866.547356.339254.025054.445054.468167.036857.097455.672149.4481...0000000001
09/08/2016 16:0060.197358.873866.547356.339254.025054.445054.468167.036857.097455.6721...0000000001
09/08/2016 17:0059.747760.197358.873866.547356.339254.025054.445054.468167.036857.0974...0000000001
09/08/2016 18:0059.934559.747760.197358.873866.547356.339254.025054.445054.468167.0368...0000000001
09/08/2016 19:0056.915459.934559.747760.197358.873866.547356.339254.025054.445054.4681...0000000001
09/08/2016 20:0064.537856.915459.934559.747760.197358.873866.547356.339254.025054.4450...0000000001
09/08/2016 21:0058.552864.537856.915459.934559.747760.197358.873866.547356.339254.0250...0000000001
09/08/2016 22:0058.972358.552864.537856.915459.934559.747760.197358.873866.547356.3392...0000000001
09/08/2016 23:0068.242358.972358.552864.537856.915459.934559.747760.197358.873866.5473...0000000001
10/08/2016 00:0095.326468.242358.972358.552864.537856.915459.934559.747760.197358.8738...0000000010
10/08/2016 01:0082.853295.326468.242358.972358.552864.537856.915459.934559.747760.1973...0000000010
10/08/2016 02:0057.976482.853295.326468.242358.972358.552864.537856.915459.934559.7477...0000000010
10/08/2016 03:0067.640757.976482.853295.326468.242358.972358.552864.537856.915459.9345...0000000010
10/08/2016 04:0066.489267.640757.976482.853295.326468.242358.972358.552864.537856.9154...0000000010
10/08/2016 05:0068.680766.489267.640757.976482.853295.326468.242358.972358.552864.5378...0000000010
..................................................................
10/12/2018 18:0069.670767.034458.597558.943360.247761.771063.158359.973957.904350.2045...0000000010
10/12/2018 19:0073.371269.670767.034458.597558.943360.247761.771063.158359.973957.9043...0000000010
10/12/2018 20:0069.145373.371269.670767.034458.597558.943360.247761.771063.158359.9739...0000000010
10/12/2018 21:0070.011169.145373.371269.670767.034458.597558.943360.247761.771063.1583...0000000010
10/12/2018 22:0066.933270.011169.145373.371269.670767.034458.597558.943360.247761.7710...0000000010
10/12/2018 23:0059.199366.933270.011169.145373.371269.670767.034458.597558.943360.2477...0000000010
11/12/2018 00:0051.859659.199366.933270.011169.145373.371269.670767.034458.597558.9433...0000000100
11/12/2018 01:0047.186351.859659.199366.933270.011169.145373.371269.670767.034458.5975...0000000100
11/12/2018 02:0046.004347.186351.859659.199366.933270.011169.145373.371269.670767.0344...0000000100
11/12/2018 03:0045.048746.004347.186351.859659.199366.933270.011169.145373.371269.6707...0000000100
11/12/2018 04:0045.359545.048746.004347.186351.859659.199366.933270.011169.145373.3712...0000000100
11/12/2018 05:0048.997845.359545.048746.004347.186351.859659.199366.933270.011169.1453...0000000100
11/12/2018 06:0067.777848.997845.359545.048746.004347.186351.859659.199366.933270.0111...0000000100
11/12/2018 07:0080.669067.777848.997845.359545.048746.004347.186351.859659.199366.9332...0000000100
11/12/2018 08:00105.993480.669067.777848.997845.359545.048746.004347.186351.859659.1993...0000000100
11/12/2018 09:00110.8088105.993480.669067.777848.997845.359545.048746.004347.186351.8596...0000000100
11/12/2018 10:00116.1816110.8088105.993480.669067.777848.997845.359545.048746.004347.1863...0000000100
11/12/2018 11:00122.7567116.1816110.8088105.993480.669067.777848.997845.359545.048746.0043...0000000100
11/12/2018 12:00125.5741122.7567116.1816110.8088105.993480.669067.777848.997845.359545.0487...0000000100
11/12/2018 13:00112.8655125.5741122.7567116.1816110.8088105.993480.669067.777848.997845.3595...0000000100
11/12/2018 14:00130.4650112.8655125.5741122.7567116.1816110.8088105.993480.669067.777848.9978...0000000100
11/12/2018 15:00136.3701130.4650112.8655125.5741122.7567116.1816110.8088105.993480.669067.7778...0000000100
11/12/2018 16:00130.1201136.3701130.4650112.8655125.5741122.7567116.1816110.8088105.993480.6690...0000000100
11/12/2018 17:00110.6386130.1201136.3701130.4650112.8655125.5741122.7567116.1816110.8088105.9934...0000000100
11/12/2018 18:00106.4128110.6386130.1201136.3701130.4650112.8655125.5741122.7567116.1816110.8088...0000000100
11/12/2018 19:00129.2578106.4128110.6386130.1201136.3701130.4650112.8655125.5741122.7567116.1816...0000000100
11/12/2018 20:00117.1150129.2578106.4128110.6386130.1201136.3701130.4650112.8655125.5741122.7567...0000000100
11/12/2018 21:00144.8820117.1150129.2578106.4128110.6386130.1201136.3701130.4650112.8655125.5741...0000000100
11/12/2018 22:00103.7000144.8820117.1150129.2578106.4128110.6386130.1201136.3701130.4650112.8655...0000000100
11/12/2018 23:0088.4655103.7000144.8820117.1150129.2578106.4128110.6386130.1201136.3701130.4650...0000000100
\n", "

20520 rows × 93 columns

\n", "
" ], "text/plain": [ " Ph-24 Ph-25 Ph-26 Ph-27 Ph-28 Ph-29 \\\n", "fecha_hora \n", "09/08/2016 00:00 54.8461 45.1982 44.7123 46.2995 42.9422 44.3551 \n", "09/08/2016 01:00 52.2179 54.8461 45.1982 44.7123 46.2995 42.9422 \n", "09/08/2016 02:00 61.9198 52.2179 54.8461 45.1982 44.7123 46.2995 \n", "09/08/2016 03:00 36.8105 61.9198 52.2179 54.8461 45.1982 44.7123 \n", "09/08/2016 04:00 34.8274 36.8105 61.9198 52.2179 54.8461 45.1982 \n", "09/08/2016 05:00 34.5824 34.8274 36.8105 61.9198 52.2179 54.8461 \n", "09/08/2016 06:00 49.4481 34.5824 34.8274 36.8105 61.9198 52.2179 \n", "09/08/2016 07:00 55.6721 49.4481 34.5824 34.8274 36.8105 61.9198 \n", "09/08/2016 08:00 57.0974 55.6721 49.4481 34.5824 34.8274 36.8105 \n", "09/08/2016 09:00 67.0368 57.0974 55.6721 49.4481 34.5824 34.8274 \n", "09/08/2016 10:00 54.4681 67.0368 57.0974 55.6721 49.4481 34.5824 \n", "09/08/2016 11:00 54.4450 54.4681 67.0368 57.0974 55.6721 49.4481 \n", "09/08/2016 12:00 54.0250 54.4450 54.4681 67.0368 57.0974 55.6721 \n", "09/08/2016 13:00 56.3392 54.0250 54.4450 54.4681 67.0368 57.0974 \n", "09/08/2016 14:00 66.5473 56.3392 54.0250 54.4450 54.4681 67.0368 \n", "09/08/2016 15:00 58.8738 66.5473 56.3392 54.0250 54.4450 54.4681 \n", "09/08/2016 16:00 60.1973 58.8738 66.5473 56.3392 54.0250 54.4450 \n", "09/08/2016 17:00 59.7477 60.1973 58.8738 66.5473 56.3392 54.0250 \n", "09/08/2016 18:00 59.9345 59.7477 60.1973 58.8738 66.5473 56.3392 \n", "09/08/2016 19:00 56.9154 59.9345 59.7477 60.1973 58.8738 66.5473 \n", "09/08/2016 20:00 64.5378 56.9154 59.9345 59.7477 60.1973 58.8738 \n", "09/08/2016 21:00 58.5528 64.5378 56.9154 59.9345 59.7477 60.1973 \n", "09/08/2016 22:00 58.9723 58.5528 64.5378 56.9154 59.9345 59.7477 \n", "09/08/2016 23:00 68.2423 58.9723 58.5528 64.5378 56.9154 59.9345 \n", "10/08/2016 00:00 95.3264 68.2423 58.9723 58.5528 64.5378 56.9154 \n", "10/08/2016 01:00 82.8532 95.3264 68.2423 58.9723 58.5528 64.5378 \n", "10/08/2016 02:00 57.9764 82.8532 95.3264 68.2423 58.9723 58.5528 \n", "10/08/2016 03:00 67.6407 57.9764 82.8532 95.3264 68.2423 58.9723 \n", "10/08/2016 04:00 66.4892 67.6407 57.9764 82.8532 95.3264 68.2423 \n", "10/08/2016 05:00 68.6807 66.4892 67.6407 57.9764 82.8532 95.3264 \n", "... ... ... ... ... ... ... \n", "10/12/2018 18:00 69.6707 67.0344 58.5975 58.9433 60.2477 61.7710 \n", "10/12/2018 19:00 73.3712 69.6707 67.0344 58.5975 58.9433 60.2477 \n", "10/12/2018 20:00 69.1453 73.3712 69.6707 67.0344 58.5975 58.9433 \n", "10/12/2018 21:00 70.0111 69.1453 73.3712 69.6707 67.0344 58.5975 \n", "10/12/2018 22:00 66.9332 70.0111 69.1453 73.3712 69.6707 67.0344 \n", "10/12/2018 23:00 59.1993 66.9332 70.0111 69.1453 73.3712 69.6707 \n", "11/12/2018 00:00 51.8596 59.1993 66.9332 70.0111 69.1453 73.3712 \n", "11/12/2018 01:00 47.1863 51.8596 59.1993 66.9332 70.0111 69.1453 \n", "11/12/2018 02:00 46.0043 47.1863 51.8596 59.1993 66.9332 70.0111 \n", "11/12/2018 03:00 45.0487 46.0043 47.1863 51.8596 59.1993 66.9332 \n", "11/12/2018 04:00 45.3595 45.0487 46.0043 47.1863 51.8596 59.1993 \n", "11/12/2018 05:00 48.9978 45.3595 45.0487 46.0043 47.1863 51.8596 \n", "11/12/2018 06:00 67.7778 48.9978 45.3595 45.0487 46.0043 47.1863 \n", "11/12/2018 07:00 80.6690 67.7778 48.9978 45.3595 45.0487 46.0043 \n", "11/12/2018 08:00 105.9934 80.6690 67.7778 48.9978 45.3595 45.0487 \n", "11/12/2018 09:00 110.8088 105.9934 80.6690 67.7778 48.9978 45.3595 \n", "11/12/2018 10:00 116.1816 110.8088 105.9934 80.6690 67.7778 48.9978 \n", "11/12/2018 11:00 122.7567 116.1816 110.8088 105.9934 80.6690 67.7778 \n", "11/12/2018 12:00 125.5741 122.7567 116.1816 110.8088 105.9934 80.6690 \n", "11/12/2018 13:00 112.8655 125.5741 122.7567 116.1816 110.8088 105.9934 \n", "11/12/2018 14:00 130.4650 112.8655 125.5741 122.7567 116.1816 110.8088 \n", "11/12/2018 15:00 136.3701 130.4650 112.8655 125.5741 122.7567 116.1816 \n", "11/12/2018 16:00 130.1201 136.3701 130.4650 112.8655 125.5741 122.7567 \n", "11/12/2018 17:00 110.6386 130.1201 136.3701 130.4650 112.8655 125.5741 \n", "11/12/2018 18:00 106.4128 110.6386 130.1201 136.3701 130.4650 112.8655 \n", "11/12/2018 19:00 129.2578 106.4128 110.6386 130.1201 136.3701 130.4650 \n", "11/12/2018 20:00 117.1150 129.2578 106.4128 110.6386 130.1201 136.3701 \n", "11/12/2018 21:00 144.8820 117.1150 129.2578 106.4128 110.6386 130.1201 \n", "11/12/2018 22:00 103.7000 144.8820 117.1150 129.2578 106.4128 110.6386 \n", "11/12/2018 23:00 88.4655 103.7000 144.8820 117.1150 129.2578 106.4128 \n", "\n", " Ph-30 Ph-31 Ph-32 Ph-33 ... \\\n", "fecha_hora ... \n", "09/08/2016 00:00 46.3440 45.6826 42.6676 39.0872 ... \n", "09/08/2016 01:00 44.3551 46.3440 45.6826 42.6676 ... \n", "09/08/2016 02:00 42.9422 44.3551 46.3440 45.6826 ... \n", "09/08/2016 03:00 46.2995 42.9422 44.3551 46.3440 ... \n", "09/08/2016 04:00 44.7123 46.2995 42.9422 44.3551 ... \n", "09/08/2016 05:00 45.1982 44.7123 46.2995 42.9422 ... \n", "09/08/2016 06:00 54.8461 45.1982 44.7123 46.2995 ... \n", "09/08/2016 07:00 52.2179 54.8461 45.1982 44.7123 ... \n", "09/08/2016 08:00 61.9198 52.2179 54.8461 45.1982 ... \n", "09/08/2016 09:00 36.8105 61.9198 52.2179 54.8461 ... \n", "09/08/2016 10:00 34.8274 36.8105 61.9198 52.2179 ... \n", "09/08/2016 11:00 34.5824 34.8274 36.8105 61.9198 ... \n", "09/08/2016 12:00 49.4481 34.5824 34.8274 36.8105 ... \n", "09/08/2016 13:00 55.6721 49.4481 34.5824 34.8274 ... \n", "09/08/2016 14:00 57.0974 55.6721 49.4481 34.5824 ... \n", "09/08/2016 15:00 67.0368 57.0974 55.6721 49.4481 ... \n", "09/08/2016 16:00 54.4681 67.0368 57.0974 55.6721 ... \n", "09/08/2016 17:00 54.4450 54.4681 67.0368 57.0974 ... \n", "09/08/2016 18:00 54.0250 54.4450 54.4681 67.0368 ... \n", "09/08/2016 19:00 56.3392 54.0250 54.4450 54.4681 ... \n", "09/08/2016 20:00 66.5473 56.3392 54.0250 54.4450 ... \n", "09/08/2016 21:00 58.8738 66.5473 56.3392 54.0250 ... \n", "09/08/2016 22:00 60.1973 58.8738 66.5473 56.3392 ... \n", "09/08/2016 23:00 59.7477 60.1973 58.8738 66.5473 ... \n", "10/08/2016 00:00 59.9345 59.7477 60.1973 58.8738 ... \n", "10/08/2016 01:00 56.9154 59.9345 59.7477 60.1973 ... \n", "10/08/2016 02:00 64.5378 56.9154 59.9345 59.7477 ... \n", "10/08/2016 03:00 58.5528 64.5378 56.9154 59.9345 ... \n", "10/08/2016 04:00 58.9723 58.5528 64.5378 56.9154 ... \n", "10/08/2016 05:00 68.2423 58.9723 58.5528 64.5378 ... \n", "... ... ... ... ... ... \n", "10/12/2018 18:00 63.1583 59.9739 57.9043 50.2045 ... \n", "10/12/2018 19:00 61.7710 63.1583 59.9739 57.9043 ... \n", "10/12/2018 20:00 60.2477 61.7710 63.1583 59.9739 ... \n", "10/12/2018 21:00 58.9433 60.2477 61.7710 63.1583 ... \n", "10/12/2018 22:00 58.5975 58.9433 60.2477 61.7710 ... \n", "10/12/2018 23:00 67.0344 58.5975 58.9433 60.2477 ... \n", "11/12/2018 00:00 69.6707 67.0344 58.5975 58.9433 ... \n", "11/12/2018 01:00 73.3712 69.6707 67.0344 58.5975 ... \n", "11/12/2018 02:00 69.1453 73.3712 69.6707 67.0344 ... \n", "11/12/2018 03:00 70.0111 69.1453 73.3712 69.6707 ... \n", "11/12/2018 04:00 66.9332 70.0111 69.1453 73.3712 ... \n", "11/12/2018 05:00 59.1993 66.9332 70.0111 69.1453 ... \n", "11/12/2018 06:00 51.8596 59.1993 66.9332 70.0111 ... \n", "11/12/2018 07:00 47.1863 51.8596 59.1993 66.9332 ... \n", "11/12/2018 08:00 46.0043 47.1863 51.8596 59.1993 ... \n", "11/12/2018 09:00 45.0487 46.0043 47.1863 51.8596 ... \n", "11/12/2018 10:00 45.3595 45.0487 46.0043 47.1863 ... \n", "11/12/2018 11:00 48.9978 45.3595 45.0487 46.0043 ... \n", "11/12/2018 12:00 67.7778 48.9978 45.3595 45.0487 ... \n", "11/12/2018 13:00 80.6690 67.7778 48.9978 45.3595 ... \n", "11/12/2018 14:00 105.9934 80.6690 67.7778 48.9978 ... \n", "11/12/2018 15:00 110.8088 105.9934 80.6690 67.7778 ... \n", "11/12/2018 16:00 116.1816 110.8088 105.9934 80.6690 ... \n", "11/12/2018 17:00 122.7567 116.1816 110.8088 105.9934 ... \n", "11/12/2018 18:00 125.5741 122.7567 116.1816 110.8088 ... \n", "11/12/2018 19:00 112.8655 125.5741 122.7567 116.1816 ... \n", "11/12/2018 20:00 130.4650 112.8655 125.5741 122.7567 ... \n", "11/12/2018 21:00 136.3701 130.4650 112.8655 125.5741 ... \n", "11/12/2018 22:00 130.1201 136.3701 130.4650 112.8655 ... \n", "11/12/2018 23:00 110.6386 130.1201 136.3701 130.4650 ... \n", "\n", " month_December month_February month_January month_July \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "09/08/2016 05:00 0 0 0 0 \n", "09/08/2016 06:00 0 0 0 0 \n", "09/08/2016 07:00 0 0 0 0 \n", "09/08/2016 08:00 0 0 0 0 \n", "09/08/2016 09:00 0 0 0 0 \n", "09/08/2016 10:00 0 0 0 0 \n", "09/08/2016 11:00 0 0 0 0 \n", "09/08/2016 12:00 0 0 0 0 \n", "09/08/2016 13:00 0 0 0 0 \n", "09/08/2016 14:00 0 0 0 0 \n", "09/08/2016 15:00 0 0 0 0 \n", "09/08/2016 16:00 0 0 0 0 \n", "09/08/2016 17:00 0 0 0 0 \n", "09/08/2016 18:00 0 0 0 0 \n", "09/08/2016 19:00 0 0 0 0 \n", "09/08/2016 20:00 0 0 0 0 \n", "09/08/2016 21:00 0 0 0 0 \n", "09/08/2016 22:00 0 0 0 0 \n", "09/08/2016 23:00 0 0 0 0 \n", "10/08/2016 00:00 0 0 0 0 \n", "10/08/2016 01:00 0 0 0 0 \n", "10/08/2016 02:00 0 0 0 0 \n", "10/08/2016 03:00 0 0 0 0 \n", "10/08/2016 04:00 0 0 0 0 \n", "10/08/2016 05:00 0 0 0 0 \n", "... ... ... ... ... \n", "10/12/2018 18:00 0 0 0 0 \n", "10/12/2018 19:00 0 0 0 0 \n", "10/12/2018 20:00 0 0 0 0 \n", "10/12/2018 21:00 0 0 0 0 \n", "10/12/2018 22:00 0 0 0 0 \n", "10/12/2018 23:00 0 0 0 0 \n", "11/12/2018 00:00 0 0 0 0 \n", "11/12/2018 01:00 0 0 0 0 \n", "11/12/2018 02:00 0 0 0 0 \n", "11/12/2018 03:00 0 0 0 0 \n", "11/12/2018 04:00 0 0 0 0 \n", "11/12/2018 05:00 0 0 0 0 \n", "11/12/2018 06:00 0 0 0 0 \n", "11/12/2018 07:00 0 0 0 0 \n", "11/12/2018 08:00 0 0 0 0 \n", "11/12/2018 09:00 0 0 0 0 \n", "11/12/2018 10:00 0 0 0 0 \n", "11/12/2018 11:00 0 0 0 0 \n", "11/12/2018 12:00 0 0 0 0 \n", "11/12/2018 13:00 0 0 0 0 \n", "11/12/2018 14:00 0 0 0 0 \n", "11/12/2018 15:00 0 0 0 0 \n", "11/12/2018 16:00 0 0 0 0 \n", "11/12/2018 17:00 0 0 0 0 \n", "11/12/2018 18:00 0 0 0 0 \n", "11/12/2018 19:00 0 0 0 0 \n", "11/12/2018 20:00 0 0 0 0 \n", "11/12/2018 21:00 0 0 0 0 \n", "11/12/2018 22:00 0 0 0 0 \n", "11/12/2018 23:00 0 0 0 0 \n", "\n", " month_June month_March month_May month_November \\\n", "fecha_hora \n", "09/08/2016 00:00 0 0 0 0 \n", "09/08/2016 01:00 0 0 0 0 \n", "09/08/2016 02:00 0 0 0 0 \n", "09/08/2016 03:00 0 0 0 0 \n", "09/08/2016 04:00 0 0 0 0 \n", "09/08/2016 05:00 0 0 0 0 \n", "09/08/2016 06:00 0 0 0 0 \n", "09/08/2016 07:00 0 0 0 0 \n", "09/08/2016 08:00 0 0 0 0 \n", "09/08/2016 09:00 0 0 0 0 \n", "09/08/2016 10:00 0 0 0 0 \n", "09/08/2016 11:00 0 0 0 0 \n", "09/08/2016 12:00 0 0 0 0 \n", "09/08/2016 13:00 0 0 0 0 \n", "09/08/2016 14:00 0 0 0 0 \n", "09/08/2016 15:00 0 0 0 0 \n", "09/08/2016 16:00 0 0 0 0 \n", "09/08/2016 17:00 0 0 0 0 \n", "09/08/2016 18:00 0 0 0 0 \n", "09/08/2016 19:00 0 0 0 0 \n", "09/08/2016 20:00 0 0 0 0 \n", "09/08/2016 21:00 0 0 0 0 \n", "09/08/2016 22:00 0 0 0 0 \n", "09/08/2016 23:00 0 0 0 0 \n", "10/08/2016 00:00 0 0 0 0 \n", "10/08/2016 01:00 0 0 0 0 \n", "10/08/2016 02:00 0 0 0 0 \n", "10/08/2016 03:00 0 0 0 0 \n", "10/08/2016 04:00 0 0 0 0 \n", "10/08/2016 05:00 0 0 0 0 \n", "... ... ... ... ... \n", "10/12/2018 18:00 0 0 0 0 \n", "10/12/2018 19:00 0 0 0 0 \n", "10/12/2018 20:00 0 0 0 0 \n", "10/12/2018 21:00 0 0 0 0 \n", "10/12/2018 22:00 0 0 0 0 \n", "10/12/2018 23:00 0 0 0 0 \n", "11/12/2018 00:00 0 0 0 1 \n", "11/12/2018 01:00 0 0 0 1 \n", "11/12/2018 02:00 0 0 0 1 \n", "11/12/2018 03:00 0 0 0 1 \n", "11/12/2018 04:00 0 0 0 1 \n", "11/12/2018 05:00 0 0 0 1 \n", "11/12/2018 06:00 0 0 0 1 \n", "11/12/2018 07:00 0 0 0 1 \n", "11/12/2018 08:00 0 0 0 1 \n", "11/12/2018 09:00 0 0 0 1 \n", "11/12/2018 10:00 0 0 0 1 \n", "11/12/2018 11:00 0 0 0 1 \n", "11/12/2018 12:00 0 0 0 1 \n", "11/12/2018 13:00 0 0 0 1 \n", "11/12/2018 14:00 0 0 0 1 \n", "11/12/2018 15:00 0 0 0 1 \n", "11/12/2018 16:00 0 0 0 1 \n", "11/12/2018 17:00 0 0 0 1 \n", "11/12/2018 18:00 0 0 0 1 \n", "11/12/2018 19:00 0 0 0 1 \n", "11/12/2018 20:00 0 0 0 1 \n", "11/12/2018 21:00 0 0 0 1 \n", "11/12/2018 22:00 0 0 0 1 \n", "11/12/2018 23:00 0 0 0 1 \n", "\n", " month_October month_September \n", "fecha_hora \n", "09/08/2016 00:00 0 1 \n", "09/08/2016 01:00 0 1 \n", "09/08/2016 02:00 0 1 \n", "09/08/2016 03:00 0 1 \n", "09/08/2016 04:00 0 1 \n", "09/08/2016 05:00 0 1 \n", "09/08/2016 06:00 0 1 \n", "09/08/2016 07:00 0 1 \n", "09/08/2016 08:00 0 1 \n", "09/08/2016 09:00 0 1 \n", "09/08/2016 10:00 0 1 \n", "09/08/2016 11:00 0 1 \n", "09/08/2016 12:00 0 1 \n", "09/08/2016 13:00 0 1 \n", "09/08/2016 14:00 0 1 \n", "09/08/2016 15:00 0 1 \n", "09/08/2016 16:00 0 1 \n", "09/08/2016 17:00 0 1 \n", "09/08/2016 18:00 0 1 \n", "09/08/2016 19:00 0 1 \n", "09/08/2016 20:00 0 1 \n", "09/08/2016 21:00 0 1 \n", "09/08/2016 22:00 0 1 \n", "09/08/2016 23:00 0 1 \n", "10/08/2016 00:00 1 0 \n", "10/08/2016 01:00 1 0 \n", "10/08/2016 02:00 1 0 \n", "10/08/2016 03:00 1 0 \n", "10/08/2016 04:00 1 0 \n", "10/08/2016 05:00 1 0 \n", "... ... ... \n", "10/12/2018 18:00 1 0 \n", "10/12/2018 19:00 1 0 \n", "10/12/2018 20:00 1 0 \n", "10/12/2018 21:00 1 0 \n", "10/12/2018 22:00 1 0 \n", "10/12/2018 23:00 1 0 \n", "11/12/2018 00:00 0 0 \n", "11/12/2018 01:00 0 0 \n", "11/12/2018 02:00 0 0 \n", "11/12/2018 03:00 0 0 \n", "11/12/2018 04:00 0 0 \n", "11/12/2018 05:00 0 0 \n", "11/12/2018 06:00 0 0 \n", "11/12/2018 07:00 0 0 \n", "11/12/2018 08:00 0 0 \n", "11/12/2018 09:00 0 0 \n", "11/12/2018 10:00 0 0 \n", "11/12/2018 11:00 0 0 \n", "11/12/2018 12:00 0 0 \n", "11/12/2018 13:00 0 0 \n", "11/12/2018 14:00 0 0 \n", "11/12/2018 15:00 0 0 \n", "11/12/2018 16:00 0 0 \n", "11/12/2018 17:00 0 0 \n", "11/12/2018 18:00 0 0 \n", "11/12/2018 19:00 0 0 \n", "11/12/2018 20:00 0 0 \n", "11/12/2018 21:00 0 0 \n", "11/12/2018 22:00 0 0 \n", "11/12/2018 23:00 0 0 \n", "\n", "[20520 rows x 93 columns]" ] }, "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X" ] }, { "cell_type": "code", "execution_count": 128, "metadata": {}, "outputs": [], "source": [ "X2 = X.copy()" ] }, { "cell_type": "code", "execution_count": 133, "metadata": {}, "outputs": [], "source": [ "X2['day_of_year'] = pd.to_datetime(X.index)" ] }, { "cell_type": "code", "execution_count": 134, "metadata": {}, "outputs": [], "source": [ "X2['day_of_year'] = X2.day_of_year.dt.dayofyear" ] }, { "cell_type": "code", "execution_count": 135, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Training features/target: (15390, 94) (15390,)\n", "Testing freatures/targe: (5130, 94) (5130,)\n" ] } ], "source": [ "X_train_2, X_test_2, y_train_2, y_test_2 = train_test_split(X2,y, random_state = 1)\n", "print(\"Training features/target: \", X_train_2.shape, y_train_2.shape)\n", "print(\"Testing freatures/targe: \", X_test_2.shape, y_test_2.shape)" ] }, { "cell_type": "code", "execution_count": 137, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(15390, 94)" ] }, "execution_count": 137, "metadata": {}, "output_type": "execute_result" } ], "source": [ "X_train_2.shape" ] }, { "cell_type": "code", "execution_count": 138, "metadata": {}, "outputs": [], "source": [ "svrpipe2 = svrpipe" ] }, { "cell_type": "code", "execution_count": 140, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\data.py:625: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.partial_fit(X, y)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\base.py:465: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " return self.fit(X, y, **fit_params).transform(X)\n", "C:\\anaconda3\\lib\\site-packages\\sklearn\\utils\\validation.py:761: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", " y = column_or_1d(y, warn=True)\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Wall time: 3min 12s\n" ] }, { "data": { "text/plain": [ "Pipeline(memory=None,\n", " steps=[('standarscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=0.95, random_state=None,\n", " svd_solver='auto', tol=0.0, whiten=False)), ('regressor', SVR(C=100, cache_size=200, coef0=0.0, degree=3, epsilon=0.1, gamma=0.05,\n", " kernel='rbf', max_iter=-1, shrinking=True, tol=0.001, verbose=False))])" ] }, "execution_count": 140, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%%time\n", "svrpipe2.fit(X_train_2, y_train)" ] }, { "cell_type": "code", "execution_count": 143, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\anaconda3\\lib\\site-packages\\sklearn\\pipeline.py:511: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by StandardScaler.\n", " Xt = transform.transform(Xt)\n" ] }, { "data": { "text/plain": [ "0.9106833022371192" ] }, "execution_count": 143, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svrpipe2.score(X_test_2, y_test)" ] }, { "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.7.1" }, "toc": { "base_numbering": 1, "nav_menu": { "height": "135px", "width": "538px" }, "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": false } }, "nbformat": 4, "nbformat_minor": 2 }