{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "decisionTreeTutorial1.ipynb", "version": "0.3.2", "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "metadata": { "id": "XD8qqVh82jpk", "colab_type": "code", "colab": {} }, "cell_type": "code", "source": [ "from sklearn.model_selection import train_test_split\n", "from sklearn.tree import DecisionTreeClassifier\n", "import numpy as np\n", "import pandas as pd" ], "execution_count": 0, "outputs": [] }, { "metadata": { "id": "p-JobDUrUqj8", "colab_type": "text" }, "cell_type": "markdown", "source": [ "# Obteniendo los datos" ] }, { "metadata": { "id": "rM8Hi3Sa6KvU", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 196 }, "outputId": "d802c9e1-ec4f-44bf-a4da-0b9726ebf6ea" }, "cell_type": "code", "source": [ "!wget https://raw.githubusercontent.com/susanli2016/Machine-Learning-with-Python/master/diabetes.csv" ], "execution_count": 39, "outputs": [ { "output_type": "stream", "text": [ "--2018-10-14 23:42:51-- https://raw.githubusercontent.com/susanli2016/Machine-Learning-with-Python/master/diabetes.csv\n", "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.0.133, 151.101.64.133, 151.101.128.133, ...\n", "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.0.133|:443... connected.\n", "HTTP request sent, awaiting response... 200 OK\n", "Length: 23875 (23K) [text/plain]\n", "Saving to: ‘diabetes.csv’\n", "\n", "\rdiabetes.csv 0%[ ] 0 --.-KB/s \rdiabetes.csv 100%[===================>] 23.32K --.-KB/s in 0.008s \n", "\n", "2018-10-14 23:42:51 (2.91 MB/s) - ‘diabetes.csv’ saved [23875/23875]\n", "\n" ], "name": "stdout" } ] }, { "metadata": { "id": "AQH3mqGw6mb4", "colab_type": "code", "colab": {} }, "cell_type": "code", "source": [ "dataset = pd.read_csv(\"diabetes.csv\")" ], "execution_count": 0, "outputs": [] }, { "metadata": { "id": "zNf_2A507Ry1", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 191 }, "outputId": "03a6cdaf-fb39-40d9-ef6e-5095fa79a29a" }, "cell_type": "code", "source": [ "dataset.head()" ], "execution_count": 42, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", " | Pregnancies | \n", "Glucose | \n", "BloodPressure | \n", "SkinThickness | \n", "Insulin | \n", "BMI | \n", "DiabetesPedigreeFunction | \n", "Age | \n", "Outcome | \n", "
---|---|---|---|---|---|---|---|---|---|
0 | \n", "6 | \n", "148 | \n", "72 | \n", "35 | \n", "0 | \n", "33.6 | \n", "0.627 | \n", "50 | \n", "1 | \n", "
1 | \n", "1 | \n", "85 | \n", "66 | \n", "29 | \n", "0 | \n", "26.6 | \n", "0.351 | \n", "31 | \n", "0 | \n", "
2 | \n", "8 | \n", "183 | \n", "64 | \n", "0 | \n", "0 | \n", "23.3 | \n", "0.672 | \n", "32 | \n", "1 | \n", "
3 | \n", "1 | \n", "89 | \n", "66 | \n", "23 | \n", "94 | \n", "28.1 | \n", "0.167 | \n", "21 | \n", "0 | \n", "
4 | \n", "0 | \n", "137 | \n", "40 | \n", "35 | \n", "168 | \n", "43.1 | \n", "2.288 | \n", "33 | \n", "1 | \n", "