{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\"Open" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Regressione: Come Scegliere il modello" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Questo notebook fornisce un esempio che permette di comparare il comportamento di diversi regressori e scegliere il migliore. Al fine di fare questa scelta viene utilizzata la cross-validation che permette di capire quanto il regressore รจ robusto a variazioni nel train-test set.\n", "\n", "\n", "1. Caricare il dataset (di regressione). \n", "2. Comparare i modelli\n", "3. Scegliere il modello migliore\n", "4. Applicare il modello allenato a un nuovo set di dati" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importare le librerie" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from sklearn.preprocessing import StandardScaler\n", "from sklearn.preprocessing import MinMaxScaler\n", "from sklearn.model_selection import train_test_split\n", "from sklearn import linear_model\n", "from sklearn.metrics import mean_squared_error # MSE\n", "from sklearn.metrics import mean_absolute_error # MAE\n", "from sklearn.metrics import median_absolute_error # MedAE\n", "from sklearn.preprocessing import PolynomialFeatures\n", "from sklearn.decomposition import PCA\n", "from sklearn.model_selection import KFold\n", "from sklearn.model_selection import cross_val_score\n", "from sklearn.linear_model import RANSACRegressor, SGDRegressor, HuberRegressor, TheilSenRegressor\n", "from sklearn.linear_model import LinearRegression\n", "from sklearn.linear_model import Lasso, Ridge\n", "from sklearn.linear_model import ElasticNet\n", "from sklearn.tree import DecisionTreeRegressor\n", "from sklearn.neighbors import KNeighborsRegressor\n", "from sklearn.svm import SVR\n", "from sklearn.ensemble import AdaBoostRegressor\n", "from sklearn.ensemble import GradientBoostingRegressor\n", "from sklearn.ensemble import RandomForestRegressor\n", "from sklearn.ensemble import ExtraTreesRegressor\n", "import seaborn as sn\n", "import matplotlib.pyplot as plt\n", "import random\n", "import numpy as np\n", "import plotly.graph_objects as go\n", "import pickle\n", "import json\n", "from sklearn.pipeline import Pipeline\n", "import pandas as pd\n", "from sklearn import datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1. Caricare il dataset\n", "Assumiamo che l'ultima colonna del dataset sia il valore di target e che il dataset contenga come input solo valori numerici." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "def load_dataset(name=\"boston\"):\n", " datasets_list = [\"boston\", \"diabetes\"] #,\"tips\"]\n", " chosen_dataset = name #\"boston\"\n", "\n", " boston = datasets.load_boston()\n", " df_boston = pd.DataFrame(boston.data,columns=boston.feature_names)\n", " df_boston[\"price\"] = boston.target\n", "\n", " diabetes = datasets.load_diabetes()\n", " df_diabetes = pd.DataFrame(diabetes.data,columns=diabetes.feature_names)\n", " df_diabetes[\"desease\"] = diabetes.target\n", " df_diabetes = df_diabetes.round(decimals=5)\n", "\n", " #df_nuovo_dataset = pd.read_csv(\"https://docs.google.com/spreadsheets/d/e/2PACX-1vSqHhx2kS9gCNmI04yksqTP2PRsT6ifTU2DLokKs3Y6KgcSGIAL7_4t_q_8kNhVkFA0xD2nt7hn_w-5/pub?output=csv\")\n", "\n", " dict_datasets = {\n", " \"boston\": df_boston,\n", " \"diabetes\": df_diabetes,\n", " # \"nuovo\" : df_nuovo_dataset\n", " } \n", " df = dict_datasets[chosen_dataset]#.head(10)\n", " df = df.dropna()\n", "\n", " #print(df.head())\n", " X = df.iloc[:,0:-1].values # Input: dalla prima alla penultima colonna\n", " Y = df.iloc[:,-1].values # Target: utlima colonna\n", "\n", " return X,Y,df" ] }, { "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", "
CRIMZNINDUSCHASNOXRMAGEDISRADTAXPTRATIOBLSTATprice
00.0063218.02.310.00.5386.57565.24.09001.0296.015.3396.904.9824.0
10.027310.07.070.00.4696.42178.94.96712.0242.017.8396.909.1421.6
20.027290.07.070.00.4697.18561.14.96712.0242.017.8392.834.0334.7
30.032370.02.180.00.4586.99845.86.06223.0222.018.7394.632.9433.4
40.069050.02.180.00.4587.14754.26.06223.0222.018.7396.905.3336.2
\n", "
" ], "text/plain": [ " CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX \\\n", "0 0.00632 18.0 2.31 0.0 0.538 6.575 65.2 4.0900 1.0 296.0 \n", "1 0.02731 0.0 7.07 0.0 0.469 6.421 78.9 4.9671 2.0 242.0 \n", "2 0.02729 0.0 7.07 0.0 0.469 7.185 61.1 4.9671 2.0 242.0 \n", "3 0.03237 0.0 2.18 0.0 0.458 6.998 45.8 6.0622 3.0 222.0 \n", "4 0.06905 0.0 2.18 0.0 0.458 7.147 54.2 6.0622 3.0 222.0 \n", "\n", " PTRATIO B LSTAT price \n", "0 15.3 396.90 4.98 24.0 \n", "1 17.8 396.90 9.14 21.6 \n", "2 17.8 392.83 4.03 34.7 \n", "3 18.7 394.63 2.94 33.4 \n", "4 18.7 396.90 5.33 36.2 " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "X,Y,df = load_dataset(name=\"boston\")\n", "display(df.head())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 2. Comparare i modelli" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "def validate(Y_test,Y_pred,name):\n", " mse = mean_squared_error(Y_test,Y_pred)\n", " rmse = np.sqrt(mse)\n", " mae = mean_absolute_error(Y_test,Y_pred)\n", " medae = median_absolute_error(Y_test,Y_pred)\n", " print(\"[\" + name + \"]\" + \" MSE: \", round(mse,4), \"RMSE : \", round(rmse,4), \"MAE: \", round(mae,4), \"MedAE: \", round(medae,4))\n", "\n", "def compare_models(X,Y):\n", " # Split data into training and validation set\n", " #X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.01, shuffle=True, random_state=0) \n", " #print(\"Shapes: X_train: \", X_train.shape, \"Y_train: \", Y_train.shape, \"X_test: \", X_test.shape, \"Y_test\", Y_test.shape)\n", " #print(\"Metric : negative mean square error (MSE)\")\n", "\n", " # Scaling\n", " sc = StandardScaler()\n", " sc.fit(X)\n", " X_train = sc.transform(X)\n", " Y_train = Y\n", " #X_test = sc.transform(X_test)\n", "\n", " # PCA\n", " '''\n", " pc = PCA(n_components=0.95)\n", " pc.fit(X_train)\n", " X_train = pc.transform(X_train)\n", " X_test = pc.transform(X_test)\n", " print (pc.explained_variance_)\n", " print (pc.explained_variance_ratio_)\n", " '''\n", " # Polinomial degree\n", " '''\n", " poly = PolynomialFeatures(degree=2)\n", " poly.fit(X_train)\n", " X_train = poly.transform(X_train)\n", " X_test = poly.transform(X_test)\n", " '''\n", "\n", " # user variables to tune\n", " seed = 5\n", " folds = 20\n", " metric = \"neg_mean_squared_error\"\n", "\n", " # hold different regression models in a single dictionary\n", " models = {}\n", " models[\"Linear\"] = LinearRegression()\n", " #models[\"RANSAC\"] = RANSACRegressor()\n", " models[\"Huber\"] = HuberRegressor(max_iter=1000)\n", " models[\"TheilSen\"] = TheilSenRegressor()\n", " #models[\"SGD\"] = SGDRegressor(max_iter=500,penalty=None, eta0=0.01, tol=0.00001)\n", " models[\"Ridge\"] = Ridge()\n", " models[\"Lasso\"] = Lasso()\n", " models[\"ElasticNet\"] = ElasticNet()\n", " models[\"KNN\"] = KNeighborsRegressor(n_neighbors=5)\n", " models[\"DecisionTree\"] = DecisionTreeRegressor()\n", " models[\"SVR\"] = SVR(gamma=\"auto\")\n", " models[\"AdaBoost\"] = AdaBoostRegressor(n_estimators=50)\n", " models[\"GradientBoost\"] = GradientBoostingRegressor(n_estimators=100)\n", " models[\"RandomForest\"] = RandomForestRegressor(n_estimators=100)\n", " models[\"ExtraTrees\"] = ExtraTreesRegressor(n_estimators=100)\n", "\n", " # 10-fold cross validation for each model\n", " model_results = []\n", " model_names = []\n", " for model_name in models:\n", " model = models[model_name]\n", " k_fold = KFold(n_splits=folds, random_state=seed,shuffle=True)\n", " results = cross_val_score(model, X_train, Y_train, cv=k_fold, scoring=metric)\n", "\n", " model_results.append(results)\n", " model_names.append(model_name)\n", " print(\"{}: {}, {}\".format(model_name, round(results.mean(), 3), round(results.std(), 3)))\n", "\n", " fig = go.Figure()\n", " for name,res in zip(model_names,model_results): \n", " fig.add_trace(go.Box(y=res,name=name, boxpoints='all'))\n", " #fig.show()\n", " return fig" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 771 }, "colab_type": "code", "id": "WrtqA2hktXTO", "outputId": "f482b94d-0729-4126-f8ee-00f33bcd5ccd" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Linear: -23.533, 10.945\n", "Huber: -25.031, 14.541\n", "TheilSen: -37.511, 28.329\n", "Ridge: -23.524, 10.984\n", "Lasso: -29.188, 14.094\n", "ElasticNet: -30.867, 16.12\n", "KNN: -20.13, 15.229\n", "DecisionTree: -23.841, 20.706\n", "SVR: -27.564, 19.139\n", "AdaBoost: -14.025, 6.407\n", "GradientBoost: -8.321, 4.745\n", "RandomForest: -10.23, 6.179\n", "ExtraTrees: -9.024, 5.04\n" ] }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "boxpoints": "all", "name": "Linear", "type": "box", "y": [ -24.628520127679437, -20.70473687890746, -16.307317591708095, -19.75472149517848, -42.59541683506843, -53.934699021627395, -18.810299177158218, -21.18361208853076, -11.266363246398173, -12.986874694193055, -28.170937082281174, -13.003424352180138, -13.325819770039889, -36.57815075786528, -23.860041405979004, -27.34535156522036, -21.320316838227885, -35.52853908793986, -11.842420427548337, -17.517757455734692 ] }, { "boxpoints": "all", "name": "Huber", "type": "box", "y": [ -25.69809956600875, -16.596486839134005, -19.822121828283095, -19.212947816411507, -56.23631631863555, -64.69561908589033, -24.922447892006197, -25.388571055673818, -11.431280694429608, -12.426758294081644, -22.200748557539136, -11.645475015323957, -10.110937913104626, -40.55100085514964, -26.922671424087593, -22.80439864821577, -19.331003924678477, -41.8569941916173, -12.995584265875689, -15.77353242650251 ] }, { "boxpoints": "all", "name": "TheilSen", "type": "box", "y": [ -32.44055315085499, -18.484048745896857, -27.770990403351846, -53.30862374935865, -62.08856299181657, -141.6591492044631, -36.07590361403228, -42.86546172358887, -13.795500688097174, -21.72124787685347, -32.52614600273071, -12.327910931058826, -17.776708905029615, -48.73822740498476, -34.010502107252826, -26.124667368575093, -18.509553050587975, -66.58573428719015, -20.615301635018714, -22.789513633426186 ] }, { "boxpoints": "all", "name": "Ridge", "type": "box", "y": [ -24.533099310014016, -20.6133200720317, -16.333929384531157, -19.69687087356541, -42.75021380826001, -54.06964116233409, -18.851963522879693, -21.250723918088088, -11.239813912495231, -12.900273076734864, -28.01787822698323, -13.011103571870054, -13.25227771244833, -36.55807034535107, -23.88761672614403, -27.300784163294416, -21.24631621370817, -35.602107553671516, -11.863341474036783, -17.50780424476169 ] }, { "boxpoints": "all", "name": "Lasso", "type": "box", "y": [ -23.84245810066819, -20.303898855196845, -19.83510592765078, -35.52493553122884, -54.23426828982151, -69.70736597044524, -22.912301056018304, -30.83565353091683, -17.66117577749965, -17.528554646545917, -26.668216845729457, -17.634896757811195, -16.152691417671107, -43.13587373877294, -22.08599332521715, -31.90246904886162, -19.559678378770972, -49.04411262061072, -19.31069029482865, -25.878055262531262 ] }, { "boxpoints": "all", "name": "ElasticNet", "type": "box", "y": [ -20.587213591126815, -18.321695146935724, -24.78221714268254, -36.880937334553806, -58.52099550035564, -78.87271547704651, -21.8498974118129, -37.077968431106235, -17.732798186858258, -18.27036239247018, -29.90669364467877, -17.15743587949498, -16.981332035492937, -47.925028238452654, -24.811943621929505, -30.664472983982954, -17.282090622100434, -49.53863588854101, -21.136745559553923, -29.03396850072698 ] }, { "boxpoints": "all", "name": "KNN", "type": "box", "y": [ -12.752646153846152, -8.81669230769231, -17.047800000000002, -29.656569230769232, -23.89064615384615, -62.395507692307696, -9.425056000000001, -27.799376, -9.702784, -8.722304000000006, -31.905583999999994, -9.651648000000009, -12.083727999999999, -49.109264, -8.768687999999996, -11.226847999999997, -11.055423999999995, -40.746064000000004, -5.513471999999999, -12.325136000000008 ] }, { "boxpoints": "all", "name": "DecisionTree", "type": "box", "y": [ -19.90346153846153, -19.675769230769227, -45.07230769230769, -14.425769230769236, -26.204230769230776, -37.33192307692308, -15.359600000000006, -16.8248, -5.454000000000002, -8.050799999999999, -12.706799999999996, -13.640799999999997, -60.8844, -10.035599999999999, -26.5168, -13.444, -11.815199999999995, -93.15280000000001, -16.553599999999996, -9.769600000000002 ] }, { "boxpoints": "all", "name": "SVR", "type": "box", "y": [ -10.88926715164833, -17.94292036188994, -25.2517372001587, -52.704311275679984, -50.227328708262306, -84.6021939980211, -9.536964226794614, -35.74724628191685, -16.69782227398693, -10.012474918344921, -27.795150373826438, -12.428562385271897, -14.434575200781014, -46.83560773711452, -17.764854131695856, -20.866103649006973, -8.912812239191464, -46.85517240895311, -18.674609280835636, -23.105048616691278 ] }, { "boxpoints": "all", "name": "AdaBoost", "type": "box", "y": [ -11.469528552171644, -9.150290736544761, -20.243799107093455, -11.830041033959578, -22.585449646107367, -11.820453447792486, -7.848855811817353, -10.891884621511792, -9.088257532237645, -8.687606281152062, -16.52010788987207, -15.12909761962886, -8.403809443615076, -25.896649963222636, -11.534980582940978, -13.294780243434422, -10.71989124237797, -32.3875945122296, -8.277602827742351, -14.712162205965875 ] }, { "boxpoints": "all", "name": "GradientBoost", "type": "box", "y": [ -17.07386289354867, -6.02625137947166, -5.775514161338557, -4.789812542411252, -7.318766693267729, -5.782784014026115, -8.646890078123842, -5.9068749776449, -4.2682072096536094, -4.801529973111102, -6.611073821566991, -8.378709939196579, -5.268771689524435, -9.716215262240478, -8.060763409269882, -9.13096773106273, -9.4690850504631, -25.26161392390116, -6.392506676884674, -7.731289181513627 ] }, { "boxpoints": "all", "name": "RandomForest", "type": "box", "y": [ -18.43093050000003, -6.0036475769230675, -10.476475153846149, -6.779547269230755, -12.386887615384602, -15.585284423076898, -10.264766159999986, -6.704642039999999, -3.7135565600000047, -5.26340892, -7.498878239999999, -11.069640800000034, -10.261407840000018, -9.776620760000013, -8.064817439999993, -6.458951360000001, -9.507955120000007, -32.64936396000002, -6.483526479999991, -7.21038107999998 ] }, { "boxpoints": "all", "name": "ExtraTrees", "type": "box", "y": [ -14.575659461538457, -4.374274269230759, -8.746017346153833, -6.3358366538461155, -8.675199884615365, -9.458495961538448, -8.706281599999986, -9.065658359999988, -4.871766760000002, -4.727446040000007, -7.798893759999999, -8.750368480000034, -7.242528760000002, -25.428066439999984, -8.817044199999986, -4.604326759999991, -7.411757080000009, -18.71544600000001, -4.5179885999999945, -7.6605703599999915 ] } ], "layout": { "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig_compare_models = compare_models(X,Y)\n", "fig_compare_models.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 3. Scegliere il modello migliore" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "def plot_fig(Ys, names):\n", " # Ys list of output to plot [Y_real, Y_pred]\n", " n = np.linspace(0,len(Ys[0]), len(Ys[0]), dtype=int)\n", " fig = go.Figure()\n", " for yh,nm in zip(Ys,names):\n", " fig.add_trace(go.Scatter(x=n, y=yh,\n", " mode='lines',#mode='lines+markers',\n", " name=nm))\n", " fig.update_layout(\n", " hovermode = \"x\",\n", " paper_bgcolor = \"rgb(0,0,0)\" ,\n", " plot_bgcolor = \"rgb(10,10,10)\" , \n", " title=dict(\n", " x = 0.5,\n", " text = \"Risultati\",\n", " font=dict(\n", " size = 20,\n", " color = \"rgb(255,255,255)\"\n", " )\n", " )\n", " )\n", " return fig\n", "\n", "def train(X,Y,selected=\"Linear\", modelName='best_model.sav'):\n", " max_val = -10000000\n", " n_iter = 20\n", " R2_train_max = 0\n", " R2_test_max = 0\n", " for i in range(0,n_iter):\n", " X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.10, shuffle=True) \n", "\n", " # Scaling\n", " #sc = StandardScaler()\n", " #sc.fit(X_train)\n", " #X_train = sc.transform(X_train)\n", " #X_test = sc.transform(X_test)\n", "\n", " # create and fit the best regression model\n", " seed =5\n", " models = {}\n", " models[\"Linear\"] = LinearRegression()\n", " #models[\"RANSAC\"] = RANSACRegressor()\n", " models[\"Huber\"] = HuberRegressor(max_iter=1000)\n", " models[\"TheilSen\"] = TheilSenRegressor()\n", " #models[\"SGD\"] = SGDRegressor(max_iter=500,penalty=None, eta0=0.01, tol=0.00001)\n", " models[\"Ridge\"] = Ridge()\n", " models[\"Lasso\"] = Lasso()\n", " models[\"ElasticNet\"] = ElasticNet()\n", " models[\"KNN\"] = KNeighborsRegressor()\n", " models[\"DecisionTree\"] = DecisionTreeRegressor()\n", " models[\"SVR\"] = SVR()\n", " models[\"AdaBoost\"] = AdaBoostRegressor()\n", " models[\"GradientBoost\"] = GradientBoostingRegressor()\n", " models[\"RandomForest\"] = RandomForestRegressor()\n", " models[\"ExtraTrees\"] = ExtraTreesRegressor()\n", " \n", " best_model = models[selected]\n", "\n", " # Logistic Regression\n", " pipeline = Pipeline([\n", " (\"sc\", StandardScaler()),\n", " #(\"pca\", PCA(n_components=0.98)),\n", " (\"reg\", best_model),\n", " ])\n", " pipeline.fit(X_train, Y_train)\n", " \n", " #best_model.fit(X_train, Y_train)\n", "\n", " # make predictions using the model (train and test)\n", " Y_test_pred = pipeline.predict(X_test)\n", " Y_train_pred = pipeline.predict(X_train)\n", " #print(\"[INFO] MSE : {}\".format(round(mean_squared_error(Y_test, Y_test_pred), 3)))\n", "\n", " # R2 score coefficient of determination (quanto gli input influscono sulla predizione)\n", " # 0 male 1 bene\n", " #validate(Y_train,Y_train_pred,name=\"Training\")\n", " R2_train = pipeline.score(X_train, Y_train)\n", " #print(\"[Training] R2 Score: \", round(R2_train,3))\n", "\n", " #validate(Y_test,Y_test_pred,name=\"Test\")\n", " R2_test = pipeline.score(X_test, Y_test)\n", " #print(\"[Test] R2 Score: \", round(R2_test,3))\n", "\n", " if np.abs(R2_test)>max_val:\n", " # Save model\n", " R2_train_max = R2_train\n", " R2_test_max = R2_test\n", " pickle.dump(pipeline, open(modelName, 'wb'))\n", " max_val = np.abs(R2_test)\n", " fig_train = plot_fig([Y_train,Y_train_pred],[\"Train Real\", \"Train Predicted\"])\n", " fig_test = plot_fig([Y_test,Y_test_pred],[\"Test Real\",\"Test Predicted\"])\n", " \n", " print( \"Best: [Training] R2 Score: \", round(R2_train_max,3))\n", " print(\"Best: [Test] R2 Score: \", round(R2_test_max,3))\n", " return fig_train,fig_test" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "colab": {}, "colab_type": "code", "id": "qKA8Y9tAtWFL" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Best: [Training] R2 Score: 0.976\n", "Best: [Test] R2 Score: 0.947\n" ] }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "lines", "name": "Train Real", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 455 ], "y": [ 19.6, 18.5, 28.4, 25, 50, 14.1, 17.2, 24.6, 41.3, 19.4, 8.5, 31.6, 17.2, 7.2, 8.8, 20.3, 30.8, 34.6, 22.3, 13.4, 29.4, 21.7, 11.8, 19.3, 19.4, 15.2, 20.6, 21.4, 16.5, 24.1, 19.1, 29.6, 36.5, 25, 8.4, 23.9, 50, 19.2, 14.9, 24.3, 29.8, 26.6, 20.9, 30.5, 16.1, 22.5, 21, 12.3, 8.8, 32, 18.8, 50, 15.4, 20.5, 10.2, 13.9, 22.9, 43.5, 20.4, 23, 22.4, 22.2, 20.7, 31.5, 22.6, 17.1, 19.1, 12.5, 19.4, 23.2, 13.1, 7, 13.4, 19.9, 20.6, 13.1, 22.7, 23.7, 16, 20.2, 19.5, 20.8, 8.3, 21, 31.7, 9.7, 25, 20.2, 20, 13.8, 21.6, 13.4, 20.8, 18.2, 23.1, 20, 25, 23.4, 20.4, 21.7, 28.2, 20.3, 33.1, 19.7, 22.6, 17.1, 19.6, 21.1, 32.7, 33.2, 21.8, 10.5, 13.8, 14.3, 28.7, 13, 20.1, 12.6, 8.5, 24.3, 33.2, 30.1, 20, 43.1, 19.8, 24.4, 20.4, 41.7, 20.5, 21.4, 23, 13.8, 18.6, 34.9, 18.3, 34.9, 50, 17.8, 27.5, 36.2, 27.5, 21.2, 23.9, 17.4, 14.1, 7.4, 35.1, 12, 36.2, 19.9, 22, 50, 25, 20.1, 29.8, 22.9, 13.9, 21.5, 28.7, 27, 26.7, 24.8, 7.2, 22.9, 31.1, 8.1, 27.1, 19.1, 15.3, 21.4, 18.5, 19.3, 48.5, 42.3, 24.1, 21.8, 20.1, 50, 20.1, 21.7, 23.8, 23.7, 18.5, 11.7, 16.5, 22.6, 11.8, 24.3, 24.5, 13.3, 35.2, 16.8, 20.7, 19.8, 22.6, 18.9, 17.1, 27.9, 25, 20.9, 21.9, 17.2, 19.6, 21.2, 19.5, 19.1, 34.9, 23.2, 16.1, 15.6, 15.7, 13.3, 50, 23.6, 14.9, 14.6, 22, 23.8, 37.6, 22, 31.2, 21.9, 25.1, 17.3, 22.2, 18.3, 18.5, 23.8, 17.8, 19.2, 30.3, 13.1, 23.9, 28, 19.4, 18.1, 17.9, 11.5, 24.4, 20.6, 22, 14.6, 22.8, 14.5, 14.5, 31.6, 24.8, 15.1, 14.1, 19.5, 14.4, 5, 26.5, 16.3, 23.3, 23.2, 23.1, 22.1, 19.9, 44, 24.7, 24.1, 20.6, 16.6, 11.3, 24.4, 34.7, 33.3, 23.8, 10.9, 24.8, 10.2, 17.4, 21.1, 28.1, 15.6, 27.9, 22, 9.6, 30.1, 23.2, 37, 19.5, 8.3, 23.9, 24.7, 23.3, 46, 15.6, 27.5, 31.5, 23.7, 22.8, 25, 15.2, 13.8, 29.1, 16.2, 10.4, 17.8, 10.8, 20.8, 50, 20.1, 23.6, 7.5, 11.9, 15.2, 16.7, 23.9, 18.9, 32.9, 50, 15.6, 14.3, 20.6, 30.7, 13.4, 37.9, 45.4, 24.2, 10.9, 12.7, 18.8, 14.2, 19.6, 48.3, 50, 38.7, 21.7, 18.9, 48.8, 21.4, 50, 12.7, 15.6, 19, 17.4, 23.1, 50, 14.4, 20.6, 20, 29, 23.5, 29.1, 50, 37.3, 39.8, 24, 18.4, 36.1, 17.6, 43.8, 32.4, 32.5, 25, 23.1, 18.4, 16.8, 17.5, 22.5, 44.8, 18, 35.4, 26.6, 24.4, 22.4, 23.1, 16.7, 7.2, 16.1, 15, 13.5, 11.9, 33, 21.9, 17.8, 22, 24.6, 22.8, 17, 23, 24.5, 6.3, 12.1, 22.5, 28.6, 22.9, 19.6, 19.4, 50, 8.4, 15, 19.9, 20.5, 16.2, 32.2, 21.7, 23.3, 35.4, 18.9, 21.7, 10.5, 19.7, 26.6, 17.7, 19, 22.2, 18.2, 22.2, 33.4, 21.2, 23.3, 23.7, 13.8, 21.2, 22.2, 21.2, 13.6, 50, 15, 20.3, 19.4, 26.4, 18.2, 13.3, 17.5, 20, 25.2, 24.8, 18.7, 9.5, 26.4, 21.7, 30.1, 10.2, 29, 29.9, 17.8, 16.6, 21, 16.4, 13.1, 23, 19.8, 20.3, 5.6, 42.8, 22, 19.3, 15.4, 21.6, 22.8, 24 ] }, { "mode": "lines", "name": "Train Predicted", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 455 ], "y": [ 19.642853305042212, 19.11793972411377, 27.289331279666897, 28.02322698014173, 48.86439656720537, 16.456941468107985, 18.377900817327276, 25.83427671439891, 39.340800508276764, 16.82859981964757, 8.410130641961059, 31.230244126848312, 15.561416100354252, 8.43963464412177, 9.061587598179477, 20.427627575758613, 29.353269519474996, 32.5209519466419, 22.227042174154843, 12.858458032965105, 28.717948702000182, 21.76656949453285, 13.902524929007166, 20.106407819941825, 18.739411740067332, 16.3821570957405, 21.165217235351733, 22.19905692709289, 17.292243603918312, 24.582850687686896, 17.6972087563407, 31.556708435173164, 35.95517601086701, 24.875733293703423, 9.50794160813013, 24.47460212295765, 48.37432293368222, 20.72502902695215, 15.414891588729025, 22.14406004983085, 29.954755163512353, 28.346591446336646, 20.515843279681395, 29.816427083882054, 17.537153320550434, 24.158469824315887, 22.616972716117978, 11.189583168946788, 8.489537638384283, 32.86406591250263, 19.030776931900107, 48.794893486861184, 14.855011946569844, 19.550921461381062, 9.605398826211557, 15.638298790835155, 21.527357932351585, 45.361670553440156, 20.093167344593258, 21.34392722975663, 21.501138728961305, 22.383485301021437, 22.0145347899858, 31.454049319112904, 24.17918434433343, 14.651734207880905, 16.744113528043574, 14.195081337189887, 19.743740397476987, 23.367224905347413, 11.24855007578098, 9.585715041697746, 14.508570990798134, 19.114347852242457, 19.427019271019166, 15.300718942654434, 21.300613462917976, 24.002007989460274, 17.423063906710997, 18.743642089256035, 18.158356946739605, 21.909897750567726, 8.273636191441073, 20.80584872000837, 32.63209036309824, 10.634586827857573, 23.894344073066662, 20.26263904437054, 21.481457318026997, 14.325649667081583, 22.308701257267654, 12.8417266003484, 18.75060391183459, 19.269364870013977, 23.587711172344434, 19.089456776474165, 23.401588163544083, 23.709270526688602, 19.325627567453566, 20.140179589102377, 29.10275657685505, 19.28335233914408, 31.817465206761472, 18.780629704538434, 20.48542022709396, 18.721227096269786, 20.294831546744945, 20.555762298860284, 31.742558135157612, 32.74750159812755, 20.88957676751055, 10.096113119529567, 13.286059381929125, 16.259011214915216, 26.45230769494652, 14.496512621009165, 20.1694244053962, 15.146660603060397, 10.954019626022, 22.388477097134828, 33.92514227701355, 26.230074243755844, 18.068662562632834, 42.58997186586433, 21.692359738091792, 23.49073166660703, 21.343077494896946, 42.203516141083306, 21.6343786403348, 21.07597251869312, 20.48252387624158, 13.922851103029338, 18.50628563791791, 33.36130794042301, 18.88979381327166, 33.954283660101254, 50.298739884012654, 16.858293253074645, 23.32961224665554, 35.709500313484696, 24.357818120583467, 22.09628852053872, 22.66449688081339, 19.101300443602703, 14.639033449743872, 8.830891595345461, 34.73912467518552, 12.512888854104, 32.27531820948651, 20.36147286805989, 24.51408630128819, 49.31530326758963, 23.68390160124668, 20.800908352530573, 27.19652623839111, 22.511925789982207, 12.976369163184467, 20.84684928972053, 29.814771011325643, 25.32206830982242, 28.70818526657746, 23.72058243716475, 7.822045622136389, 23.50424767699096, 29.974810833504247, 9.089988044368173, 21.636572983022813, 17.98574600321803, 17.760605242123216, 22.88225803336712, 18.161696034842848, 20.812998027002777, 48.27029470081536, 43.67595712239211, 24.72468071005119, 20.95498670210453, 19.469369609566733, 49.81051079961656, 18.384262075990822, 21.62638163991215, 23.23916886724865, 24.24051552699981, 18.842793006050993, 11.932291684443411, 19.046337108404156, 22.727080983273723, 9.884777328739816, 24.49968489955085, 21.351366003282273, 12.975116602141572, 37.220933999159385, 19.3993069600623, 22.109049072174585, 20.16902167245761, 22.811663272378627, 18.44210724599871, 18.069266489847877, 27.784285678040785, 25.197888644017006, 21.1769915695493, 22.56784542239169, 16.585069620234222, 20.574079139467234, 20.786949178344397, 18.22584662880862, 21.106586483955027, 34.54688568842436, 20.768816819985, 17.02057499143638, 16.86541795890982, 16.59586676235558, 13.61003659330413, 47.69032046108533, 27.221934227913234, 16.07922101877072, 14.08276395509875, 22.393131742370972, 22.227042174154843, 40.96533721186752, 20.856882143219885, 30.879139320900222, 23.68706688589004, 25.819862130418702, 16.72087148523324, 22.18665019854749, 20.824201438474365, 21.615007346563075, 21.981304664149636, 14.8297382363102, 20.093877476694264, 30.172449079484082, 15.069531002107116, 23.958485275953688, 26.9096923482095, 18.842423361596808, 17.419735625008006, 16.299641896269097, 11.546915488569448, 23.396859766265596, 21.046562638355265, 23.375889994959653, 16.18266690251509, 26.274627878908262, 14.381596484563715, 17.690580215151154, 32.026350107088724, 26.00734761442935, 15.10512574020014, 15.430982108737737, 19.603776510521385, 13.408777110491254, 6.254757520754317, 25.199112112667517, 15.550446120276153, 24.858448176173678, 19.371493589052147, 21.392238055663398, 23.472607168955346, 19.929102920850596, 43.12703994917878, 23.320754983278, 23.07528174998573, 20.29715204721434, 16.241672248669918, 11.546915488569448, 22.257591149523734, 34.22959206278958, 35.15567679196398, 23.587711172344434, 11.082313450667927, 26.86796800366611, 11.24855007578098, 20.10212983516894, 20.84454432892434, 25.885913589749308, 16.281854092570814, 29.138877222511397, 22.341227911478594, 11.157219043795338, 31.028682876505332, 22.759167682837955, 32.68704289683327, 19.705244696965647, 9.562625987860413, 24.80631173395882, 23.362877340540148, 25.110332179694474, 45.659721743364905, 15.191631483449807, 27.539370558743197, 32.952706249478275, 22.122805732551715, 23.736353898889, 24.317263702852447, 15.398217134243161, 16.209631770135395, 26.899599411056688, 19.475977090064568, 11.558139626019937, 16.540120986736227, 10.718772457866818, 19.914553087674612, 49.5497608111189, 20.018269202660885, 23.942200201277302, 8.141857278235031, 14.971591185296774, 16.430936898473213, 17.701095325762683, 25.128375604180352, 20.096576213741248, 33.44142755974267, 49.67671108041297, 14.626528880728603, 14.403398956721327, 20.713375457964595, 30.534190480522604, 12.34243466221966, 39.1626399977671, 45.67886534346127, 23.63810606723755, 11.157177202639948, 14.932768093344329, 18.993934740354213, 14.994445638715467, 20.093877476694264, 45.10544502084634, 48.355666657840565, 39.319732513445636, 20.87738542209136, 21.454777267311595, 46.46437135885681, 19.579061667955187, 49.16020175117015, 13.309752783611613, 16.243566041287384, 17.239434801986498, 16.4606907310667, 21.42845823525454, 48.75129486493416, 15.697243528334312, 20.685092823231297, 20.86931861769898, 30.680094550984837, 24.883519684626272, 28.90743581777427, 49.729111577123284, 35.808092930994256, 39.39232473042854, 22.40097324971336, 16.835799497743622, 34.33577074552429, 18.763669740594157, 42.46319442602407, 32.15470946727204, 30.511487538590536, 24.03363256519337, 21.647551076090824, 18.610352954983792, 17.807263728352556, 17.080818847125162, 20.871254734697892, 45.99594124638143, 17.01752982992074, 35.81675280690981, 26.319601853299112, 22.948201588944695, 21.50267974267152, 20.877503611884617, 14.483458087986467, 10.44615377854809, 18.539140576662547, 17.60502041642009, 14.614384223311665, 12.89453609617363, 32.325246683358436, 18.83421794044021, 16.38945509722969, 25.470337243685876, 23.665767371945527, 23.347599631892727, 17.474069050350533, 23.947069181629992, 22.47846701701355, 8.871461166606414, 11.665003911957527, 20.924152127650288, 27.445130989771606, 23.165428164829148, 18.06964064054927, 19.817131935950837, 48.742500498181236, 8.48873047517274, 16.349766642435263, 19.99817505751276, 20.464663492555953, 16.18706588193969, 31.112721003598832, 20.807679225505982, 22.557002924171304, 35.10850956285378, 17.79349853663106, 20.014445933553827, 9.652973141042459, 20.33901047667926, 26.498800892740228, 18.304297055655375, 20.010915344118846, 23.141230369920947, 18.90834543421718, 21.09214426835694, 34.262803361260495, 21.206252205126454, 22.445163764486338, 23.859527923371694, 14.298870516989062, 21.04925871876536, 21.37230791421071, 21.520349826653735, 14.62763246514762, 48.77584775329156, 16.354805855084074, 21.205390429123604, 19.316203794258552, 24.896636190653307, 19.114736697953678, 15.505210813639021, 18.8988158048708, 20.830122165441708, 24.753603426725064, 24.38490715974977, 20.278551461889354, 9.562206894682827, 23.801199747986974, 19.798947785701053, 31.596555705257327, 12.806823562669345, 26.975359087437536, 29.185495244717217, 18.020504329061968, 17.366285831799573, 21.29193470281816, 16.013095023822302, 14.170868741142003, 23.447787432493012, 19.08119335250153, 21.845807832253815, 7.178226932039024, 42.19106946018614, 21.98781829630641, 19.1512256808229, 14.657163564102563, 21.80690683157907, 22.1139198580612, 25.923560825026954 ] } ], "layout": { "hovermode": "x", "paper_bgcolor": "rgb(0,0,0)", "plot_bgcolor": "rgb(10,10,10)", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "font": { "color": "rgb(255,255,255)", "size": 20 }, "text": "Risultati", "x": 0.5 } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "lines", "name": "Test Real", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51 ], "y": [ 19.3, 33.8, 28.5, 25.3, 18.7, 29.6, 23.4, 36.4, 22.6, 26.2, 11, 17.5, 46.7, 18.4, 22.7, 11.7, 12.8, 24.7, 50, 13.6, 33.4, 14.5, 13.5, 23.1, 28.7, 14, 14.8, 12.7, 10.4, 14.9, 32, 18.7, 27.5, 7, 24.5, 18.6, 13.2, 22.3, 36, 33.1, 8.7, 20.4, 21.4, 27.1, 28.4, 5, 21.5, 37.2, 31, 19.3, 23.1 ] }, { "mode": "lines", "name": "Test Predicted", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 51 ], "y": [ 20.144368351235734, 33.49700050591491, 32.15031672742904, 24.325049010629435, 18.86101703196011, 23.838152043242147, 21.514515719358773, 36.25605585455497, 24.228560845800118, 25.480636321759306, 10.85830422492253, 18.982530351187076, 44.696922193960084, 16.22795377738699, 21.231970136565565, 14.281745226187917, 11.686350503613982, 24.375681420651233, 43.5219848234504, 14.33176401120306, 34.556203445252414, 15.08931563833213, 13.667066451665036, 22.765154964838885, 26.265097547143675, 13.83146579053479, 18.306510147608133, 14.039550066713364, 9.193316556023204, 12.37489449089239, 27.16228445908054, 19.47934624304374, 22.88256767795297, 10.24659374762866, 25.528056622507993, 21.677741055127083, 14.323482946207125, 23.1654965366985, 35.85310468751871, 31.859923745390486, 8.124984850140546, 20.074290241823054, 19.077551206842745, 25.841906978394224, 25.986016503305727, 8.064782798699119, 20.40526359441948, 36.93440483979563, 31.284137247206523, 21.255011777865935, 22.294115001242343 ] } ], "layout": { "hovermode": "x", "paper_bgcolor": "rgb(0,0,0)", "plot_bgcolor": "rgb(10,10,10)", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "font": { "color": "rgb(255,255,255)", "size": 20 }, "text": "Risultati", "x": 0.5 } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "model_list = [\"Linear\", \"Huber\", \"TheilSen\",\"Ridge\",\"Lasso\",\"ElasticNet\",\"KNN\",\"DecisionTree\",\"SVR\",\"AdaBoost\",\"GradientBoost\",\"RandomForest\",\"ExtraTrees\"]\n", "chosen_model = \"GradientBoost\"\n", "fig_train, fig_test = train(X,Y,selected=chosen_model,modelName=\"test.sav\")\n", "fig_train.show()\n", "fig_test.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 4. Applicare il modello allenato a un nuovo set di dati" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "def apply_model(X,modelName='best_model.sav'):\n", " loaded_model = pickle.load(open(modelName, 'rb'))\n", " y_hat = loaded_model.predict(X)\n", " return y_hat" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Per questa parte fingeremo di avere nuovi dati. Questi ultimi li creeremo utilizzando la funzione **train_test_split** di scikit-learn." ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 542 }, "colab_type": "code", "id": "2BIHy-7u-K0u", "outputId": "479663d5-e6ae-4ef1-ccaa-db1cfa2a0f16" }, "outputs": [], "source": [ "# Creiamo dei dati\n", "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.80, shuffle=True) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Carichiamo la pipeline componente per componente per componente" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "loaded_model = pickle.load(open(\"test.sav\", 'rb'))" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [], "source": [ "sc_block = loaded_model.named_steps[\"sc\"]" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "loaded_model = pickle.load(open(\"test.sav\", 'rb'))\n", "\n", "# Applicare lo Standard Scaling\n", "sc_block = loaded_model.named_steps[\"sc\"]\n", "X_test_sc = sc_block.transform(X_test)\n", "\n", "# Applicare la PCA\n", "#pca_block = loaded_model.named_steps[\"pca\"]\n", "#X_test_pca = pca_block.transform(X_test_sc)\n", "#print(pca_block.explained_variance_ratio_)\n", "\n", "# Applicare il regressore\n", "model_trained = loaded_model.named_steps[\"reg\"]\n", "Y_pred = model_trained.predict(X_test_sc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Carichiamo l'intera pipeline" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "Y_pred_pipe = apply_model(X_test,modelName=\"test.sav\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Assicuriamoci che i due risultati siano uguali" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "mode": "lines", "name": "test", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 405 ], "y": [ 7, 20, 21.2, 23, 22.3, 15.1, 13.6, 36, 19.6, 50, 17, 28.7, 18.2, 12.1, 21.2, 36.2, 7.4, 16.8, 50, 27, 21.8, 31, 18.7, 10.4, 13.1, 18.6, 15.2, 27.5, 20.6, 20.9, 17.4, 20.2, 19.5, 22.1, 13.4, 10.9, 13.2, 20.5, 19.5, 50, 50, 8.5, 13.9, 22.5, 23.3, 29.1, 8.3, 7.2, 16.2, 18.3, 22, 18.5, 22.5, 18.6, 22.3, 23.7, 17.8, 14.3, 20.5, 10.8, 20.8, 17.2, 13.6, 18.4, 8.7, 19.7, 35.2, 19.9, 29.6, 14.8, 29, 23.1, 18.4, 13.1, 19.2, 50, 14.1, 21.1, 19.6, 22, 48.3, 31.7, 28.2, 18, 30.5, 25, 19.3, 23.1, 14.1, 7.2, 21.7, 18.9, 13.5, 29.9, 23.1, 22.8, 32.7, 20.3, 36.1, 23.9, 34.6, 42.8, 18.9, 19.7, 28.7, 19.4, 18.4, 17.8, 21.5, 24.4, 21.4, 29.1, 19.2, 16.5, 19.4, 15.6, 20.3, 29.6, 23, 19.5, 14.4, 22.8, 19.1, 23.3, 19.3, 21.7, 31.5, 11.8, 14.9, 33.1, 17.9, 5, 14.9, 12, 32.2, 10.5, 19.8, 25.2, 13.3, 23, 20, 24.5, 30.8, 23.1, 24.4, 14.5, 24.1, 19.8, 23.6, 46, 37, 23.3, 19.1, 17.5, 23.9, 16.5, 36.4, 44, 27.9, 20, 22.6, 29.8, 24.5, 10.9, 21.8, 23.4, 38.7, 6.3, 17.5, 17.3, 18.3, 21.7, 13.1, 23.2, 23.9, 9.7, 22.8, 20.1, 23.9, 17.7, 26.2, 33.8, 21.4, 24.8, 8.8, 32, 18.5, 13.8, 14.1, 18.7, 17.1, 24.2, 16.1, 16.4, 24.8, 20.8, 15, 19.4, 19.3, 14.5, 19.4, 8.8, 25.3, 50, 22.6, 21, 17.2, 8.3, 23.4, 50, 19, 18.5, 20.4, 11.7, 50, 50, 30.1, 20.1, 24.7, 21.6, 30.7, 21.1, 31.6, 15.6, 32, 23.1, 24.3, 23.5, 23.7, 21, 22.4, 27.5, 19.3, 8.1, 21.7, 17.1, 32.9, 16.3, 19.9, 10.2, 15.4, 24.8, 21.2, 50, 21.2, 23.6, 21, 12.7, 19.4, 28.4, 21.2, 15.7, 22.5, 31.1, 13.8, 15, 20.6, 36.5, 21.9, 24.7, 11, 27.5, 21.7, 22.2, 26.4, 33, 18.2, 28.5, 24.4, 19.1, 22.2, 36.2, 26.6, 22.7, 24.3, 15.2, 20.1, 41.3, 22.9, 23.9, 12.8, 14.5, 15, 16.6, 24.6, 11.3, 23.7, 17.8, 22.6, 17.8, 23.7, 50, 16.7, 12.7, 43.1, 18.1, 24.8, 17.1, 23.2, 23.8, 15.6, 22.9, 17.8, 31.6, 25.1, 21.4, 15.4, 16.8, 20.6, 18.5, 37.3, 13.5, 12.5, 22.9, 20, 39.8, 21.7, 22.2, 5.6, 50, 25, 27.9, 33.3, 17.5, 13.4, 22.4, 50, 20.7, 12.6, 23.8, 35.4, 37.9, 10.2, 17.4, 26.4, 23.1, 18.7, 16.7, 33.2, 48.5, 48.8, 23, 25, 46.7, 15.6, 20.1, 19.6, 20.4, 24.7, 23.2, 19.5, 27.1, 16.6, 7.2, 34.9, 25, 13.9, 29, 31.5, 13.3, 22, 32.5, 14.6, 37.2, 11.7, 50, 24.3, 21.4, 28.1, 11.8, 22.6, 22, 10.2, 9.6, 14.3, 21.7, 33.1, 20.6, 30.3, 28.6, 24.4, 25, 18.8, 21.9, 28, 19.9, 15.2, 11.5, 24, 11.9, 28.7, 19.6, 14, 8.5, 20.3, 14.6, 20.3, 31.2, 50, 21.9, 5, 33.2, 12.3, 15.6, 19.4 ] }, { "mode": "lines", "name": "pred", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 405 ], "y": [ 9.585715041697746, 18.068662562632834, 21.04925871876536, 23.447787432493012, 23.1654965366985, 15.10512574020014, 14.62763246514762, 35.85310468751871, 20.574079139467234, 48.75129486493416, 17.474069050350533, 26.45230769494652, 18.90834543421718, 11.665003911957527, 21.206252205126454, 32.27531820948651, 8.830891595345461, 17.807263728352556, 43.5219848234504, 25.32206830982242, 20.88957676751055, 31.284137247206523, 18.86101703196011, 9.193316556023204, 14.170868741142003, 18.50628563791791, 16.3821570957405, 27.539370558743197, 21.165217235351733, 21.1769915695493, 20.10212983516894, 18.743642089256035, 18.22584662880862, 23.472607168955346, 12.8417266003484, 11.157177202639948, 14.323482946207125, 20.464663492555953, 18.158356946739605, 48.794893486861184, 49.67671108041297, 10.954019626022, 12.976369163184467, 20.871254734697892, 22.445163764486338, 26.899599411056688, 8.273636191441073, 7.822045622136389, 19.475977090064568, 20.824201438474365, 22.393131742370972, 19.11793972411377, 20.924152127650288, 21.677741055127083, 22.227042174154843, 24.002007989460274, 16.858293253074645, 14.403398956721327, 21.6343786403348, 10.718772457866818, 19.914553087674612, 15.561416100354252, 14.33176401120306, 16.22795377738699, 8.124984850140546, 20.33901047667926, 37.220933999159385, 19.929102920850596, 23.838152043242147, 18.306510147608133, 30.680094550984837, 23.587711172344434, 18.610352954983792, 15.300718942654434, 20.093877476694264, 50.298739884012654, 14.639033449743872, 20.555762298860284, 20.294831546744945, 21.98781829630641, 45.10544502084634, 32.63209036309824, 29.10275657685505, 17.01752982992074, 29.816427083882054, 24.03363256519337, 20.144368351235734, 22.294115001242343, 16.456941468107985, 10.44615377854809, 20.87738542209136, 18.44210724599871, 13.667066451665036, 29.185495244717217, 21.647551076090824, 26.274627878908262, 31.742558135157612, 21.205390429123604, 34.33577074552429, 25.128375604180352, 32.5209519466419, 42.19106946018614, 21.454777267311595, 18.780629704538434, 26.265097547143675, 18.739411740067332, 16.835799497743622, 18.020504329061968, 20.40526359441948, 22.948201588944695, 22.19905692709289, 28.90743581777427, 20.72502902695215, 17.292243603918312, 18.842423361596808, 16.243566041287384, 20.427627575758613, 31.556708435173164, 20.48252387624158, 19.603776510521385, 13.408777110491254, 23.347599631892727, 17.6972087563407, 25.110332179694474, 19.1512256808229, 20.140179589102377, 32.952706249478275, 13.902524929007166, 15.414891588729025, 31.859923745390486, 16.299641896269097, 6.254757520754317, 16.07922101877072, 12.512888854104, 31.112721003598832, 10.096113119529567, 21.692359738091792, 24.753603426725064, 15.505210813639021, 23.947069181629992, 21.481457318026997, 25.528056622507993, 29.353269519474996, 21.42845823525454, 22.257591149523734, 17.690580215151154, 24.72468071005119, 19.08119335250153, 27.221934227913234, 45.659721743364905, 32.68704289683327, 22.557002924171304, 17.98574600321803, 18.8988158048708, 22.66449688081339, 19.046337108404156, 36.25605585455497, 43.12703994917878, 29.138877222511397, 20.86931861769898, 22.811663272378627, 29.954755163512353, 21.351366003282273, 11.082313450667927, 20.95498670210453, 23.709270526688602, 39.319732513445636, 8.871461166606414, 18.982530351187076, 16.72087148523324, 18.88979381327166, 21.76656949453285, 15.069531002107116, 20.768816819985, 23.958485275953688, 10.634586827857573, 22.1139198580612, 19.469369609566733, 24.47460212295765, 18.304297055655375, 25.480636321759306, 33.49700050591491, 21.07597251869312, 23.72058243716475, 8.489537638384283, 27.16228445908054, 18.842793006050993, 14.325649667081583, 15.430982108737737, 20.278551461889354, 14.651734207880905, 23.63810606723755, 17.537153320550434, 16.013095023822302, 26.00734761442935, 18.75060391183459, 17.60502041642009, 19.316203794258552, 20.106407819941825, 15.08931563833213, 19.817131935950837, 9.061587598179477, 24.325049010629435, 48.355666657840565, 24.228560845800118, 21.29193470281816, 16.585069620234222, 9.562625987860413, 21.514515719358773, 49.16020175117015, 17.239434801986498, 18.161696034842848, 21.343077494896946, 11.932291684443411, 49.5497608111189, 48.77584775329156, 31.596555705257327, 20.1694244053962, 24.375681420651233, 21.80690683157907, 30.534190480522604, 20.84454432892434, 32.026350107088724, 16.86541795890982, 32.86406591250263, 20.877503611884617, 24.49968489955085, 24.883519684626272, 22.122805732551715, 20.80584872000837, 21.501138728961305, 22.88256767795297, 21.255011777865935, 9.089988044368173, 20.807679225505982, 18.069266489847877, 33.44142755974267, 15.550446120276153, 19.99817505751276, 11.24855007578098, 14.855011946569844, 26.86796800366611, 20.786949178344397, 47.69032046108533, 21.520349826653735, 23.942200201277302, 22.616972716117978, 13.309752783611613, 19.743740397476987, 25.986016503305727, 22.09628852053872, 16.59586676235558, 24.158469824315887, 29.974810833504247, 13.922851103029338, 16.354805855084074, 20.29715204721434, 35.95517601086701, 18.83421794044021, 23.320754983278, 10.85830422492253, 23.32961224665554, 20.014445933553827, 22.18665019854749, 24.896636190653307, 32.325246683358436, 19.269364870013977, 32.15031672742904, 23.49073166660703, 16.744113528043574, 22.383485301021437, 35.709500313484696, 26.319601853299112, 21.231970136565565, 22.14406004983085, 15.398217134243161, 18.384262075990822, 39.340800508276764, 21.527357932351585, 24.80631173395882, 11.686350503613982, 14.381596484563715, 16.349766642435263, 16.241672248669918, 23.665767371945527, 11.546915488569448, 23.859527923371694, 16.540120986736227, 24.17918434433343, 14.8297382363102, 24.24051552699981, 49.31530326758963, 14.483458087986467, 14.932768093344329, 42.58997186586433, 17.419735625008006, 24.38490715974977, 18.721227096269786, 23.367224905347413, 22.227042174154843, 15.191631483449807, 22.511925789982207, 16.38945509722969, 31.230244126848312, 25.819862130418702, 19.077551206842745, 14.657163564102563, 19.3993069600623, 20.713375457964595, 21.615007346563075, 35.808092930994256, 14.614384223311665, 14.195081337189887, 23.50424767699096, 19.089456776474165, 39.39232473042854, 19.798947785701053, 21.09214426835694, 7.178226932039024, 49.81051079961656, 23.68390160124668, 27.784285678040785, 35.15567679196398, 17.080818847125162, 14.508570990798134, 21.50267974267152, 49.729111577123284, 22.0145347899858, 15.146660603060397, 23.587711172344434, 35.81675280690981, 39.1626399977671, 9.605398826211557, 16.4606907310667, 23.801199747986974, 21.392238055663398, 19.47934624304374, 17.701095325762683, 33.92514227701355, 48.27029470081536, 46.46437135885681, 21.34392722975663, 23.894344073066662, 44.696922193960084, 16.281854092570814, 20.018269202660885, 19.642853305042212, 20.093167344593258, 23.362877340540148, 22.759167682837955, 19.705244696965647, 25.841906978394224, 17.366285831799573, 8.43963464412177, 33.36130794042301, 24.875733293703423, 15.638298790835155, 26.975359087437536, 31.454049319112904, 12.975116602141572, 20.856882143219885, 30.511487538590536, 16.18266690251509, 36.93440483979563, 14.281745226187917, 48.742500498181236, 22.388477097134828, 19.579061667955187, 25.885913589749308, 9.884777328739816, 20.48542022709396, 23.375889994959653, 12.806823562669345, 11.157219043795338, 16.259011214915216, 21.62638163991215, 31.817465206761472, 21.046562638355265, 30.172449079484082, 27.445130989771606, 23.396859766265596, 28.02322698014173, 18.993934740354213, 23.68706688589004, 26.9096923482095, 20.36147286805989, 16.430936898473213, 11.546915488569448, 25.923560825026954, 14.971591185296774, 29.814771011325643, 18.06964064054927, 13.83146579053479, 8.410130641961059, 19.28335233914408, 14.08276395509875, 21.845807832253815, 30.879139320900222, 48.37432293368222, 22.56784542239169, 8.064782798699119, 32.74750159812755, 11.189583168946788, 14.626528880728603, 16.82859981964757 ] }, { "mode": "lines", "name": "pipe", "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 405 ], "y": [ 9.585715041697746, 18.068662562632834, 21.04925871876536, 23.447787432493012, 23.1654965366985, 15.10512574020014, 14.62763246514762, 35.85310468751871, 20.574079139467234, 48.75129486493416, 17.474069050350533, 26.45230769494652, 18.90834543421718, 11.665003911957527, 21.206252205126454, 32.27531820948651, 8.830891595345461, 17.807263728352556, 43.5219848234504, 25.32206830982242, 20.88957676751055, 31.284137247206523, 18.86101703196011, 9.193316556023204, 14.170868741142003, 18.50628563791791, 16.3821570957405, 27.539370558743197, 21.165217235351733, 21.1769915695493, 20.10212983516894, 18.743642089256035, 18.22584662880862, 23.472607168955346, 12.8417266003484, 11.157177202639948, 14.323482946207125, 20.464663492555953, 18.158356946739605, 48.794893486861184, 49.67671108041297, 10.954019626022, 12.976369163184467, 20.871254734697892, 22.445163764486338, 26.899599411056688, 8.273636191441073, 7.822045622136389, 19.475977090064568, 20.824201438474365, 22.393131742370972, 19.11793972411377, 20.924152127650288, 21.677741055127083, 22.227042174154843, 24.002007989460274, 16.858293253074645, 14.403398956721327, 21.6343786403348, 10.718772457866818, 19.914553087674612, 15.561416100354252, 14.33176401120306, 16.22795377738699, 8.124984850140546, 20.33901047667926, 37.220933999159385, 19.929102920850596, 23.838152043242147, 18.306510147608133, 30.680094550984837, 23.587711172344434, 18.610352954983792, 15.300718942654434, 20.093877476694264, 50.298739884012654, 14.639033449743872, 20.555762298860284, 20.294831546744945, 21.98781829630641, 45.10544502084634, 32.63209036309824, 29.10275657685505, 17.01752982992074, 29.816427083882054, 24.03363256519337, 20.144368351235734, 22.294115001242343, 16.456941468107985, 10.44615377854809, 20.87738542209136, 18.44210724599871, 13.667066451665036, 29.185495244717217, 21.647551076090824, 26.274627878908262, 31.742558135157612, 21.205390429123604, 34.33577074552429, 25.128375604180352, 32.5209519466419, 42.19106946018614, 21.454777267311595, 18.780629704538434, 26.265097547143675, 18.739411740067332, 16.835799497743622, 18.020504329061968, 20.40526359441948, 22.948201588944695, 22.19905692709289, 28.90743581777427, 20.72502902695215, 17.292243603918312, 18.842423361596808, 16.243566041287384, 20.427627575758613, 31.556708435173164, 20.48252387624158, 19.603776510521385, 13.408777110491254, 23.347599631892727, 17.6972087563407, 25.110332179694474, 19.1512256808229, 20.140179589102377, 32.952706249478275, 13.902524929007166, 15.414891588729025, 31.859923745390486, 16.299641896269097, 6.254757520754317, 16.07922101877072, 12.512888854104, 31.112721003598832, 10.096113119529567, 21.692359738091792, 24.753603426725064, 15.505210813639021, 23.947069181629992, 21.481457318026997, 25.528056622507993, 29.353269519474996, 21.42845823525454, 22.257591149523734, 17.690580215151154, 24.72468071005119, 19.08119335250153, 27.221934227913234, 45.659721743364905, 32.68704289683327, 22.557002924171304, 17.98574600321803, 18.8988158048708, 22.66449688081339, 19.046337108404156, 36.25605585455497, 43.12703994917878, 29.138877222511397, 20.86931861769898, 22.811663272378627, 29.954755163512353, 21.351366003282273, 11.082313450667927, 20.95498670210453, 23.709270526688602, 39.319732513445636, 8.871461166606414, 18.982530351187076, 16.72087148523324, 18.88979381327166, 21.76656949453285, 15.069531002107116, 20.768816819985, 23.958485275953688, 10.634586827857573, 22.1139198580612, 19.469369609566733, 24.47460212295765, 18.304297055655375, 25.480636321759306, 33.49700050591491, 21.07597251869312, 23.72058243716475, 8.489537638384283, 27.16228445908054, 18.842793006050993, 14.325649667081583, 15.430982108737737, 20.278551461889354, 14.651734207880905, 23.63810606723755, 17.537153320550434, 16.013095023822302, 26.00734761442935, 18.75060391183459, 17.60502041642009, 19.316203794258552, 20.106407819941825, 15.08931563833213, 19.817131935950837, 9.061587598179477, 24.325049010629435, 48.355666657840565, 24.228560845800118, 21.29193470281816, 16.585069620234222, 9.562625987860413, 21.514515719358773, 49.16020175117015, 17.239434801986498, 18.161696034842848, 21.343077494896946, 11.932291684443411, 49.5497608111189, 48.77584775329156, 31.596555705257327, 20.1694244053962, 24.375681420651233, 21.80690683157907, 30.534190480522604, 20.84454432892434, 32.026350107088724, 16.86541795890982, 32.86406591250263, 20.877503611884617, 24.49968489955085, 24.883519684626272, 22.122805732551715, 20.80584872000837, 21.501138728961305, 22.88256767795297, 21.255011777865935, 9.089988044368173, 20.807679225505982, 18.069266489847877, 33.44142755974267, 15.550446120276153, 19.99817505751276, 11.24855007578098, 14.855011946569844, 26.86796800366611, 20.786949178344397, 47.69032046108533, 21.520349826653735, 23.942200201277302, 22.616972716117978, 13.309752783611613, 19.743740397476987, 25.986016503305727, 22.09628852053872, 16.59586676235558, 24.158469824315887, 29.974810833504247, 13.922851103029338, 16.354805855084074, 20.29715204721434, 35.95517601086701, 18.83421794044021, 23.320754983278, 10.85830422492253, 23.32961224665554, 20.014445933553827, 22.18665019854749, 24.896636190653307, 32.325246683358436, 19.269364870013977, 32.15031672742904, 23.49073166660703, 16.744113528043574, 22.383485301021437, 35.709500313484696, 26.319601853299112, 21.231970136565565, 22.14406004983085, 15.398217134243161, 18.384262075990822, 39.340800508276764, 21.527357932351585, 24.80631173395882, 11.686350503613982, 14.381596484563715, 16.349766642435263, 16.241672248669918, 23.665767371945527, 11.546915488569448, 23.859527923371694, 16.540120986736227, 24.17918434433343, 14.8297382363102, 24.24051552699981, 49.31530326758963, 14.483458087986467, 14.932768093344329, 42.58997186586433, 17.419735625008006, 24.38490715974977, 18.721227096269786, 23.367224905347413, 22.227042174154843, 15.191631483449807, 22.511925789982207, 16.38945509722969, 31.230244126848312, 25.819862130418702, 19.077551206842745, 14.657163564102563, 19.3993069600623, 20.713375457964595, 21.615007346563075, 35.808092930994256, 14.614384223311665, 14.195081337189887, 23.50424767699096, 19.089456776474165, 39.39232473042854, 19.798947785701053, 21.09214426835694, 7.178226932039024, 49.81051079961656, 23.68390160124668, 27.784285678040785, 35.15567679196398, 17.080818847125162, 14.508570990798134, 21.50267974267152, 49.729111577123284, 22.0145347899858, 15.146660603060397, 23.587711172344434, 35.81675280690981, 39.1626399977671, 9.605398826211557, 16.4606907310667, 23.801199747986974, 21.392238055663398, 19.47934624304374, 17.701095325762683, 33.92514227701355, 48.27029470081536, 46.46437135885681, 21.34392722975663, 23.894344073066662, 44.696922193960084, 16.281854092570814, 20.018269202660885, 19.642853305042212, 20.093167344593258, 23.362877340540148, 22.759167682837955, 19.705244696965647, 25.841906978394224, 17.366285831799573, 8.43963464412177, 33.36130794042301, 24.875733293703423, 15.638298790835155, 26.975359087437536, 31.454049319112904, 12.975116602141572, 20.856882143219885, 30.511487538590536, 16.18266690251509, 36.93440483979563, 14.281745226187917, 48.742500498181236, 22.388477097134828, 19.579061667955187, 25.885913589749308, 9.884777328739816, 20.48542022709396, 23.375889994959653, 12.806823562669345, 11.157219043795338, 16.259011214915216, 21.62638163991215, 31.817465206761472, 21.046562638355265, 30.172449079484082, 27.445130989771606, 23.396859766265596, 28.02322698014173, 18.993934740354213, 23.68706688589004, 26.9096923482095, 20.36147286805989, 16.430936898473213, 11.546915488569448, 25.923560825026954, 14.971591185296774, 29.814771011325643, 18.06964064054927, 13.83146579053479, 8.410130641961059, 19.28335233914408, 14.08276395509875, 21.845807832253815, 30.879139320900222, 48.37432293368222, 22.56784542239169, 8.064782798699119, 32.74750159812755, 11.189583168946788, 14.626528880728603, 16.82859981964757 ] } ], "layout": { "hovermode": "x", "paper_bgcolor": "rgb(0,0,0)", "plot_bgcolor": "rgb(10,10,10)", "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "font": { "color": "rgb(255,255,255)", "size": 20 }, "text": "Risultati", "x": 0.5 } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig_res = plot_fig([Y_test, Y_pred,Y_pred_pipe], [\"test\", \"pred\",\"pipe\"])\n", "fig_res.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extra: Train-Test procedure" ] }, { "cell_type": "code", "execution_count": 67, "metadata": {}, "outputs": [], "source": [ "# Procedura di training\n", "def train_procedure():\n", " # 0 CARICA DATASET\n", " print(\"CARICA DATASET\")\n", " X,Y,df = load_dataset(name=\"boston\")\n", "\n", " # 1 COMPARA I MODELLI\n", " print(\"COMPARA MODELLI\")\n", " fig_compare_models = compare_models(X,Y)\n", "\n", " # 2 SCELGO IL MODELLO MIGLIORE\n", " print(\"SCELGO MODELLO MIGLIORE\")\n", " model_list = [\"Linear\", \"Huber\", \"TheilSen\",\"Ridge\",\"Lasso\",\"ElasticNet\",\"KNN\",\"DecisionTree\",\"SVR\",\"AdaBoost\",\"GradientBoost\",\"RandomForest\",\"ExtraTrees\"]\n", " chosen_model = \"GradientBoost\"\n", " model_name = \"test.sav\"\n", " fig_train, fig_test = train(X,Y,selected=chosen_model,modelName=model_name)\n", "\n", "# Procedura di test\n", "def test_procedure():\n", " # 3 CARICO IL NUOVO DATASET\n", " print(\"CARICO NUOVO DATASET\")\n", " X,Y,df = load_dataset(name=\"boston\")\n", " X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.80, shuffle=True) \n", "\n", " # 3bis. APPLICARE IL MODELL ALLENATO\n", " print(\"APPLICO MODELLO ALLENATO\")\n", " Y_pred_pipe = apply_model(X_test,modelName=\"test.sav\")\n", " fig_res = plot_fig([Y_test,Y_pred_pipe], [\"test\",\"pipe\"])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#train_procedure()\n", "test_procedure()" ] } ], "metadata": { "colab": { "collapsed_sections": [], "name": "Copy of Regression-Recap.ipynb", "provenance": [] }, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 1 }