{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "#Perform a practical on Decision Tree algorithm"
      ],
      "metadata": {
        "id": "ZqNhDEhh0gBI"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "from sklearn.tree import DecisionTreeClassifier\n",
        "from sklearn.model_selection import train_test_split\n",
        "from sklearn.metrics import accuracy_score\n",
        "from sklearn.datasets import load_iris\n",
        "\n",
        "# Load a sample dataset (Iris dataset)\n",
        "iris = load_iris()\n",
        "X = iris.data\n",
        "y = iris.target\n",
        "\n",
        "# Split the dataset into training and testing sets\n",
        "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n",
        "\n",
        "# Create a Decision Tree Classifier\n",
        "decision_tree = DecisionTreeClassifier()\n",
        "\n",
        "# Train the classifier\n",
        "decision_tree.fit(X_train, y_train)\n",
        "\n",
        "# Make predictions on the test set\n",
        "y_pred = decision_tree.predict(X_test)\n",
        "\n",
        "# Evaluate the accuracy of the classifier\n",
        "accuracy = accuracy_score(y_test, y_pred)\n",
        "print(f\"Accuracy: {accuracy}\")"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "FvU31UVD0pa_",
        "outputId": "e33c7b08-1bda-4d6c-9965-a7336ffaee41"
      },
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Accuracy: 1.0\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "id": "e04deb07",
        "outputId": "3e38824e-2e89-4aee-9bd2-3e1eadab15cc"
      },
      "source": [
        "from sklearn.tree import export_graphviz\n",
        "import graphviz\n",
        "\n",
        "# Export the decision tree to a DOT file\n",
        "dot_data = export_graphviz(decision_tree, out_file=None,\n",
        "                           feature_names=iris.feature_names,\n",
        "                           class_names=iris.target_names,\n",
        "                           filled=True, rounded=True,\n",
        "                           special_characters=True)\n",
        "\n",
        "# Visualize the tree using graphviz\n",
        "graph = graphviz.Source(dot_data)\n",
        "display(graph)"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.43.0 (0)\n -->\n<!-- Title: Tree Pages: 1 -->\n<svg width=\"751pt\" height=\"790pt\"\n viewBox=\"0.00 0.00 751.00 790.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 786)\">\n<title>Tree</title>\n<polygon fill=\"white\" stroke=\"transparent\" points=\"-4,4 -4,-786 747,-786 747,4 -4,4\"/>\n<!-- 0 -->\n<g id=\"node1\" class=\"node\">\n<title>0</title>\n<path fill=\"#fdfffd\" stroke=\"black\" d=\"M259.5,-782C259.5,-782 137.5,-782 137.5,-782 131.5,-782 125.5,-776 125.5,-770 125.5,-770 125.5,-711 125.5,-711 125.5,-705 131.5,-699 137.5,-699 137.5,-699 259.5,-699 259.5,-699 265.5,-699 271.5,-705 271.5,-711 271.5,-711 271.5,-770 271.5,-770 271.5,-776 265.5,-782 259.5,-782\"/>\n<text text-anchor=\"start\" x=\"133.5\" y=\"-766.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 0.8</text>\n<text text-anchor=\"start\" x=\"163\" y=\"-751.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.667</text>\n<text text-anchor=\"start\" x=\"153.5\" y=\"-736.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 120</text>\n<text text-anchor=\"start\" x=\"140.5\" y=\"-721.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [40, 41, 39]</text>\n<text text-anchor=\"start\" x=\"146\" y=\"-706.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 1 -->\n<g id=\"node2\" class=\"node\">\n<title>1</title>\n<path fill=\"#e58139\" stroke=\"black\" d=\"M167,-655.5C167,-655.5 74,-655.5 74,-655.5 68,-655.5 62,-649.5 62,-643.5 62,-643.5 62,-599.5 62,-599.5 62,-593.5 68,-587.5 74,-587.5 74,-587.5 167,-587.5 167,-587.5 173,-587.5 179,-593.5 179,-599.5 179,-599.5 179,-643.5 179,-643.5 179,-649.5 173,-655.5 167,-655.5\"/>\n<text text-anchor=\"start\" x=\"92.5\" y=\"-640.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"79.5\" y=\"-625.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 40</text>\n<text text-anchor=\"start\" x=\"70\" y=\"-610.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [40, 0, 0]</text>\n<text text-anchor=\"start\" x=\"77\" y=\"-595.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = setosa</text>\n</g>\n<!-- 0&#45;&gt;1 -->\n<g id=\"edge1\" class=\"edge\">\n<title>0&#45;&gt;1</title>\n<path fill=\"none\" stroke=\"black\" d=\"M171.44,-698.91C163.93,-687.65 155.78,-675.42 148.24,-664.11\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"151.07,-662.05 142.61,-655.67 145.25,-665.93 151.07,-662.05\"/>\n<text text-anchor=\"middle\" x=\"137.71\" y=\"-676.48\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n</g>\n<!-- 2 -->\n<g id=\"node3\" class=\"node\">\n<title>2</title>\n<path fill=\"#f5fef9\" stroke=\"black\" d=\"M344,-663C344,-663 209,-663 209,-663 203,-663 197,-657 197,-651 197,-651 197,-592 197,-592 197,-586 203,-580 209,-580 209,-580 344,-580 344,-580 350,-580 356,-586 356,-592 356,-592 356,-651 356,-651 356,-657 350,-663 344,-663\"/>\n<text text-anchor=\"start\" x=\"205\" y=\"-647.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 4.75</text>\n<text text-anchor=\"start\" x=\"248.5\" y=\"-632.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.5</text>\n<text text-anchor=\"start\" x=\"235.5\" y=\"-617.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 80</text>\n<text text-anchor=\"start\" x=\"222\" y=\"-602.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 41, 39]</text>\n<text text-anchor=\"start\" x=\"224\" y=\"-587.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 0&#45;&gt;2 -->\n<g id=\"edge2\" class=\"edge\">\n<title>0&#45;&gt;2</title>\n<path fill=\"none\" stroke=\"black\" d=\"M225.56,-698.91C231.43,-690.1 237.7,-680.7 243.76,-671.61\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"246.85,-673.28 249.49,-663.02 241.03,-669.4 246.85,-673.28\"/>\n<text text-anchor=\"middle\" x=\"254.39\" y=\"-683.84\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n</g>\n<!-- 3 -->\n<g id=\"node4\" class=\"node\">\n<title>3</title>\n<path fill=\"#3ee684\" stroke=\"black\" d=\"M255.5,-544C255.5,-544 125.5,-544 125.5,-544 119.5,-544 113.5,-538 113.5,-532 113.5,-532 113.5,-473 113.5,-473 113.5,-467 119.5,-461 125.5,-461 125.5,-461 255.5,-461 255.5,-461 261.5,-461 267.5,-467 267.5,-473 267.5,-473 267.5,-532 267.5,-532 267.5,-538 261.5,-544 255.5,-544\"/>\n<text text-anchor=\"start\" x=\"121.5\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.65</text>\n<text text-anchor=\"start\" x=\"155\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.053</text>\n<text text-anchor=\"start\" x=\"149.5\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 37</text>\n<text text-anchor=\"start\" x=\"140\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 36, 1]</text>\n<text text-anchor=\"start\" x=\"138\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 2&#45;&gt;3 -->\n<g id=\"edge3\" class=\"edge\">\n<title>2&#45;&gt;3</title>\n<path fill=\"none\" stroke=\"black\" d=\"M246.66,-579.91C240.13,-571.01 233.14,-561.51 226.39,-552.33\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"229.03,-550.01 220.28,-544.02 223.39,-554.15 229.03,-550.01\"/>\n</g>\n<!-- 6 -->\n<g id=\"node7\" class=\"node\">\n<title>6</title>\n<path fill=\"#9253e8\" stroke=\"black\" d=\"M427.5,-544C427.5,-544 297.5,-544 297.5,-544 291.5,-544 285.5,-538 285.5,-532 285.5,-532 285.5,-473 285.5,-473 285.5,-467 291.5,-461 297.5,-461 297.5,-461 427.5,-461 427.5,-461 433.5,-461 439.5,-467 439.5,-473 439.5,-473 439.5,-532 439.5,-532 439.5,-538 433.5,-544 427.5,-544\"/>\n<text text-anchor=\"start\" x=\"293.5\" y=\"-528.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.75</text>\n<text text-anchor=\"start\" x=\"327\" y=\"-513.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.206</text>\n<text text-anchor=\"start\" x=\"321.5\" y=\"-498.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 43</text>\n<text text-anchor=\"start\" x=\"312\" y=\"-483.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 5, 38]</text>\n<text text-anchor=\"start\" x=\"314\" y=\"-468.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 2&#45;&gt;6 -->\n<g id=\"edge6\" class=\"edge\">\n<title>2&#45;&gt;6</title>\n<path fill=\"none\" stroke=\"black\" d=\"M306.34,-579.91C312.87,-571.01 319.86,-561.51 326.61,-552.33\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"329.61,-554.15 332.72,-544.02 323.97,-550.01 329.61,-554.15\"/>\n</g>\n<!-- 4 -->\n<g id=\"node5\" class=\"node\">\n<title>4</title>\n<path fill=\"#39e581\" stroke=\"black\" d=\"M109,-417.5C109,-417.5 12,-417.5 12,-417.5 6,-417.5 0,-411.5 0,-405.5 0,-405.5 0,-361.5 0,-361.5 0,-355.5 6,-349.5 12,-349.5 12,-349.5 109,-349.5 109,-349.5 115,-349.5 121,-355.5 121,-361.5 121,-361.5 121,-405.5 121,-405.5 121,-411.5 115,-417.5 109,-417.5\"/>\n<text text-anchor=\"start\" x=\"32.5\" y=\"-402.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"19.5\" y=\"-387.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n<text text-anchor=\"start\" x=\"10\" y=\"-372.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 36, 0]</text>\n<text text-anchor=\"start\" x=\"8\" y=\"-357.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 3&#45;&gt;4 -->\n<g id=\"edge4\" class=\"edge\">\n<title>3&#45;&gt;4</title>\n<path fill=\"none\" stroke=\"black\" d=\"M145.4,-460.91C132.28,-449.1 117.96,-436.22 104.89,-424.45\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"107.13,-421.76 97.35,-417.67 102.44,-426.96 107.13,-421.76\"/>\n</g>\n<!-- 5 -->\n<g id=\"node6\" class=\"node\">\n<title>5</title>\n<path fill=\"#8139e5\" stroke=\"black\" d=\"M240,-417.5C240,-417.5 151,-417.5 151,-417.5 145,-417.5 139,-411.5 139,-405.5 139,-405.5 139,-361.5 139,-361.5 139,-355.5 145,-349.5 151,-349.5 151,-349.5 240,-349.5 240,-349.5 246,-349.5 252,-355.5 252,-361.5 252,-361.5 252,-405.5 252,-405.5 252,-411.5 246,-417.5 240,-417.5\"/>\n<text text-anchor=\"start\" x=\"167.5\" y=\"-402.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"158\" y=\"-387.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n<text text-anchor=\"start\" x=\"148.5\" y=\"-372.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n<text text-anchor=\"start\" x=\"147\" y=\"-357.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 3&#45;&gt;5 -->\n<g id=\"edge5\" class=\"edge\">\n<title>3&#45;&gt;5</title>\n<path fill=\"none\" stroke=\"black\" d=\"M192.23,-460.91C192.69,-450.2 193.19,-438.62 193.65,-427.78\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"197.15,-427.81 194.08,-417.67 190.16,-427.51 197.15,-427.81\"/>\n</g>\n<!-- 7 -->\n<g id=\"node8\" class=\"node\">\n<title>7</title>\n<path fill=\"#ffffff\" stroke=\"black\" d=\"M426,-425C426,-425 291,-425 291,-425 285,-425 279,-419 279,-413 279,-413 279,-354 279,-354 279,-348 285,-342 291,-342 291,-342 426,-342 426,-342 432,-342 438,-348 438,-354 438,-354 438,-413 438,-413 438,-419 432,-425 426,-425\"/>\n<text text-anchor=\"start\" x=\"287\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 4.95</text>\n<text text-anchor=\"start\" x=\"330.5\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.5</text>\n<text text-anchor=\"start\" x=\"321\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 8</text>\n<text text-anchor=\"start\" x=\"311.5\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 4]</text>\n<text text-anchor=\"start\" x=\"306\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 6&#45;&gt;7 -->\n<g id=\"edge7\" class=\"edge\">\n<title>6&#45;&gt;7</title>\n<path fill=\"none\" stroke=\"black\" d=\"M361.11,-460.91C360.83,-452.56 360.52,-443.67 360.23,-435.02\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"363.73,-434.9 359.89,-425.02 356.73,-435.13 363.73,-434.9\"/>\n</g>\n<!-- 14 -->\n<g id=\"node15\" class=\"node\">\n<title>14</title>\n<path fill=\"#853fe6\" stroke=\"black\" d=\"M603,-425C603,-425 468,-425 468,-425 462,-425 456,-419 456,-413 456,-413 456,-354 456,-354 456,-348 462,-342 468,-342 468,-342 603,-342 603,-342 609,-342 615,-348 615,-354 615,-354 615,-413 615,-413 615,-419 609,-425 603,-425\"/>\n<text text-anchor=\"start\" x=\"464\" y=\"-409.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 4.85</text>\n<text text-anchor=\"start\" x=\"500\" y=\"-394.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.056</text>\n<text text-anchor=\"start\" x=\"494.5\" y=\"-379.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 35</text>\n<text text-anchor=\"start\" x=\"485\" y=\"-364.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 34]</text>\n<text text-anchor=\"start\" x=\"487\" y=\"-349.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 6&#45;&gt;14 -->\n<g id=\"edge14\" class=\"edge\">\n<title>6&#45;&gt;14</title>\n<path fill=\"none\" stroke=\"black\" d=\"M422.52,-460.91C436.88,-451.2 452.31,-440.76 467.02,-430.81\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"469.26,-433.52 475.58,-425.02 465.34,-427.72 469.26,-433.52\"/>\n</g>\n<!-- 8 -->\n<g id=\"node9\" class=\"node\">\n<title>8</title>\n<path fill=\"#39e581\" stroke=\"black\" d=\"M254,-298.5C254,-298.5 157,-298.5 157,-298.5 151,-298.5 145,-292.5 145,-286.5 145,-286.5 145,-242.5 145,-242.5 145,-236.5 151,-230.5 157,-230.5 157,-230.5 254,-230.5 254,-230.5 260,-230.5 266,-236.5 266,-242.5 266,-242.5 266,-286.5 266,-286.5 266,-292.5 260,-298.5 254,-298.5\"/>\n<text text-anchor=\"start\" x=\"177.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"168\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n<text text-anchor=\"start\" x=\"158.5\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\n<text text-anchor=\"start\" x=\"153\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 7&#45;&gt;8 -->\n<g id=\"edge8\" class=\"edge\">\n<title>7&#45;&gt;8</title>\n<path fill=\"none\" stroke=\"black\" d=\"M305.42,-341.91C289.69,-329.88 272.5,-316.73 256.88,-304.79\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"258.94,-301.96 248.87,-298.67 254.69,-307.52 258.94,-301.96\"/>\n</g>\n<!-- 9 -->\n<g id=\"node10\" class=\"node\">\n<title>9</title>\n<path fill=\"#c09cf2\" stroke=\"black\" d=\"M426.5,-306C426.5,-306 296.5,-306 296.5,-306 290.5,-306 284.5,-300 284.5,-294 284.5,-294 284.5,-235 284.5,-235 284.5,-229 290.5,-223 296.5,-223 296.5,-223 426.5,-223 426.5,-223 432.5,-223 438.5,-229 438.5,-235 438.5,-235 438.5,-294 438.5,-294 438.5,-300 432.5,-306 426.5,-306\"/>\n<text text-anchor=\"start\" x=\"292.5\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal width (cm) ≤ 1.55</text>\n<text text-anchor=\"start\" x=\"326\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.444</text>\n<text text-anchor=\"start\" x=\"324\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 6</text>\n<text text-anchor=\"start\" x=\"314.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 4]</text>\n<text text-anchor=\"start\" x=\"313\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 7&#45;&gt;9 -->\n<g id=\"edge9\" class=\"edge\">\n<title>7&#45;&gt;9</title>\n<path fill=\"none\" stroke=\"black\" d=\"M359.54,-341.91C359.75,-333.56 359.98,-324.67 360.2,-316.02\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"363.7,-316.11 360.46,-306.02 356.71,-315.93 363.7,-316.11\"/>\n</g>\n<!-- 10 -->\n<g id=\"node11\" class=\"node\">\n<title>10</title>\n<path fill=\"#8139e5\" stroke=\"black\" d=\"M256,-179.5C256,-179.5 167,-179.5 167,-179.5 161,-179.5 155,-173.5 155,-167.5 155,-167.5 155,-123.5 155,-123.5 155,-117.5 161,-111.5 167,-111.5 167,-111.5 256,-111.5 256,-111.5 262,-111.5 268,-117.5 268,-123.5 268,-123.5 268,-167.5 268,-167.5 268,-173.5 262,-179.5 256,-179.5\"/>\n<text text-anchor=\"start\" x=\"183.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"174\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n<text text-anchor=\"start\" x=\"164.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 3]</text>\n<text text-anchor=\"start\" x=\"163\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 9&#45;&gt;10 -->\n<g id=\"edge10\" class=\"edge\">\n<title>9&#45;&gt;10</title>\n<path fill=\"none\" stroke=\"black\" d=\"M309.46,-222.91C294.18,-210.99 277.49,-197.98 262.29,-186.12\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"264.06,-183.06 254.02,-179.67 259.75,-188.58 264.06,-183.06\"/>\n</g>\n<!-- 11 -->\n<g id=\"node12\" class=\"node\">\n<title>11</title>\n<path fill=\"#9cf2c0\" stroke=\"black\" d=\"M433,-187C433,-187 298,-187 298,-187 292,-187 286,-181 286,-175 286,-175 286,-116 286,-116 286,-110 292,-104 298,-104 298,-104 433,-104 433,-104 439,-104 445,-110 445,-116 445,-116 445,-175 445,-175 445,-181 439,-187 433,-187\"/>\n<text text-anchor=\"start\" x=\"294\" y=\"-171.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">petal length (cm) ≤ 5.45</text>\n<text text-anchor=\"start\" x=\"330\" y=\"-156.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.444</text>\n<text text-anchor=\"start\" x=\"328\" y=\"-141.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n<text text-anchor=\"start\" x=\"318.5\" y=\"-126.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 1]</text>\n<text text-anchor=\"start\" x=\"313\" y=\"-111.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 9&#45;&gt;11 -->\n<g id=\"edge11\" class=\"edge\">\n<title>9&#45;&gt;11</title>\n<path fill=\"none\" stroke=\"black\" d=\"M362.89,-222.91C363.17,-214.56 363.48,-205.67 363.77,-197.02\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"367.27,-197.13 364.11,-187.02 360.27,-196.9 367.27,-197.13\"/>\n</g>\n<!-- 12 -->\n<g id=\"node13\" class=\"node\">\n<title>12</title>\n<path fill=\"#39e581\" stroke=\"black\" d=\"M347,-68C347,-68 250,-68 250,-68 244,-68 238,-62 238,-56 238,-56 238,-12 238,-12 238,-6 244,0 250,0 250,0 347,0 347,0 353,0 359,-6 359,-12 359,-12 359,-56 359,-56 359,-62 353,-68 347,-68\"/>\n<text text-anchor=\"start\" x=\"270.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"261\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n<text text-anchor=\"start\" x=\"251.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\n<text text-anchor=\"start\" x=\"246\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 11&#45;&gt;12 -->\n<g id=\"edge12\" class=\"edge\">\n<title>11&#45;&gt;12</title>\n<path fill=\"none\" stroke=\"black\" d=\"M340.55,-103.73C335.19,-94.97 329.52,-85.7 324.14,-76.91\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"327.08,-75 318.88,-68.3 321.11,-78.66 327.08,-75\"/>\n</g>\n<!-- 13 -->\n<g id=\"node14\" class=\"node\">\n<title>13</title>\n<path fill=\"#8139e5\" stroke=\"black\" d=\"M478,-68C478,-68 389,-68 389,-68 383,-68 377,-62 377,-56 377,-56 377,-12 377,-12 377,-6 383,0 389,0 389,0 478,0 478,0 484,0 490,-6 490,-12 490,-12 490,-56 490,-56 490,-62 484,-68 478,-68\"/>\n<text text-anchor=\"start\" x=\"405.5\" y=\"-52.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"396\" y=\"-37.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n<text text-anchor=\"start\" x=\"386.5\" y=\"-22.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n<text text-anchor=\"start\" x=\"385\" y=\"-7.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 11&#45;&gt;13 -->\n<g id=\"edge13\" class=\"edge\">\n<title>11&#45;&gt;13</title>\n<path fill=\"none\" stroke=\"black\" d=\"M390.82,-103.73C396.26,-94.97 402.01,-85.7 407.48,-76.91\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"410.52,-78.64 412.82,-68.3 404.57,-74.95 410.52,-78.64\"/>\n</g>\n<!-- 15 -->\n<g id=\"node16\" class=\"node\">\n<title>15</title>\n<path fill=\"#c09cf2\" stroke=\"black\" d=\"M596,-306C596,-306 471,-306 471,-306 465,-306 459,-300 459,-294 459,-294 459,-235 459,-235 459,-229 465,-223 471,-223 471,-223 596,-223 596,-223 602,-223 608,-229 608,-235 608,-235 608,-294 608,-294 608,-300 602,-306 596,-306\"/>\n<text text-anchor=\"start\" x=\"467\" y=\"-290.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">sepal width (cm) ≤ 3.1</text>\n<text text-anchor=\"start\" x=\"498\" y=\"-275.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.444</text>\n<text text-anchor=\"start\" x=\"496\" y=\"-260.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n<text text-anchor=\"start\" x=\"486.5\" y=\"-245.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 2]</text>\n<text text-anchor=\"start\" x=\"485\" y=\"-230.8\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 14&#45;&gt;15 -->\n<g id=\"edge15\" class=\"edge\">\n<title>14&#45;&gt;15</title>\n<path fill=\"none\" stroke=\"black\" d=\"M534.81,-341.91C534.66,-333.56 534.51,-324.67 534.36,-316.02\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"537.86,-315.96 534.19,-306.02 530.86,-316.08 537.86,-315.96\"/>\n</g>\n<!-- 18 -->\n<g id=\"node19\" class=\"node\">\n<title>18</title>\n<path fill=\"#8139e5\" stroke=\"black\" d=\"M731,-298.5C731,-298.5 638,-298.5 638,-298.5 632,-298.5 626,-292.5 626,-286.5 626,-286.5 626,-242.5 626,-242.5 626,-236.5 632,-230.5 638,-230.5 638,-230.5 731,-230.5 731,-230.5 737,-230.5 743,-236.5 743,-242.5 743,-242.5 743,-286.5 743,-286.5 743,-292.5 737,-298.5 731,-298.5\"/>\n<text text-anchor=\"start\" x=\"656.5\" y=\"-283.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"643.5\" y=\"-268.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 32</text>\n<text text-anchor=\"start\" x=\"634\" y=\"-253.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 32]</text>\n<text text-anchor=\"start\" x=\"636\" y=\"-238.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 14&#45;&gt;18 -->\n<g id=\"edge18\" class=\"edge\">\n<title>14&#45;&gt;18</title>\n<path fill=\"none\" stroke=\"black\" d=\"M587.19,-341.91C602.37,-329.99 618.95,-316.98 634.04,-305.12\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"636.56,-307.6 642.26,-298.67 632.24,-302.09 636.56,-307.6\"/>\n</g>\n<!-- 16 -->\n<g id=\"node17\" class=\"node\">\n<title>16</title>\n<path fill=\"#8139e5\" stroke=\"black\" d=\"M575,-179.5C575,-179.5 486,-179.5 486,-179.5 480,-179.5 474,-173.5 474,-167.5 474,-167.5 474,-123.5 474,-123.5 474,-117.5 480,-111.5 486,-111.5 486,-111.5 575,-111.5 575,-111.5 581,-111.5 587,-117.5 587,-123.5 587,-123.5 587,-167.5 587,-167.5 587,-173.5 581,-179.5 575,-179.5\"/>\n<text text-anchor=\"start\" x=\"502.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"493\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n<text text-anchor=\"start\" x=\"483.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 2]</text>\n<text text-anchor=\"start\" x=\"482\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = virginica</text>\n</g>\n<!-- 15&#45;&gt;16 -->\n<g id=\"edge16\" class=\"edge\">\n<title>15&#45;&gt;16</title>\n<path fill=\"none\" stroke=\"black\" d=\"M532.46,-222.91C532.18,-212.2 531.89,-200.62 531.61,-189.78\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"535.11,-189.57 531.35,-179.67 528.11,-189.75 535.11,-189.57\"/>\n</g>\n<!-- 17 -->\n<g id=\"node18\" class=\"node\">\n<title>17</title>\n<path fill=\"#39e581\" stroke=\"black\" d=\"M714,-179.5C714,-179.5 617,-179.5 617,-179.5 611,-179.5 605,-173.5 605,-167.5 605,-167.5 605,-123.5 605,-123.5 605,-117.5 611,-111.5 617,-111.5 617,-111.5 714,-111.5 714,-111.5 720,-111.5 726,-117.5 726,-123.5 726,-123.5 726,-167.5 726,-167.5 726,-173.5 720,-179.5 714,-179.5\"/>\n<text text-anchor=\"start\" x=\"637.5\" y=\"-164.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">gini = 0.0</text>\n<text text-anchor=\"start\" x=\"628\" y=\"-149.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n<text text-anchor=\"start\" x=\"618.5\" y=\"-134.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 0]</text>\n<text text-anchor=\"start\" x=\"613\" y=\"-119.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = versicolor</text>\n</g>\n<!-- 15&#45;&gt;17 -->\n<g id=\"edge17\" class=\"edge\">\n<title>15&#45;&gt;17</title>\n<path fill=\"none\" stroke=\"black\" d=\"M579.3,-222.91C592.62,-211.1 607.15,-198.22 620.43,-186.45\"/>\n<polygon fill=\"black\" stroke=\"black\" points=\"622.92,-188.92 628.08,-179.67 618.28,-183.68 622.92,-188.92\"/>\n</g>\n</g>\n</svg>\n",
            "text/plain": [
              "<graphviz.sources.Source at 0x7982b75064e0>"
            ]
          },
          "metadata": {}
        }
      ]
    }
  ]
}