{"cells":[{"cell_type":"markdown","source":"# Xgboost - Clasificación","metadata":{"id":"aDll5YpdFlNF","cell_id":"a37dd8d1e70844e185cc7237f52b3dbd","deepnote_cell_type":"markdown"}},{"cell_type":"code","source":"from google.colab import drive\nimport os\ndrive.mount('/content/drive')\n# Establecer ruta de acceso en drive\nimport os\nprint(os.getcwd())\nos.chdir(\"/content/drive/My Drive\")\nprint(os.getcwd())","metadata":{"id":"SUC155scFoc0","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"4d565104c74045729aabd0a42c0309c6","outputId":"85939bbd-dce9-401b-da0c-3759ddd5af51","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":2145,"user_tz":240,"timestamp":1652654065938},"deepnote_cell_type":"code"},"outputs":[{"output_type":"stream","name":"stdout","text":"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n/content/drive/My Drive\n/content/drive/My Drive\n"}],"execution_count":7},{"cell_type":"code","source":"!pip install xgboost","metadata":{"id":"q6dwM_FPLLkX","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"c678a5ee9c5b455f96a6fb7595c92ffa","outputId":"9ce03532-3b3c-4cd8-f4a5-a4873c01c0ce","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":3697,"user_tz":240,"timestamp":1652654036966},"deepnote_cell_type":"code"},"outputs":[{"output_type":"stream","name":"stdout","text":"Requirement already satisfied: xgboost in /usr/local/lib/python3.7/dist-packages (0.90)\nRequirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from xgboost) (1.21.6)\nRequirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from xgboost) (1.4.1)\n"}],"execution_count":2},{"cell_type":"code","source":"import xgboost as xgb #pip install xgboost\nimport pandas as pd\nimport numpy as np\nfrom sklearn.linear_model import LinearRegression as LR\nfrom sklearn.model_selection import train_test_split\n\ndata = pd.read_csv('winequality-red.csv')\ndata","metadata":{"id":"GIdK0mGJFlNT","colab":{"height":423,"base_uri":"https://localhost:8080/"},"cell_id":"cbaf98dad5524a948fe61df0746d31f8","outputId":"45f28b10-ebce-485e-8f7d-0165dbc6ff8d","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":647,"user_tz":240,"timestamp":1652654072498},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":" fixed acidity volatile acidity citric acid residual sugar chlorides \\\n0 7.4 0.700 0.00 1.9 0.076 \n1 7.8 0.880 0.00 2.6 0.098 \n2 7.8 0.760 0.04 2.3 0.092 \n3 11.2 0.280 0.56 1.9 0.075 \n4 7.4 0.700 0.00 1.9 0.076 \n... ... ... ... ... ... \n1594 6.2 0.600 0.08 2.0 0.090 \n1595 5.9 0.550 0.10 2.2 0.062 \n1596 6.3 0.510 0.13 2.3 0.076 \n1597 5.9 0.645 0.12 2.0 0.075 \n1598 6.0 0.310 0.47 3.6 0.067 \n\n free sulfur dioxide total sulfur dioxide density pH sulphates \\\n0 11.0 34.0 0.99780 3.51 0.56 \n1 25.0 67.0 0.99680 3.20 0.68 \n2 15.0 54.0 0.99700 3.26 0.65 \n3 17.0 60.0 0.99800 3.16 0.58 \n4 11.0 34.0 0.99780 3.51 0.56 \n... ... ... ... ... ... \n1594 32.0 44.0 0.99490 3.45 0.58 \n1595 39.0 51.0 0.99512 3.52 0.76 \n1596 29.0 40.0 0.99574 3.42 0.75 \n1597 32.0 44.0 0.99547 3.57 0.71 \n1598 18.0 42.0 0.99549 3.39 0.66 \n\n alcohol quality \n0 9.4 5 \n1 9.8 5 \n2 9.8 5 \n3 9.8 6 \n4 9.4 5 \n... ... ... \n1594 10.5 5 \n1595 11.2 6 \n1596 11.0 6 \n1597 10.2 5 \n1598 11.0 6 \n\n[1599 rows x 12 columns]","text/html":"\n
\n
\n
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
07.40.7000.001.90.07611.034.00.997803.510.569.45
17.80.8800.002.60.09825.067.00.996803.200.689.85
27.80.7600.042.30.09215.054.00.997003.260.659.85
311.20.2800.561.90.07517.060.00.998003.160.589.86
47.40.7000.001.90.07611.034.00.997803.510.569.45
.......................................
15946.20.6000.082.00.09032.044.00.994903.450.5810.55
15955.90.5500.102.20.06239.051.00.995123.520.7611.26
15966.30.5100.132.30.07629.040.00.995743.420.7511.06
15975.90.6450.122.00.07532.044.00.995473.570.7110.25
15986.00.3100.473.60.06718.042.00.995493.390.6611.06
\n

1599 rows × 12 columns

\n
\n \n \n \n\n \n
\n
\n "},"metadata":{},"execution_count":8}],"execution_count":8},{"cell_type":"code","source":"data.quality.unique()","metadata":{"id":"2NRixyYZT3Zp","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"3686c0c5edf64b089029bc20cb3017e9","outputId":"e291a4f6-2b45-40e2-f2e6-1cee26580f86","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":1093,"user_tz":240,"timestamp":1652654075965},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":"array([5, 6, 7, 4, 8, 3])"},"metadata":{},"execution_count":9}],"execution_count":9},{"cell_type":"markdown","source":"Vamos a hacer un problema de clasificacion. Asi que lo que vamos a predecir es\nsi el vino es de buena calidad o no. Tomaremos el 6 como umbral para decidir si\nes bueno o no. ","metadata":{"id":"LGispmSlFlNZ","cell_id":"ef167cea5007404ea88e2e32470cd025","deepnote_cell_type":"markdown"}},{"cell_type":"code","source":"data.loc[data['quality'] < 6, 'quality'] = 0 #baja calidad\ndata.loc[data['quality'] >= 6, 'quality'] = 1 #alta calidad","metadata":{"id":"xslPn-bEFlNb","cell_id":"92a05b5cf3f145e5bbc4d954706ba7af","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":301,"user_tz":240,"timestamp":1652654076690},"deepnote_cell_type":"code"},"outputs":[],"execution_count":10},{"cell_type":"code","source":"#Veamos que tenemos!\ndata","metadata":{"id":"Mu9yXr3WFlNc","colab":{"height":423,"base_uri":"https://localhost:8080/"},"cell_id":"5e60bc1f28384581a7e996ee4d7fc6db","outputId":"5e46013d-7e02-4e90-e6e1-559756dd9e98","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":318,"user_tz":240,"timestamp":1652654078336},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":" fixed acidity volatile acidity citric acid residual sugar chlorides \\\n0 7.4 0.700 0.00 1.9 0.076 \n1 7.8 0.880 0.00 2.6 0.098 \n2 7.8 0.760 0.04 2.3 0.092 \n3 11.2 0.280 0.56 1.9 0.075 \n4 7.4 0.700 0.00 1.9 0.076 \n... ... ... ... ... ... \n1594 6.2 0.600 0.08 2.0 0.090 \n1595 5.9 0.550 0.10 2.2 0.062 \n1596 6.3 0.510 0.13 2.3 0.076 \n1597 5.9 0.645 0.12 2.0 0.075 \n1598 6.0 0.310 0.47 3.6 0.067 \n\n free sulfur dioxide total sulfur dioxide density pH sulphates \\\n0 11.0 34.0 0.99780 3.51 0.56 \n1 25.0 67.0 0.99680 3.20 0.68 \n2 15.0 54.0 0.99700 3.26 0.65 \n3 17.0 60.0 0.99800 3.16 0.58 \n4 11.0 34.0 0.99780 3.51 0.56 \n... ... ... ... ... ... \n1594 32.0 44.0 0.99490 3.45 0.58 \n1595 39.0 51.0 0.99512 3.52 0.76 \n1596 29.0 40.0 0.99574 3.42 0.75 \n1597 32.0 44.0 0.99547 3.57 0.71 \n1598 18.0 42.0 0.99549 3.39 0.66 \n\n alcohol quality \n0 9.4 0 \n1 9.8 0 \n2 9.8 0 \n3 9.8 1 \n4 9.4 0 \n... ... ... \n1594 10.5 0 \n1595 11.2 1 \n1596 11.0 1 \n1597 10.2 0 \n1598 11.0 1 \n\n[1599 rows x 12 columns]","text/html":"\n
\n
\n
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
fixed acidityvolatile aciditycitric acidresidual sugarchloridesfree sulfur dioxidetotal sulfur dioxidedensitypHsulphatesalcoholquality
07.40.7000.001.90.07611.034.00.997803.510.569.40
17.80.8800.002.60.09825.067.00.996803.200.689.80
27.80.7600.042.30.09215.054.00.997003.260.659.80
311.20.2800.561.90.07517.060.00.998003.160.589.81
47.40.7000.001.90.07611.034.00.997803.510.569.40
.......................................
15946.20.6000.082.00.09032.044.00.994903.450.5810.50
15955.90.5500.102.20.06239.051.00.995123.520.7611.21
15966.30.5100.132.30.07629.040.00.995743.420.7511.01
15975.90.6450.122.00.07532.044.00.995473.570.7110.20
15986.00.3100.473.60.06718.042.00.995493.390.6611.01
\n

1599 rows × 12 columns

\n
\n \n \n \n\n \n
\n
\n "},"metadata":{},"execution_count":11}],"execution_count":11},{"cell_type":"code","source":"X = data.drop(\"quality\", axis=1) #Elimino de mi dataset la variable a predecir\ny = data.quality #Defino el Target","metadata":{"id":"qVu31IW6FlNe","cell_id":"2165c3d5af0e478fae7d3f3c172bfd16","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":305,"user_tz":240,"timestamp":1652654080681},"deepnote_cell_type":"code"},"outputs":[],"execution_count":12},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state=123)","metadata":{"id":"He7eXjTBFlNf","cell_id":"c7742875167448e4aa2ae9cccc227d52","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":3,"user_tz":240,"timestamp":1652654081628},"deepnote_cell_type":"code"},"outputs":[],"execution_count":13},{"cell_type":"code","source":"clf_xgb = xgb.XGBClassifier(objective='binary:logistic', n_estimators=10,seed=42,max_depth=6, learning_rate=0.01)","metadata":{"id":"NoCZq85tFlNh","cell_id":"78fb5d2d068a42da9978b33079a421e0","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":4,"user_tz":240,"timestamp":1652654082619},"deepnote_cell_type":"code"},"outputs":[],"execution_count":14},{"cell_type":"code","source":"clf_xgb.fit(X_train,y_train) #Entrenamos el modelo","metadata":{"id":"pYCPtKpmFlNj","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"dda03905246140c3adde047aaa00b7b8","outputId":"e9046187-2e1f-40b4-886e-d1289b57f763","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":381,"user_tz":240,"timestamp":1652654083939},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":"XGBClassifier(learning_rate=0.01, max_depth=6, n_estimators=10, seed=42)"},"metadata":{},"execution_count":15}],"execution_count":15},{"cell_type":"code","source":"y_train_pred = clf_xgb.predict(X_train) #Prediccion en Train\ny_test_pred = clf_xgb.predict(X_test) #Prediccion en Test","metadata":{"id":"SZu8kjblFlNn","cell_id":"99ac163c4224401aa3016bdc1fa79f19","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":6,"user_tz":240,"timestamp":1652654084574},"deepnote_cell_type":"code"},"outputs":[],"execution_count":16},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score\n\n#Calculo el accuracy en Train\n#train_accuracy = accuracy_score(y_train, y_train_pred)\n\n#Calculo el accuracy en Test\ntest_accuracy = accuracy_score(y_test, y_test_pred)\n\n#print('% de aciertos sobre el set de entrenamiento:', train_accuracy)\nprint('% de aciertos sobre el set de evaluación:',test_accuracy)","metadata":{"id":"LvqasUDIFlNo","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"1eea10be8d364fcebb57509014a74a4e","outputId":"6dd4cd98-fa20-4c42-e15c-0b706bdcd3a3","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":2,"user_tz":240,"timestamp":1652654085546},"deepnote_cell_type":"code"},"outputs":[{"output_type":"stream","name":"stdout","text":"% de aciertos sobre el set de evaluación: 0.75625\n"}],"execution_count":17},{"cell_type":"markdown","source":"# XGboost - Regresión","metadata":{"id":"-DG4X3x0FlNq","cell_id":"8af5038170954bf387b8e3b1220ce3e2","deepnote_cell_type":"markdown"}},{"cell_type":"code","source":"import pandas as pd\nimport xgboost as xgb\nfrom sklearn.datasets import load_boston\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import mean_squared_error","metadata":{"id":"b0GwP7cxFlNr","cell_id":"1c1dc58433ed408b9d53e58a3718492b","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":409,"user_tz":240,"timestamp":1652654088018},"deepnote_cell_type":"code"},"outputs":[],"execution_count":18},{"cell_type":"code","source":"boston = load_boston()\nX = pd.DataFrame(boston.data, columns=boston.feature_names)\ny = pd.Series(boston.target)","metadata":{"id":"PKll--nzFlNs","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"8b7199d1f65448f4b215891cfb79d0c4","outputId":"831a356f-5d3a-4b01-d535-504f69251759","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":235,"user_tz":240,"timestamp":1652654089830},"deepnote_cell_type":"code"},"outputs":[{"output_type":"stream","name":"stderr","text":"/usr/local/lib/python3.7/dist-packages/sklearn/utils/deprecation.py:87: FutureWarning: Function load_boston is deprecated; `load_boston` is deprecated in 1.0 and will be removed in 1.2.\n\n The Boston housing prices dataset has an ethical problem. You can refer to\n the documentation of this function for further details.\n\n The scikit-learn maintainers therefore strongly discourage the use of this\n dataset unless the purpose of the code is to study and educate about\n ethical issues in data science and machine learning.\n\n In this special case, you can fetch the dataset from the original\n source::\n\n import pandas as pd\n import numpy as np\n\n\n data_url = \"http://lib.stat.cmu.edu/datasets/boston\"\n raw_df = pd.read_csv(data_url, sep=\"\\s+\", skiprows=22, header=None)\n data = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])\n target = raw_df.values[1::2, 2]\n\n Alternative datasets include the California housing dataset (i.e.\n :func:`~sklearn.datasets.fetch_california_housing`) and the Ames housing\n dataset. You can load the datasets as follows::\n\n from sklearn.datasets import fetch_california_housing\n housing = fetch_california_housing()\n\n for the California housing dataset and::\n\n from sklearn.datasets import fetch_openml\n housing = fetch_openml(name=\"house_prices\", as_frame=True)\n\n for the Ames housing dataset.\n \n warnings.warn(msg, category=FutureWarning)\n"}],"execution_count":19},{"cell_type":"code","source":"#Vemos que tenemos!\nX.head()","metadata":{"id":"705lMeVmFlNt","colab":{"height":206,"base_uri":"https://localhost:8080/"},"cell_id":"df1b46824f1344ea9365902a82b0e4bc","outputId":"19e9e3cd-e615-4ecd-f376-591385d9d49f","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":318,"user_tz":240,"timestamp":1652654092927},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":" CRIM ZN INDUS CHAS NOX RM AGE DIS RAD TAX \\\n0 0.00632 18.0 2.31 0.0 0.538 6.575 65.2 4.0900 1.0 296.0 \n1 0.02731 0.0 7.07 0.0 0.469 6.421 78.9 4.9671 2.0 242.0 \n2 0.02729 0.0 7.07 0.0 0.469 7.185 61.1 4.9671 2.0 242.0 \n3 0.03237 0.0 2.18 0.0 0.458 6.998 45.8 6.0622 3.0 222.0 \n4 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 \n0 15.3 396.90 4.98 \n1 17.8 396.90 9.14 \n2 17.8 392.83 4.03 \n3 18.7 394.63 2.94 \n4 18.7 396.90 5.33 ","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
CRIMZNINDUSCHASNOXRMAGEDISRADTAXPTRATIOBLSTAT
00.0063218.02.310.00.5386.57565.24.09001.0296.015.3396.904.98
10.027310.07.070.00.4696.42178.94.96712.0242.017.8396.909.14
20.027290.07.070.00.4697.18561.14.96712.0242.017.8392.834.03
30.032370.02.180.00.4586.99845.86.06223.0222.018.7394.632.94
40.069050.02.180.00.4587.14754.26.06223.0222.018.7396.905.33
\n
\n \n \n \n\n \n
\n
\n "},"metadata":{},"execution_count":21}],"execution_count":21},{"cell_type":"code","source":"y","metadata":{"id":"Ny1ziPpQMvTe","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"85024e08e4fe470f865d68c8eafc242a","outputId":"8076d462-1a47-49d2-eaf6-3e3d0348f836","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":3,"user_tz":240,"timestamp":1652654093950},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":"0 24.0\n1 21.6\n2 34.7\n3 33.4\n4 36.2\n ... \n501 22.4\n502 20.6\n503 23.9\n504 22.0\n505 11.9\nLength: 506, dtype: float64"},"metadata":{},"execution_count":22}],"execution_count":22},{"cell_type":"code","source":"#Creamos el objeteo XGBoost\nregressor = xgb.XGBRegressor(\n n_estimators=80,\n reg_lambda=1, # L1 regularization term on weights\n gamma=0, # Minimum loss reduction required to make a further partition on a leaf node of the tree\n max_depth=3\n)","metadata":{"id":"abilhiiCFlNu","cell_id":"601e2508348041fc93ef4a5106c24d5f","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":223,"user_tz":240,"timestamp":1652654095837},"deepnote_cell_type":"code"},"outputs":[],"execution_count":23},{"cell_type":"code","source":"#Fiteamos\nregressor.fit(X_train, y_train)","metadata":{"id":"h3fIHZiqFlNv","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"85a28e1e167b4139a76059ec6b4ee77b","outputId":"70bbe163-0f4d-46ce-ef9c-76909d6ad743","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":239,"user_tz":240,"timestamp":1652654096715},"deepnote_cell_type":"code"},"outputs":[{"output_type":"stream","name":"stdout","text":"[22:34:57] WARNING: /workspace/src/objective/regression_obj.cu:152: reg:linear is now deprecated in favor of reg:squarederror.\n"},{"output_type":"execute_result","data":{"text/plain":"XGBRegressor(n_estimators=80)"},"metadata":{},"execution_count":24}],"execution_count":24},{"cell_type":"code","source":"#Predecimos\ny_pred = regressor.predict(X_test)","metadata":{"id":"jBMrYUlrFlNw","cell_id":"db11c4089a4a40f9a98ae01b7748457c","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":405,"user_tz":240,"timestamp":1652654099816},"deepnote_cell_type":"code"},"outputs":[],"execution_count":25},{"cell_type":"code","source":"#Error\nmean_squared_error(y_test, y_pred)","metadata":{"id":"2uKlpW9EFlNw","colab":{"base_uri":"https://localhost:8080/"},"cell_id":"15d1967076a5470e8db67f53e3fb6987","outputId":"0886e963-0fda-4cbf-913a-9a0f8e43b906","executionInfo":{"user":{"userId":"09471607480253994520","displayName":"David Francisco Bustos Usta"},"status":"ok","elapsed":4,"user_tz":240,"timestamp":1652654100164},"deepnote_cell_type":"code"},"outputs":[{"output_type":"execute_result","data":{"text/plain":"0.17131945976806356"},"metadata":{},"execution_count":26}],"execution_count":26},{"cell_type":"markdown","source":"\nCreated in deepnote.com \nCreated in Deepnote","metadata":{"created_in_deepnote_cell":true,"deepnote_cell_type":"markdown"}}],"nbformat":4,"nbformat_minor":0,"metadata":{"toc":{"sideBar":true,"nav_menu":{},"toc_cell":false,"title_cell":"Table of Contents","toc_position":{},"skip_h1_title":false,"title_sidebar":"Contents","base_numbering":1,"number_sections":true,"toc_window_display":false,"toc_section_display":true},"colab":{"name":"Xgboost - CoderHouse (Ejemplo 2).ipynb","provenance":[],"collapsed_sections":[]},"deepnote":{},"kernelspec":{"name":"python3","language":"python","display_name":"Python 3"},"varInspector":{"cols":{"lenVar":40,"lenName":16,"lenType":16},"kernels_config":{"r":{"library":"var_list.r","varRefreshCmd":"cat(var_dic_list()) ","delete_cmd_prefix":"rm(","delete_cmd_postfix":") "},"python":{"library":"var_list.py","varRefreshCmd":"print(var_dic_list())","delete_cmd_prefix":"del ","delete_cmd_postfix":""}},"window_display":false,"types_to_exclude":["module","function","builtin_function_or_method","instance","_Feature"]},"language_info":{"name":"python","version":"3.8.5","mimetype":"text/x-python","file_extension":".py","pygments_lexer":"ipython3","codemirror_mode":{"name":"ipython","version":3},"nbconvert_exporter":"python"},"deepnote_notebook_id":"13f6c2abbe7b4ede81b23b3dd3a44706","deepnote_execution_queue":[]}}