首页 > 编程语言 >决策树源码

决策树源码

时间:2024-09-15 20:53:46浏览次数:3  
标签:gt 45 value 源码 entropy samples class 决策树

 这是做了一些决策树的相关的测试可以参考一下

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "e48835ae-32cb-455f-bbac-291355781cdf",
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn import tree\n",
    "from sklearn.datasets import load_wine\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cc09ea10-ef9d-4905-8101-45721d5310b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "wine=load_wine()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1e5dfc32-6b73-4b82-a3c6-521b9c1a3280",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(178, 13)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "04145bc2-85de-416a-8bf9-8f5a87cf3f0b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n",
       "       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,\n",
       "       1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n",
       "       2, 2])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3e97db01-996a-4652-817d-94a6353aa7fb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>10</th>\n",
       "      <th>11</th>\n",
       "      <th>12</th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>14.23</td>\n",
       "      <td>1.71</td>\n",
       "      <td>2.43</td>\n",
       "      <td>15.6</td>\n",
       "      <td>127.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>3.06</td>\n",
       "      <td>0.28</td>\n",
       "      <td>2.29</td>\n",
       "      <td>5.64</td>\n",
       "      <td>1.04</td>\n",
       "      <td>3.92</td>\n",
       "      <td>1065.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>13.20</td>\n",
       "      <td>1.78</td>\n",
       "      <td>2.14</td>\n",
       "      <td>11.2</td>\n",
       "      <td>100.0</td>\n",
       "      <td>2.65</td>\n",
       "      <td>2.76</td>\n",
       "      <td>0.26</td>\n",
       "      <td>1.28</td>\n",
       "      <td>4.38</td>\n",
       "      <td>1.05</td>\n",
       "      <td>3.40</td>\n",
       "      <td>1050.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>13.16</td>\n",
       "      <td>2.36</td>\n",
       "      <td>2.67</td>\n",
       "      <td>18.6</td>\n",
       "      <td>101.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>3.24</td>\n",
       "      <td>0.30</td>\n",
       "      <td>2.81</td>\n",
       "      <td>5.68</td>\n",
       "      <td>1.03</td>\n",
       "      <td>3.17</td>\n",
       "      <td>1185.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>14.37</td>\n",
       "      <td>1.95</td>\n",
       "      <td>2.50</td>\n",
       "      <td>16.8</td>\n",
       "      <td>113.0</td>\n",
       "      <td>3.85</td>\n",
       "      <td>3.49</td>\n",
       "      <td>0.24</td>\n",
       "      <td>2.18</td>\n",
       "      <td>7.80</td>\n",
       "      <td>0.86</td>\n",
       "      <td>3.45</td>\n",
       "      <td>1480.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>13.24</td>\n",
       "      <td>2.59</td>\n",
       "      <td>2.87</td>\n",
       "      <td>21.0</td>\n",
       "      <td>118.0</td>\n",
       "      <td>2.80</td>\n",
       "      <td>2.69</td>\n",
       "      <td>0.39</td>\n",
       "      <td>1.82</td>\n",
       "      <td>4.32</td>\n",
       "      <td>1.04</td>\n",
       "      <td>2.93</td>\n",
       "      <td>735.0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>173</th>\n",
       "      <td>13.71</td>\n",
       "      <td>5.65</td>\n",
       "      <td>2.45</td>\n",
       "      <td>20.5</td>\n",
       "      <td>95.0</td>\n",
       "      <td>1.68</td>\n",
       "      <td>0.61</td>\n",
       "      <td>0.52</td>\n",
       "      <td>1.06</td>\n",
       "      <td>7.70</td>\n",
       "      <td>0.64</td>\n",
       "      <td>1.74</td>\n",
       "      <td>740.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>174</th>\n",
       "      <td>13.40</td>\n",
       "      <td>3.91</td>\n",
       "      <td>2.48</td>\n",
       "      <td>23.0</td>\n",
       "      <td>102.0</td>\n",
       "      <td>1.80</td>\n",
       "      <td>0.75</td>\n",
       "      <td>0.43</td>\n",
       "      <td>1.41</td>\n",
       "      <td>7.30</td>\n",
       "      <td>0.70</td>\n",
       "      <td>1.56</td>\n",
       "      <td>750.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>175</th>\n",
       "      <td>13.27</td>\n",
       "      <td>4.28</td>\n",
       "      <td>2.26</td>\n",
       "      <td>20.0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>1.59</td>\n",
       "      <td>0.69</td>\n",
       "      <td>0.43</td>\n",
       "      <td>1.35</td>\n",
       "      <td>10.20</td>\n",
       "      <td>0.59</td>\n",
       "      <td>1.56</td>\n",
       "      <td>835.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>176</th>\n",
       "      <td>13.17</td>\n",
       "      <td>2.59</td>\n",
       "      <td>2.37</td>\n",
       "      <td>20.0</td>\n",
       "      <td>120.0</td>\n",
       "      <td>1.65</td>\n",
       "      <td>0.68</td>\n",
       "      <td>0.53</td>\n",
       "      <td>1.46</td>\n",
       "      <td>9.30</td>\n",
       "      <td>0.60</td>\n",
       "      <td>1.62</td>\n",
       "      <td>840.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>177</th>\n",
       "      <td>14.13</td>\n",
       "      <td>4.10</td>\n",
       "      <td>2.74</td>\n",
       "      <td>24.5</td>\n",
       "      <td>96.0</td>\n",
       "      <td>2.05</td>\n",
       "      <td>0.76</td>\n",
       "      <td>0.56</td>\n",
       "      <td>1.35</td>\n",
       "      <td>9.20</td>\n",
       "      <td>0.61</td>\n",
       "      <td>1.60</td>\n",
       "      <td>560.0</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>178 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        0     1     2     3      4     5     6     7     8      9     10  \\\n",
       "0    14.23  1.71  2.43  15.6  127.0  2.80  3.06  0.28  2.29   5.64  1.04   \n",
       "1    13.20  1.78  2.14  11.2  100.0  2.65  2.76  0.26  1.28   4.38  1.05   \n",
       "2    13.16  2.36  2.67  18.6  101.0  2.80  3.24  0.30  2.81   5.68  1.03   \n",
       "3    14.37  1.95  2.50  16.8  113.0  3.85  3.49  0.24  2.18   7.80  0.86   \n",
       "4    13.24  2.59  2.87  21.0  118.0  2.80  2.69  0.39  1.82   4.32  1.04   \n",
       "..     ...   ...   ...   ...    ...   ...   ...   ...   ...    ...   ...   \n",
       "173  13.71  5.65  2.45  20.5   95.0  1.68  0.61  0.52  1.06   7.70  0.64   \n",
       "174  13.40  3.91  2.48  23.0  102.0  1.80  0.75  0.43  1.41   7.30  0.70   \n",
       "175  13.27  4.28  2.26  20.0  120.0  1.59  0.69  0.43  1.35  10.20  0.59   \n",
       "176  13.17  2.59  2.37  20.0  120.0  1.65  0.68  0.53  1.46   9.30  0.60   \n",
       "177  14.13  4.10  2.74  24.5   96.0  2.05  0.76  0.56  1.35   9.20  0.61   \n",
       "\n",
       "       11      12  0   \n",
       "0    3.92  1065.0   0  \n",
       "1    3.40  1050.0   0  \n",
       "2    3.17  1185.0   0  \n",
       "3    3.45  1480.0   0  \n",
       "4    2.93   735.0   0  \n",
       "..    ...     ...  ..  \n",
       "173  1.74   740.0   2  \n",
       "174  1.56   750.0   2  \n",
       "175  1.56   835.0   2  \n",
       "176  1.62   840.0   2  \n",
       "177  1.60   560.0   2  \n",
       "\n",
       "[178 rows x 14 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "pd.concat([pd.DataFrame(wine.data),pd.DataFrame(wine.target)],axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "2117a52e-6020-44ac-8103-ca41db457cdf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['alcohol',\n",
       " 'malic_acid',\n",
       " 'ash',\n",
       " 'alcalinity_of_ash',\n",
       " 'magnesium',\n",
       " 'total_phenols',\n",
       " 'flavanoids',\n",
       " 'nonflavanoid_phenols',\n",
       " 'proanthocyanins',\n",
       " 'color_intensity',\n",
       " 'hue',\n",
       " 'od280/od315_of_diluted_wines',\n",
       " 'proline']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.feature_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8fa4f4b1-0f91-4006-ab31-1d0ab5cfa3d8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array(['class_0', 'class_1', 'class_2'], dtype='<U7')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wine.target_names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "722f4dd9-f673-451e-b143-3a5fa58e5876",
   "metadata": {},
   "outputs": [],
   "source": [
    "Xtrain, Xtest, Ytrain, Ytest = train_test_split(wine.data,wine.target,test_size=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "85506514-ca4c-4fb9-bee7-9e90b40af945",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(124, 13)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Xtrain.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "1d64b341-effe-49bb-9f01-e15e45a1dfb7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(54, 13)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Xtest.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "0b39f1ea-73d1-4e93-82c1-c83c66d0abca",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "178"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "124+54"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "a9a7f8ed-1e16-4b2d-9869-1ae83631eb45",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9074074074074074"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf=tree.DecisionTreeClassifier(criterion=\"entropy\")\n",
    "clf=clf.fit(Xtrain,Ytrain)\n",
    "score=clf.score(Xtest,Ytest)\n",
    "score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "06817aeb-87bb-4234-b801-3d73f5e8246d",
   "metadata": {},
   "outputs": [
    {
     "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 12.0.0 (0)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"774pt\" height=\"599pt\"\n",
       " viewBox=\"0.00 0.00 773.50 599.25\" 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 595.25)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-595.25 769.5,-595.25 769.5,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#fffdfc\" stroke=\"black\" d=\"M319,-591.25C319,-591.25 211.5,-591.25 211.5,-591.25 205.5,-591.25 199.5,-585.25 199.5,-579.25 199.5,-579.25 199.5,-509.75 199.5,-509.75 199.5,-503.75 205.5,-497.75 211.5,-497.75 211.5,-497.75 319,-497.75 319,-497.75 325,-497.75 331,-503.75 331,-509.75 331,-509.75 331,-579.25 331,-579.25 331,-585.25 325,-591.25 319,-591.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"265.25\" y=\"-573.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 2.33</text>\n",
       "<text text-anchor=\"middle\" x=\"265.25\" y=\"-553.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.57</text>\n",
       "<text text-anchor=\"middle\" x=\"265.25\" y=\"-538.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 124</text>\n",
       "<text text-anchor=\"middle\" x=\"265.25\" y=\"-523.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 45, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"265.25\" y=\"-508.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#f4fef8\" stroke=\"black\" d=\"M244.25,-461.75C244.25,-461.75 144.25,-461.75 144.25,-461.75 138.25,-461.75 132.25,-455.75 132.25,-449.75 132.25,-449.75 132.25,-380.25 132.25,-380.25 132.25,-374.25 138.25,-368.25 144.25,-368.25 144.25,-368.25 244.25,-368.25 244.25,-368.25 250.25,-368.25 256.25,-374.25 256.25,-380.25 256.25,-380.25 256.25,-449.75 256.25,-449.75 256.25,-455.75 250.25,-461.75 244.25,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">颜色强度 &lt;= 3.9</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.999</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 68</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 35, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M239.62,-497.47C234.99,-489.16 230.12,-480.42 225.36,-471.87\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"228.5,-470.32 220.58,-463.29 222.39,-473.72 228.5,-470.32\"/>\n",
       "<text text-anchor=\"middle\" x=\"213\" y=\"-480.21\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 8 -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>8</title>\n",
       "<path fill=\"#eb9c64\" stroke=\"black\" d=\"M436.25,-461.75C436.25,-461.75 336.25,-461.75 336.25,-461.75 330.25,-461.75 324.25,-455.75 324.25,-449.75 324.25,-449.75 324.25,-380.25 324.25,-380.25 324.25,-374.25 330.25,-368.25 336.25,-368.25 336.25,-368.25 436.25,-368.25 436.25,-368.25 442.25,-368.25 448.25,-374.25 448.25,-380.25 448.25,-380.25 448.25,-449.75 448.25,-449.75 448.25,-455.75 442.25,-461.75 436.25,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">脯氨酸 &lt;= 737.0</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.677</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 56</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 10, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;8 -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>0&#45;&gt;8</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M308.93,-497.47C317.33,-488.62 326.2,-479.28 334.81,-470.2\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"337.24,-472.72 341.59,-463.06 332.17,-467.9 337.24,-472.72\"/>\n",
       "<text text-anchor=\"middle\" x=\"343.28\" y=\"-481.15\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M104.5,-322.12C104.5,-322.12 12,-322.12 12,-322.12 6,-322.12 0,-316.12 0,-310.12 0,-310.12 0,-260.88 0,-260.88 0,-254.88 6,-248.88 12,-248.88 12,-248.88 104.5,-248.88 104.5,-248.88 110.5,-248.88 116.5,-254.88 116.5,-260.88 116.5,-260.88 116.5,-310.12 116.5,-310.12 116.5,-316.12 110.5,-322.12 104.5,-322.12\"/>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-304.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-289.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 32</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-274.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 32, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-259.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M145.15,-367.97C132.04,-355.68 117.92,-342.44 104.95,-330.28\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"107.4,-327.78 97.71,-323.5 102.61,-332.89 107.4,-327.78\"/>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#8c4be7\" stroke=\"black\" d=\"M242,-332.25C242,-332.25 146.5,-332.25 146.5,-332.25 140.5,-332.25 134.5,-326.25 134.5,-320.25 134.5,-320.25 134.5,-250.75 134.5,-250.75 134.5,-244.75 140.5,-238.75 146.5,-238.75 146.5,-238.75 242,-238.75 242,-238.75 248,-238.75 254,-244.75 254,-250.75 254,-250.75 254,-320.25 254,-320.25 254,-326.25 248,-332.25 242,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 1.385</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.414</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 36</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;3 -->\n",
       "<g id=\"edge3\" class=\"edge\">\n",
       "<title>1&#45;&gt;3</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M194.25,-367.97C194.25,-360.12 194.25,-351.87 194.25,-343.77\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"197.75,-343.98 194.25,-333.98 190.75,-343.98 197.75,-343.98\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M109,-192.62C109,-192.62 13.5,-192.62 13.5,-192.62 7.5,-192.62 1.5,-186.62 1.5,-180.62 1.5,-180.62 1.5,-131.38 1.5,-131.38 1.5,-125.38 7.5,-119.38 13.5,-119.38 13.5,-119.38 109,-119.38 109,-119.38 115,-119.38 121,-125.38 121,-131.38 121,-131.38 121,-180.62 121,-180.62 121,-186.62 115,-192.62 109,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"61.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"61.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 32</text>\n",
       "<text text-anchor=\"middle\" x=\"61.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 32]</text>\n",
       "<text text-anchor=\"middle\" x=\"61.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M146.23,-238.47C133.42,-226.18 119.6,-212.94 106.92,-200.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"109.5,-198.4 99.86,-194.01 104.65,-203.46 109.5,-198.4\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>5</title>\n",
       "<path fill=\"#7beeab\" stroke=\"black\" d=\"M237.5,-202.75C237.5,-202.75 151,-202.75 151,-202.75 145,-202.75 139,-196.75 139,-190.75 139,-190.75 139,-121.25 139,-121.25 139,-115.25 145,-109.25 151,-109.25 151,-109.25 237.5,-109.25 237.5,-109.25 243.5,-109.25 249.5,-115.25 249.5,-121.25 249.5,-121.25 249.5,-190.75 249.5,-190.75 249.5,-196.75 243.5,-202.75 237.5,-202.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-185.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">灰 &lt;= 2.47</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-165.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.811</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-150.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-135.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-120.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M194.25,-238.47C194.25,-230.62 194.25,-222.37 194.25,-214.27\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"197.75,-214.48 194.25,-204.48 190.75,-214.48 197.75,-214.48\"/>\n",
       "</g>\n",
       "<!-- 6 -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>6</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M170.75,-73.25C170.75,-73.25 85.75,-73.25 85.75,-73.25 79.75,-73.25 73.75,-67.25 73.75,-61.25 73.75,-61.25 73.75,-12 73.75,-12 73.75,-6 79.75,0 85.75,0 85.75,0 170.75,0 170.75,0 176.75,0 182.75,-6 182.75,-12 182.75,-12 182.75,-61.25 182.75,-61.25 182.75,-67.25 176.75,-73.25 170.75,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"128.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"128.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n",
       "<text text-anchor=\"middle\" x=\"128.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"128.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;6 -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>5&#45;&gt;6</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M168.35,-108.95C163.63,-100.55 158.7,-91.78 153.98,-83.39\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"157.05,-81.7 149.1,-74.7 150.95,-85.14 157.05,-81.7\"/>\n",
       "</g>\n",
       "<!-- 7 -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>7</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M308,-73.25C308,-73.25 212.5,-73.25 212.5,-73.25 206.5,-73.25 200.5,-67.25 200.5,-61.25 200.5,-61.25 200.5,-12 200.5,-12 200.5,-6 206.5,0 212.5,0 212.5,0 308,0 308,0 314,0 320,-6 320,-12 320,-12 320,-61.25 320,-61.25 320,-67.25 314,-73.25 308,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"260.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"260.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"260.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"260.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;7 -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>5&#45;&gt;7</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M220.15,-108.95C224.87,-100.55 229.8,-91.78 234.52,-83.39\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"237.55,-85.14 239.4,-74.7 231.45,-81.7 237.55,-85.14\"/>\n",
       "</g>\n",
       "<!-- 9 -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>9</title>\n",
       "<path fill=\"#4fe88f\" stroke=\"black\" d=\"M429.5,-332.25C429.5,-332.25 343,-332.25 343,-332.25 337,-332.25 331,-326.25 331,-320.25 331,-320.25 331,-250.75 331,-250.75 331,-244.75 337,-238.75 343,-238.75 343,-238.75 429.5,-238.75 429.5,-238.75 435.5,-238.75 441.5,-244.75 441.5,-250.75 441.5,-250.75 441.5,-320.25 441.5,-320.25 441.5,-326.25 435.5,-332.25 429.5,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 13.175</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.469</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 10</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [1, 9, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"386.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;9 -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>8&#45;&gt;9</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M386.25,-367.97C386.25,-360.12 386.25,-351.87 386.25,-343.77\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"389.75,-343.98 386.25,-333.98 382.75,-343.98 389.75,-343.98\"/>\n",
       "</g>\n",
       "<!-- 12 -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>12</title>\n",
       "<path fill=\"#e6843d\" stroke=\"black\" d=\"M629.62,-332.25C629.62,-332.25 522.88,-332.25 522.88,-332.25 516.88,-332.25 510.88,-326.25 510.88,-320.25 510.88,-320.25 510.88,-250.75 510.88,-250.75 510.88,-244.75 516.88,-238.75 522.88,-238.75 522.88,-238.75 629.62,-238.75 629.62,-238.75 635.62,-238.75 641.62,-244.75 641.62,-250.75 641.62,-250.75 641.62,-320.25 641.62,-320.25 641.62,-326.25 635.62,-332.25 629.62,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">颜色强度 &lt;= 3.435</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.151</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 46</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [45, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;12 -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>8&#45;&gt;12</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M448.73,-372.08C465.43,-360.87 483.65,-348.64 500.96,-337.02\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"502.86,-339.96 509.22,-331.48 498.96,-334.15 502.86,-339.96\"/>\n",
       "</g>\n",
       "<!-- 10 -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>10</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M364.75,-192.62C364.75,-192.62 279.75,-192.62 279.75,-192.62 273.75,-192.62 267.75,-186.62 267.75,-180.62 267.75,-180.62 267.75,-131.38 267.75,-131.38 267.75,-125.38 273.75,-119.38 279.75,-119.38 279.75,-119.38 364.75,-119.38 364.75,-119.38 370.75,-119.38 376.75,-125.38 376.75,-131.38 376.75,-131.38 376.75,-180.62 376.75,-180.62 376.75,-186.62 370.75,-192.62 364.75,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"322.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"322.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 9</text>\n",
       "<text text-anchor=\"middle\" x=\"322.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 9, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"322.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M363.14,-238.47C357.39,-227 351.21,-214.7 345.45,-203.22\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"348.59,-201.68 340.98,-194.31 342.34,-204.82 348.59,-201.68\"/>\n",
       "</g>\n",
       "<!-- 11 -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>11</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M491.75,-192.62C491.75,-192.62 406.75,-192.62 406.75,-192.62 400.75,-192.62 394.75,-186.62 394.75,-180.62 394.75,-180.62 394.75,-131.38 394.75,-131.38 394.75,-125.38 400.75,-119.38 406.75,-119.38 406.75,-119.38 491.75,-119.38 491.75,-119.38 497.75,-119.38 503.75,-125.38 503.75,-131.38 503.75,-131.38 503.75,-180.62 503.75,-180.62 503.75,-186.62 497.75,-192.62 491.75,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"449.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"449.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"449.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [1, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"449.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</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=\"M408.99,-238.47C414.66,-227 420.74,-214.7 426.41,-203.22\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"429.52,-204.83 430.81,-194.32 423.24,-201.73 429.52,-204.83\"/>\n",
       "</g>\n",
       "<!-- 13 -->\n",
       "<g id=\"node14\" class=\"node\">\n",
       "<title>13</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M618.75,-192.62C618.75,-192.62 533.75,-192.62 533.75,-192.62 527.75,-192.62 521.75,-186.62 521.75,-180.62 521.75,-180.62 521.75,-131.38 521.75,-131.38 521.75,-125.38 527.75,-119.38 533.75,-119.38 533.75,-119.38 618.75,-119.38 618.75,-119.38 624.75,-119.38 630.75,-125.38 630.75,-131.38 630.75,-131.38 630.75,-180.62 630.75,-180.62 630.75,-186.62 624.75,-192.62 618.75,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"576.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 12&#45;&gt;13 -->\n",
       "<g id=\"edge13\" class=\"edge\">\n",
       "<title>12&#45;&gt;13</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M576.25,-238.47C576.25,-227.35 576.25,-215.45 576.25,-204.28\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"579.75,-204.47 576.25,-194.47 572.75,-204.47 579.75,-204.47\"/>\n",
       "</g>\n",
       "<!-- 14 -->\n",
       "<g id=\"node15\" class=\"node\">\n",
       "<title>14</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M753.5,-192.62C753.5,-192.62 661,-192.62 661,-192.62 655,-192.62 649,-186.62 649,-180.62 649,-180.62 649,-131.38 649,-131.38 649,-125.38 655,-119.38 661,-119.38 661,-119.38 753.5,-119.38 753.5,-119.38 759.5,-119.38 765.5,-125.38 765.5,-131.38 765.5,-131.38 765.5,-180.62 765.5,-180.62 765.5,-186.62 759.5,-192.62 753.5,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"707.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"707.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 45</text>\n",
       "<text text-anchor=\"middle\" x=\"707.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [45, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"707.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 12&#45;&gt;14 -->\n",
       "<g id=\"edge14\" class=\"edge\">\n",
       "<title>12&#45;&gt;14</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M623.54,-238.47C636.17,-226.18 649.77,-212.94 662.27,-200.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"664.49,-203.5 669.22,-194.02 659.61,-198.48 664.49,-203.5\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x2878b05b0>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "feature_name = ['酒精','苹果酸','灰','灰的碱性','镁','总酚','类黄酮','非黄烷类酚类','花青素','颜色强度','色调','od280/od315稀释葡萄酒','脯氨酸']\n",
    "\n",
    "import graphviz\n",
    "dot_data = tree.export_graphviz(clf\n",
    "                                ,out_file = None\n",
    "                                ,feature_names= feature_name\n",
    "                                ,class_names=[\"琴酒\",\"雪莉\",\"贝尔摩德\"]\n",
    "                                ,filled=True\n",
    "                                ,rounded=True\n",
    ")\n",
    "graph = graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "16d89ba7-e469-4222-86ed-27072386bfb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0.02409578, 0.        , 0.01667255, 0.        , 0.        ,\n",
       "       0.        , 0.51595287, 0.        , 0.        , 0.30831896,\n",
       "       0.        , 0.        , 0.13495985])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.feature_importances_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6af80686-3a6a-4dff-9d94-a74967897fd4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('酒精', 0.024095775711441454),\n",
       " ('苹果酸', 0.0),\n",
       " ('灰', 0.016672545323473092),\n",
       " ('灰的碱性', 0.0),\n",
       " ('镁', 0.0),\n",
       " ('总酚', 0.0),\n",
       " ('类黄酮', 0.5159528704512936),\n",
       " ('非黄烷类酚类', 0.0),\n",
       " ('花青素', 0.0),\n",
       " ('颜色强度', 0.3083189599480639),\n",
       " ('色调', 0.0),\n",
       " ('od280/od315稀释葡萄酒', 0.0),\n",
       " ('脯氨酸', 0.13495984856572807)]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[*zip(feature_name,clf.feature_importances_)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "932c4791-d8ce-4437-959b-ff4e5c12b68c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8703703703703703"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf = tree.DecisionTreeClassifier(criterion=\"entropy\",random_state=90)\n",
    "clf = clf.fit(Xtrain, Ytrain)\n",
    "score = clf.score(Xtest, Ytest) #返回预测的准确度\n",
    "score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "d39d8574-170d-43ae-8413-b4849706557e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.8518518518518519"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf=tree.DecisionTreeClassifier(criterion=\"entropy\"\n",
    "                               ,random_state=30\n",
    "                               ,splitter=\"random\"\n",
    "                               )\n",
    "\n",
    "clf=clf.fit(Xtrain,Ytrain)\n",
    "score=clf.score(Xtest,Ytest)\n",
    "\n",
    "score\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "08292c06-439f-4adf-a521-6198439484e7",
   "metadata": {},
   "outputs": [],
   "source": [
    "import graphviz"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "3f509ff0-e6ef-415a-b617-1a1f9ef5b4d0",
   "metadata": {},
   "outputs": [
    {
     "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 12.0.0 (0)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"1162pt\" height=\"858pt\"\n",
       " viewBox=\"0.00 0.00 1161.50 858.25\" 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 854.25)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-854.25 1157.5,-854.25 1157.5,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#fffdfc\" stroke=\"black\" d=\"M561,-850.25C561,-850.25 453.5,-850.25 453.5,-850.25 447.5,-850.25 441.5,-844.25 441.5,-838.25 441.5,-838.25 441.5,-768.75 441.5,-768.75 441.5,-762.75 447.5,-756.75 453.5,-756.75 453.5,-756.75 561,-756.75 561,-756.75 567,-756.75 573,-762.75 573,-768.75 573,-768.75 573,-838.25 573,-838.25 573,-844.25 567,-850.25 561,-850.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"507.25\" y=\"-832.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 1.714</text>\n",
       "<text text-anchor=\"middle\" x=\"507.25\" y=\"-812.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.57</text>\n",
       "<text text-anchor=\"middle\" x=\"507.25\" y=\"-797.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 124</text>\n",
       "<text text-anchor=\"middle\" x=\"507.25\" y=\"-782.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 45, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"507.25\" y=\"-767.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#c6a5f3\" stroke=\"black\" d=\"M485.25,-720.75C485.25,-720.75 385.25,-720.75 385.25,-720.75 379.25,-720.75 373.25,-714.75 373.25,-708.75 373.25,-708.75 373.25,-639.25 373.25,-639.25 373.25,-633.25 379.25,-627.25 385.25,-627.25 385.25,-627.25 485.25,-627.25 485.25,-627.25 491.25,-627.25 497.25,-633.25 497.25,-639.25 497.25,-639.25 497.25,-708.75 497.25,-708.75 497.25,-714.75 491.25,-720.75 485.25,-720.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-703.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 12.675</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-683.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.937</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-668.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 51</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-653.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 18, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-638.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M481.26,-756.47C476.57,-748.16 471.63,-739.42 466.8,-730.87\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"469.91,-729.27 461.95,-722.28 463.82,-732.71 469.91,-729.27\"/>\n",
       "<text text-anchor=\"middle\" x=\"454.51\" y=\"-739.25\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 14 -->\n",
       "<g id=\"node15\" class=\"node\">\n",
       "<title>14</title>\n",
       "<path fill=\"#f4cbad\" stroke=\"black\" d=\"M691.25,-720.75C691.25,-720.75 591.25,-720.75 591.25,-720.75 585.25,-720.75 579.25,-714.75 579.25,-708.75 579.25,-708.75 579.25,-639.25 579.25,-639.25 579.25,-633.25 585.25,-627.25 591.25,-627.25 591.25,-627.25 691.25,-627.25 691.25,-627.25 697.25,-627.25 703.25,-633.25 703.25,-639.25 703.25,-639.25 703.25,-708.75 703.25,-708.75 703.25,-714.75 697.25,-720.75 691.25,-720.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-703.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 13.103</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-683.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.951</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-668.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 73</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-653.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 27, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-638.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;14 -->\n",
       "<g id=\"edge14\" class=\"edge\">\n",
       "<title>0&#45;&gt;14</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M555.63,-756.47C565.11,-747.44 575.14,-737.9 584.87,-728.65\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"587.02,-731.43 591.85,-722.01 582.19,-726.36 587.02,-731.43\"/>\n",
       "<text text-anchor=\"middle\" x=\"592.32\" y=\"-740.16\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#63eb9c\" stroke=\"black\" d=\"M247.62,-591.25C247.62,-591.25 140.88,-591.25 140.88,-591.25 134.88,-591.25 128.88,-585.25 128.88,-579.25 128.88,-579.25 128.88,-509.75 128.88,-509.75 128.88,-503.75 134.88,-497.75 140.88,-497.75 140.88,-497.75 247.62,-497.75 247.62,-497.75 253.62,-497.75 259.62,-503.75 259.62,-509.75 259.62,-509.75 259.62,-579.25 259.62,-579.25 259.62,-585.25 253.62,-591.25 247.62,-591.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-573.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">颜色强度 &lt;= 5.958</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-553.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.672</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-538.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 17</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-523.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 14, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-508.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M372.87,-640C341.4,-623.35 302.97,-603.02 269.84,-585.49\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"271.55,-582.43 261.07,-580.85 268.27,-588.62 271.55,-582.43\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>5</title>\n",
       "<path fill=\"#9253e8\" stroke=\"black\" d=\"M483,-591.25C483,-591.25 387.5,-591.25 387.5,-591.25 381.5,-591.25 375.5,-585.25 375.5,-579.25 375.5,-579.25 375.5,-509.75 375.5,-509.75 375.5,-503.75 381.5,-497.75 387.5,-497.75 387.5,-497.75 483,-497.75 483,-497.75 489,-497.75 495,-503.75 495,-509.75 495,-509.75 495,-579.25 495,-579.25 495,-585.25 489,-591.25 483,-591.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-573.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 0.761</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-553.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.523</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-538.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 34</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-523.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 30]</text>\n",
       "<text text-anchor=\"middle\" x=\"435.25\" y=\"-508.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;5 -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>1&#45;&gt;5</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M435.25,-626.97C435.25,-619.12 435.25,-610.87 435.25,-602.77\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"438.75,-602.98 435.25,-592.98 431.75,-602.98 438.75,-602.98\"/>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M104.5,-451.62C104.5,-451.62 12,-451.62 12,-451.62 6,-451.62 0,-445.62 0,-439.62 0,-439.62 0,-390.38 0,-390.38 0,-384.38 6,-378.38 12,-378.38 12,-378.38 104.5,-378.38 104.5,-378.38 110.5,-378.38 116.5,-384.38 116.5,-390.38 116.5,-390.38 116.5,-439.62 116.5,-439.62 116.5,-445.62 110.5,-451.62 104.5,-451.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-434.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-419.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 14</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-404.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 14, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-389.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M145.15,-497.47C132.04,-485.18 117.92,-471.94 104.95,-459.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"107.4,-457.28 97.71,-453 102.61,-462.39 107.4,-457.28\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M242,-451.62C242,-451.62 146.5,-451.62 146.5,-451.62 140.5,-451.62 134.5,-445.62 134.5,-439.62 134.5,-439.62 134.5,-390.38 134.5,-390.38 134.5,-384.38 140.5,-378.38 146.5,-378.38 146.5,-378.38 242,-378.38 242,-378.38 248,-378.38 254,-384.38 254,-390.38 254,-390.38 254,-439.62 254,-439.62 254,-445.62 248,-451.62 242,-451.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-434.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-419.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-404.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-389.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;4 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>2&#45;&gt;4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M194.25,-497.47C194.25,-486.35 194.25,-474.45 194.25,-463.28\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"197.75,-463.47 194.25,-453.47 190.75,-463.47 197.75,-463.47\"/>\n",
       "</g>\n",
       "<!-- 6 -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>6</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M380,-451.62C380,-451.62 284.5,-451.62 284.5,-451.62 278.5,-451.62 272.5,-445.62 272.5,-439.62 272.5,-439.62 272.5,-390.38 272.5,-390.38 272.5,-384.38 278.5,-378.38 284.5,-378.38 284.5,-378.38 380,-378.38 380,-378.38 386,-378.38 392,-384.38 392,-390.38 392,-390.38 392,-439.62 392,-439.62 392,-445.62 386,-451.62 380,-451.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-434.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-419.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 18</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-404.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 18]</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-389.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;6 -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>5&#45;&gt;6</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M398.06,-497.47C388.42,-485.53 378.05,-472.7 368.46,-460.82\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"371.26,-458.72 362.25,-453.14 365.81,-463.12 371.26,-458.72\"/>\n",
       "</g>\n",
       "<!-- 7 -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>7</title>\n",
       "<path fill=\"#ab7bee\" stroke=\"black\" d=\"M518,-461.75C518,-461.75 422.5,-461.75 422.5,-461.75 416.5,-461.75 410.5,-455.75 410.5,-449.75 410.5,-449.75 410.5,-380.25 410.5,-380.25 410.5,-374.25 416.5,-368.25 422.5,-368.25 422.5,-368.25 518,-368.25 518,-368.25 524,-368.25 530,-374.25 530,-380.25 530,-380.25 530,-449.75 530,-449.75 530,-455.75 524,-461.75 518,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"470.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">色调 &lt;= 0.654</text>\n",
       "<text text-anchor=\"middle\" x=\"470.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.811</text>\n",
       "<text text-anchor=\"middle\" x=\"470.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 16</text>\n",
       "<text text-anchor=\"middle\" x=\"470.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 12]</text>\n",
       "<text text-anchor=\"middle\" x=\"470.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;7 -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>5&#45;&gt;7</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M447.89,-497.47C450.07,-489.53 452.36,-481.18 454.61,-472.99\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"457.96,-473.99 457.23,-463.42 451.21,-472.14 457.96,-473.99\"/>\n",
       "</g>\n",
       "<!-- 8 -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>8</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M406,-322.12C406,-322.12 310.5,-322.12 310.5,-322.12 304.5,-322.12 298.5,-316.12 298.5,-310.12 298.5,-310.12 298.5,-260.88 298.5,-260.88 298.5,-254.88 304.5,-248.88 310.5,-248.88 310.5,-248.88 406,-248.88 406,-248.88 412,-248.88 418,-254.88 418,-260.88 418,-260.88 418,-310.12 418,-310.12 418,-316.12 412,-322.12 406,-322.12\"/>\n",
       "<text text-anchor=\"middle\" x=\"358.25\" y=\"-304.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"358.25\" y=\"-289.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 7</text>\n",
       "<text text-anchor=\"middle\" x=\"358.25\" y=\"-274.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 7]</text>\n",
       "<text text-anchor=\"middle\" x=\"358.25\" y=\"-259.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M429.82,-367.97C419.23,-355.92 407.83,-342.94 397.32,-330.97\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"400.07,-328.8 390.84,-323.6 394.81,-333.42 400.07,-328.8\"/>\n",
       "</g>\n",
       "<!-- 9 -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>9</title>\n",
       "<path fill=\"#e6d7fa\" stroke=\"black\" d=\"M576.12,-332.25C576.12,-332.25 448.38,-332.25 448.38,-332.25 442.38,-332.25 436.38,-326.25 436.38,-320.25 436.38,-320.25 436.38,-250.75 436.38,-250.75 436.38,-244.75 442.38,-238.75 448.38,-238.75 448.38,-238.75 576.12,-238.75 576.12,-238.75 582.12,-238.75 588.12,-244.75 588.12,-250.75 588.12,-250.75 588.12,-320.25 588.12,-320.25 588.12,-326.25 582.12,-332.25 576.12,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">非黄烷类酚类 &lt;= 0.43</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.991</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 9</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 5]</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M485.41,-367.97C488.06,-359.93 490.84,-351.49 493.57,-343.21\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"496.83,-344.49 496.64,-333.9 490.18,-342.3 496.83,-344.49\"/>\n",
       "</g>\n",
       "<!-- 10 -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>10</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M493,-192.62C493,-192.62 397.5,-192.62 397.5,-192.62 391.5,-192.62 385.5,-186.62 385.5,-180.62 385.5,-180.62 385.5,-131.38 385.5,-131.38 385.5,-125.38 391.5,-119.38 397.5,-119.38 397.5,-119.38 493,-119.38 493,-119.38 499,-119.38 505,-125.38 505,-131.38 505,-131.38 505,-180.62 505,-180.62 505,-186.62 499,-192.62 493,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"445.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"445.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\n",
       "<text text-anchor=\"middle\" x=\"445.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 4]</text>\n",
       "<text text-anchor=\"middle\" x=\"445.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M488.06,-238.47C481.97,-226.88 475.44,-214.45 469.36,-202.87\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"472.6,-201.53 464.85,-194.3 466.4,-204.78 472.6,-201.53\"/>\n",
       "</g>\n",
       "<!-- 11 -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>11</title>\n",
       "<path fill=\"#6aeca0\" stroke=\"black\" d=\"M621.5,-202.75C621.5,-202.75 535,-202.75 535,-202.75 529,-202.75 523,-196.75 523,-190.75 523,-190.75 523,-121.25 523,-121.25 523,-115.25 529,-109.25 535,-109.25 535,-109.25 621.5,-109.25 621.5,-109.25 627.5,-109.25 633.5,-115.25 633.5,-121.25 633.5,-121.25 633.5,-190.75 633.5,-190.75 633.5,-196.75 627.5,-202.75 621.5,-202.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"578.25\" y=\"-185.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">灰 &lt;= 2.553</text>\n",
       "<text text-anchor=\"middle\" x=\"578.25\" y=\"-165.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.722</text>\n",
       "<text text-anchor=\"middle\" x=\"578.25\" y=\"-150.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 5</text>\n",
       "<text text-anchor=\"middle\" x=\"578.25\" y=\"-135.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"578.25\" y=\"-120.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M536.08,-238.47C540.33,-230.25 544.8,-221.61 549.18,-213.15\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"552.27,-214.8 553.76,-204.31 546.06,-211.58 552.27,-214.8\"/>\n",
       "</g>\n",
       "<!-- 12 -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>12</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M554.75,-73.25C554.75,-73.25 469.75,-73.25 469.75,-73.25 463.75,-73.25 457.75,-67.25 457.75,-61.25 457.75,-61.25 457.75,-12 457.75,-12 457.75,-6 463.75,0 469.75,0 469.75,0 554.75,0 554.75,0 560.75,0 566.75,-6 566.75,-12 566.75,-12 566.75,-61.25 566.75,-61.25 566.75,-67.25 560.75,-73.25 554.75,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"512.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M552.35,-108.95C547.63,-100.55 542.7,-91.78 537.98,-83.39\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"541.05,-81.7 533.1,-74.7 534.95,-85.14 541.05,-81.7\"/>\n",
       "</g>\n",
       "<!-- 13 -->\n",
       "<g id=\"node14\" class=\"node\">\n",
       "<title>13</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M692,-73.25C692,-73.25 596.5,-73.25 596.5,-73.25 590.5,-73.25 584.5,-67.25 584.5,-61.25 584.5,-61.25 584.5,-12 584.5,-12 584.5,-6 590.5,0 596.5,0 596.5,0 692,0 692,0 698,0 704,-6 704,-12 704,-12 704,-61.25 704,-61.25 704,-67.25 698,-73.25 692,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"644.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"644.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"644.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 1]</text>\n",
       "<text text-anchor=\"middle\" x=\"644.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M604.15,-108.95C608.87,-100.55 613.8,-91.78 618.52,-83.39\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"621.55,-85.14 623.4,-74.7 615.45,-81.7 621.55,-85.14\"/>\n",
       "</g>\n",
       "<!-- 15 -->\n",
       "<g id=\"node16\" class=\"node\">\n",
       "<title>15</title>\n",
       "<path fill=\"#5ae996\" stroke=\"black\" d=\"M695,-591.25C695,-591.25 587.5,-591.25 587.5,-591.25 581.5,-591.25 575.5,-585.25 575.5,-579.25 575.5,-579.25 575.5,-509.75 575.5,-509.75 575.5,-503.75 581.5,-497.75 587.5,-497.75 587.5,-497.75 695,-497.75 695,-497.75 701,-497.75 707,-503.75 707,-509.75 707,-509.75 707,-579.25 707,-579.25 707,-585.25 701,-591.25 695,-591.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-573.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">脯氨酸 &lt;= 740.027</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-553.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.592</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-538.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 28</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-523.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [4, 24, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"641.25\" y=\"-508.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M641.25,-626.97C641.25,-619.12 641.25,-610.87 641.25,-602.77\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"644.75,-602.98 641.25,-592.98 637.75,-602.98 644.75,-602.98\"/>\n",
       "</g>\n",
       "<!-- 20 -->\n",
       "<g id=\"node21\" class=\"node\">\n",
       "<title>20</title>\n",
       "<path fill=\"#e78a47\" stroke=\"black\" d=\"M932.5,-591.25C932.5,-591.25 840,-591.25 840,-591.25 834,-591.25 828,-585.25 828,-579.25 828,-579.25 828,-509.75 828,-509.75 828,-503.75 834,-497.75 840,-497.75 840,-497.75 932.5,-497.75 932.5,-497.75 938.5,-497.75 944.5,-503.75 944.5,-509.75 944.5,-509.75 944.5,-579.25 944.5,-579.25 944.5,-585.25 938.5,-591.25 932.5,-591.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-573.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 2.407</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-553.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.353</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-538.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 45</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-523.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [42, 3, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-508.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 14&#45;&gt;20 -->\n",
       "<g id=\"edge20\" class=\"edge\">\n",
       "<title>14&#45;&gt;20</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M703.71,-640.5C738.57,-622.36 782.04,-599.73 817.82,-581.11\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"819.1,-584.39 826.35,-576.67 815.87,-578.18 819.1,-584.39\"/>\n",
       "</g>\n",
       "<!-- 16 -->\n",
       "<g id=\"node17\" class=\"node\">\n",
       "<title>16</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M652.5,-451.62C652.5,-451.62 560,-451.62 560,-451.62 554,-451.62 548,-445.62 548,-439.62 548,-439.62 548,-390.38 548,-390.38 548,-384.38 554,-378.38 560,-378.38 560,-378.38 652.5,-378.38 652.5,-378.38 658.5,-378.38 664.5,-384.38 664.5,-390.38 664.5,-390.38 664.5,-439.62 664.5,-439.62 664.5,-445.62 658.5,-451.62 652.5,-451.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"606.25\" y=\"-434.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"606.25\" y=\"-419.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 21</text>\n",
       "<text text-anchor=\"middle\" x=\"606.25\" y=\"-404.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 21, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"606.25\" y=\"-389.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M628.61,-497.47C625.53,-486.24 622.23,-474.2 619.13,-462.93\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"622.54,-462.14 616.52,-453.42 615.79,-463.99 622.54,-462.14\"/>\n",
       "</g>\n",
       "<!-- 17 -->\n",
       "<g id=\"node18\" class=\"node\">\n",
       "<title>17</title>\n",
       "<path fill=\"#f8e0ce\" stroke=\"black\" d=\"M801.62,-461.75C801.62,-461.75 694.88,-461.75 694.88,-461.75 688.88,-461.75 682.88,-455.75 682.88,-449.75 682.88,-449.75 682.88,-380.25 682.88,-380.25 682.88,-374.25 688.88,-368.25 694.88,-368.25 694.88,-368.25 801.62,-368.25 801.62,-368.25 807.62,-368.25 813.62,-374.25 813.62,-380.25 813.62,-380.25 813.62,-449.75 813.62,-449.75 813.62,-455.75 807.62,-461.75 801.62,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"748.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">颜色强度 &lt;= 3.407</text>\n",
       "<text text-anchor=\"middle\" x=\"748.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.985</text>\n",
       "<text text-anchor=\"middle\" x=\"748.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 7</text>\n",
       "<text text-anchor=\"middle\" x=\"748.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [4, 3, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"748.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</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=\"M679.88,-497.47C687.15,-488.8 694.82,-479.66 702.3,-470.76\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"704.96,-473.03 708.7,-463.12 699.59,-468.53 704.96,-473.03\"/>\n",
       "</g>\n",
       "<!-- 18 -->\n",
       "<g id=\"node19\" class=\"node\">\n",
       "<title>18</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M703.75,-322.12C703.75,-322.12 618.75,-322.12 618.75,-322.12 612.75,-322.12 606.75,-316.12 606.75,-310.12 606.75,-310.12 606.75,-260.88 606.75,-260.88 606.75,-254.88 612.75,-248.88 618.75,-248.88 618.75,-248.88 703.75,-248.88 703.75,-248.88 709.75,-248.88 715.75,-254.88 715.75,-260.88 715.75,-260.88 715.75,-310.12 715.75,-310.12 715.75,-316.12 709.75,-322.12 703.75,-322.12\"/>\n",
       "<text text-anchor=\"middle\" x=\"661.25\" y=\"-304.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"661.25\" y=\"-289.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n",
       "<text text-anchor=\"middle\" x=\"661.25\" y=\"-274.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 3, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"661.25\" y=\"-259.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 17&#45;&gt;18 -->\n",
       "<g id=\"edge18\" class=\"edge\">\n",
       "<title>17&#45;&gt;18</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M716.84,-367.97C708.78,-356.15 700.11,-343.45 692.07,-331.67\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"695.17,-330 686.64,-323.71 689.39,-333.94 695.17,-330\"/>\n",
       "</g>\n",
       "<!-- 19 -->\n",
       "<g id=\"node20\" class=\"node\">\n",
       "<title>19</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M830.75,-322.12C830.75,-322.12 745.75,-322.12 745.75,-322.12 739.75,-322.12 733.75,-316.12 733.75,-310.12 733.75,-310.12 733.75,-260.88 733.75,-260.88 733.75,-254.88 739.75,-248.88 745.75,-248.88 745.75,-248.88 830.75,-248.88 830.75,-248.88 836.75,-248.88 842.75,-254.88 842.75,-260.88 842.75,-260.88 842.75,-310.12 842.75,-310.12 842.75,-316.12 836.75,-322.12 830.75,-322.12\"/>\n",
       "<text text-anchor=\"middle\" x=\"788.25\" y=\"-304.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"788.25\" y=\"-289.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 4</text>\n",
       "<text text-anchor=\"middle\" x=\"788.25\" y=\"-274.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [4, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"788.25\" y=\"-259.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 17&#45;&gt;19 -->\n",
       "<g id=\"edge19\" class=\"edge\">\n",
       "<title>17&#45;&gt;19</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M762.69,-367.97C766.22,-356.74 769.99,-344.7 773.53,-333.43\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"776.86,-334.49 776.51,-323.91 770.18,-332.4 776.86,-334.49\"/>\n",
       "</g>\n",
       "<!-- 21 -->\n",
       "<g id=\"node22\" class=\"node\">\n",
       "<title>21</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M928.75,-451.62C928.75,-451.62 843.75,-451.62 843.75,-451.62 837.75,-451.62 831.75,-445.62 831.75,-439.62 831.75,-439.62 831.75,-390.38 831.75,-390.38 831.75,-384.38 837.75,-378.38 843.75,-378.38 843.75,-378.38 928.75,-378.38 928.75,-378.38 934.75,-378.38 940.75,-384.38 940.75,-390.38 940.75,-390.38 940.75,-439.62 940.75,-439.62 940.75,-445.62 934.75,-451.62 928.75,-451.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-434.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-419.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 2</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-404.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 2, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"886.25\" y=\"-389.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 20&#45;&gt;21 -->\n",
       "<g id=\"edge21\" class=\"edge\">\n",
       "<title>20&#45;&gt;21</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M886.25,-497.47C886.25,-486.35 886.25,-474.45 886.25,-463.28\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"889.75,-463.47 886.25,-453.47 882.75,-463.47 889.75,-463.47\"/>\n",
       "</g>\n",
       "<!-- 22 -->\n",
       "<g id=\"node23\" class=\"node\">\n",
       "<title>22</title>\n",
       "<path fill=\"#e6843e\" stroke=\"black\" d=\"M1085.75,-461.75C1085.75,-461.75 970.75,-461.75 970.75,-461.75 964.75,-461.75 958.75,-455.75 958.75,-449.75 958.75,-449.75 958.75,-380.25 958.75,-380.25 958.75,-374.25 964.75,-368.25 970.75,-368.25 970.75,-368.25 1085.75,-368.25 1085.75,-368.25 1091.75,-368.25 1097.75,-374.25 1097.75,-380.25 1097.75,-380.25 1097.75,-449.75 1097.75,-449.75 1097.75,-455.75 1091.75,-461.75 1085.75,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"1028.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">脯氨酸 &lt;= 1053.589</text>\n",
       "<text text-anchor=\"middle\" x=\"1028.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.159</text>\n",
       "<text text-anchor=\"middle\" x=\"1028.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 43</text>\n",
       "<text text-anchor=\"middle\" x=\"1028.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [42, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"1028.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 20&#45;&gt;22 -->\n",
       "<g id=\"edge22\" class=\"edge\">\n",
       "<title>20&#45;&gt;22</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M937.52,-497.47C947.57,-488.44 958.2,-478.9 968.5,-469.65\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"970.83,-472.26 975.93,-462.97 966.15,-467.05 970.83,-472.26\"/>\n",
       "</g>\n",
       "<!-- 23 -->\n",
       "<g id=\"node24\" class=\"node\">\n",
       "<title>23</title>\n",
       "<path fill=\"#e78a47\" stroke=\"black\" d=\"M1006.5,-332.25C1006.5,-332.25 914,-332.25 914,-332.25 908,-332.25 902,-326.25 902,-320.25 902,-320.25 902,-250.75 902,-250.75 902,-244.75 908,-238.75 914,-238.75 914,-238.75 1006.5,-238.75 1006.5,-238.75 1012.5,-238.75 1018.5,-244.75 1018.5,-250.75 1018.5,-250.75 1018.5,-320.25 1018.5,-320.25 1018.5,-326.25 1012.5,-332.25 1006.5,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"960.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">灰 &lt;= 1.864</text>\n",
       "<text text-anchor=\"middle\" x=\"960.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.353</text>\n",
       "<text text-anchor=\"middle\" x=\"960.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 15</text>\n",
       "<text text-anchor=\"middle\" x=\"960.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [14, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"960.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 22&#45;&gt;23 -->\n",
       "<g id=\"edge23\" class=\"edge\">\n",
       "<title>22&#45;&gt;23</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M1003.7,-367.97C999.27,-359.66 994.61,-350.92 990.05,-342.37\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"993.27,-340.97 985.48,-333.8 987.09,-344.27 993.27,-340.97\"/>\n",
       "</g>\n",
       "<!-- 26 -->\n",
       "<g id=\"node27\" class=\"node\">\n",
       "<title>26</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M1141.5,-322.12C1141.5,-322.12 1049,-322.12 1049,-322.12 1043,-322.12 1037,-316.12 1037,-310.12 1037,-310.12 1037,-260.88 1037,-260.88 1037,-254.88 1043,-248.88 1049,-248.88 1049,-248.88 1141.5,-248.88 1141.5,-248.88 1147.5,-248.88 1153.5,-254.88 1153.5,-260.88 1153.5,-260.88 1153.5,-310.12 1153.5,-310.12 1153.5,-316.12 1147.5,-322.12 1141.5,-322.12\"/>\n",
       "<text text-anchor=\"middle\" x=\"1095.25\" y=\"-304.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"1095.25\" y=\"-289.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 28</text>\n",
       "<text text-anchor=\"middle\" x=\"1095.25\" y=\"-274.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [28, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"1095.25\" y=\"-259.82\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 22&#45;&gt;26 -->\n",
       "<g id=\"edge26\" class=\"edge\">\n",
       "<title>22&#45;&gt;26</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M1052.44,-367.97C1058.53,-356.38 1065.06,-343.95 1071.14,-332.37\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"1074.1,-334.28 1075.65,-323.8 1067.9,-331.03 1074.1,-334.28\"/>\n",
       "</g>\n",
       "<!-- 24 -->\n",
       "<g id=\"node25\" class=\"node\">\n",
       "<title>24</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M936.75,-192.62C936.75,-192.62 851.75,-192.62 851.75,-192.62 845.75,-192.62 839.75,-186.62 839.75,-180.62 839.75,-180.62 839.75,-131.38 839.75,-131.38 839.75,-125.38 845.75,-119.38 851.75,-119.38 851.75,-119.38 936.75,-119.38 936.75,-119.38 942.75,-119.38 948.75,-125.38 948.75,-131.38 948.75,-131.38 948.75,-180.62 948.75,-180.62 948.75,-186.62 942.75,-192.62 936.75,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"894.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"894.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 1</text>\n",
       "<text text-anchor=\"middle\" x=\"894.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 1, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"894.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 23&#45;&gt;24 -->\n",
       "<g id=\"edge24\" class=\"edge\">\n",
       "<title>23&#45;&gt;24</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M936.42,-238.47C930.43,-226.88 923.99,-214.45 918,-202.87\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"921.27,-201.58 913.56,-194.31 915.05,-204.8 921.27,-201.58\"/>\n",
       "</g>\n",
       "<!-- 25 -->\n",
       "<g id=\"node26\" class=\"node\">\n",
       "<title>25</title>\n",
       "<path fill=\"#e58139\" stroke=\"black\" d=\"M1071.5,-192.62C1071.5,-192.62 979,-192.62 979,-192.62 973,-192.62 967,-186.62 967,-180.62 967,-180.62 967,-131.38 967,-131.38 967,-125.38 973,-119.38 979,-119.38 979,-119.38 1071.5,-119.38 1071.5,-119.38 1077.5,-119.38 1083.5,-125.38 1083.5,-131.38 1083.5,-131.38 1083.5,-180.62 1083.5,-180.62 1083.5,-186.62 1077.5,-192.62 1071.5,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"1025.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"1025.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 14</text>\n",
       "<text text-anchor=\"middle\" x=\"1025.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [14, 0, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"1025.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 23&#45;&gt;25 -->\n",
       "<g id=\"edge25\" class=\"edge\">\n",
       "<title>23&#45;&gt;25</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M983.72,-238.47C989.62,-226.88 995.96,-214.45 1001.86,-202.87\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"1004.81,-204.81 1006.23,-194.31 998.57,-201.63 1004.81,-204.81\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x2879468b0>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dot_data=tree.export_graphviz(clf\n",
    "                               ,feature_names=feature_name\n",
    "                               ,class_names=[\"琴酒\",\"雪莉\",\"贝尔摩德\"]\n",
    "                               ,filled=True\n",
    "                               ,rounded=True\n",
    "                              )\n",
    "\n",
    "graph=graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "b3f3dd2c-a752-40b2-98db-82c4280f4f57",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "score_train=clf.score(Xtrain,Ytrain)\n",
    "score_train"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "b1a6d7e8-b5fb-40d0-aaa1-db769531e3e8",
   "metadata": {},
   "outputs": [
    {
     "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 12.0.0 (0)\n",
       " -->\n",
       "<!-- Title: Tree Pages: 1 -->\n",
       "<svg width=\"808pt\" height=\"470pt\"\n",
       " viewBox=\"0.00 0.00 807.50 469.75\" 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 465.75)\">\n",
       "<title>Tree</title>\n",
       "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-465.75 803.5,-465.75 803.5,4 -4,4\"/>\n",
       "<!-- 0 -->\n",
       "<g id=\"node1\" class=\"node\">\n",
       "<title>0</title>\n",
       "<path fill=\"#fffdfc\" stroke=\"black\" d=\"M459,-461.75C459,-461.75 351.5,-461.75 351.5,-461.75 345.5,-461.75 339.5,-455.75 339.5,-449.75 339.5,-449.75 339.5,-380.25 339.5,-380.25 339.5,-374.25 345.5,-368.25 351.5,-368.25 351.5,-368.25 459,-368.25 459,-368.25 465,-368.25 471,-374.25 471,-380.25 471,-380.25 471,-449.75 471,-449.75 471,-455.75 465,-461.75 459,-461.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"405.25\" y=\"-444.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 1.714</text>\n",
       "<text text-anchor=\"middle\" x=\"405.25\" y=\"-424.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 1.57</text>\n",
       "<text text-anchor=\"middle\" x=\"405.25\" y=\"-409.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 124</text>\n",
       "<text text-anchor=\"middle\" x=\"405.25\" y=\"-394.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 45, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"405.25\" y=\"-379.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 1 -->\n",
       "<g id=\"node2\" class=\"node\">\n",
       "<title>1</title>\n",
       "<path fill=\"#c6a5f3\" stroke=\"black\" d=\"M382.25,-332.25C382.25,-332.25 282.25,-332.25 282.25,-332.25 276.25,-332.25 270.25,-326.25 270.25,-320.25 270.25,-320.25 270.25,-250.75 270.25,-250.75 270.25,-244.75 276.25,-238.75 282.25,-238.75 282.25,-238.75 382.25,-238.75 382.25,-238.75 388.25,-238.75 394.25,-244.75 394.25,-250.75 394.25,-250.75 394.25,-320.25 394.25,-320.25 394.25,-326.25 388.25,-332.25 382.25,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 12.675</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.937</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 51</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 18, 33]</text>\n",
       "<text text-anchor=\"middle\" x=\"332.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</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=\"M378.9,-367.97C374.14,-359.66 369.14,-350.92 364.24,-342.37\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"367.32,-340.72 359.32,-333.78 361.25,-344.19 367.32,-340.72\"/>\n",
       "<text text-anchor=\"middle\" x=\"352.01\" y=\"-350.79\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">True</text>\n",
       "</g>\n",
       "<!-- 8 -->\n",
       "<g id=\"node9\" class=\"node\">\n",
       "<title>8</title>\n",
       "<path fill=\"#f4cbad\" stroke=\"black\" d=\"M532,-332.25C532,-332.25 424.5,-332.25 424.5,-332.25 418.5,-332.25 412.5,-326.25 412.5,-320.25 412.5,-320.25 412.5,-250.75 412.5,-250.75 412.5,-244.75 418.5,-238.75 424.5,-238.75 424.5,-238.75 532,-238.75 532,-238.75 538,-238.75 544,-244.75 544,-250.75 544,-250.75 544,-320.25 544,-320.25 544,-326.25 538,-332.25 532,-332.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"478.25\" y=\"-314.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">脯氨酸 &lt;= 558.218</text>\n",
       "<text text-anchor=\"middle\" x=\"478.25\" y=\"-294.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.951</text>\n",
       "<text text-anchor=\"middle\" x=\"478.25\" y=\"-279.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 73</text>\n",
       "<text text-anchor=\"middle\" x=\"478.25\" y=\"-264.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 27, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"478.25\" y=\"-249.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 0&#45;&gt;8 -->\n",
       "<g id=\"edge8\" class=\"edge\">\n",
       "<title>0&#45;&gt;8</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M431.6,-367.97C436.36,-359.66 441.36,-350.92 446.26,-342.37\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"449.25,-344.19 451.18,-333.78 443.18,-340.72 449.25,-344.19\"/>\n",
       "<text text-anchor=\"middle\" x=\"458.49\" y=\"-350.79\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">False</text>\n",
       "</g>\n",
       "<!-- 2 -->\n",
       "<g id=\"node3\" class=\"node\">\n",
       "<title>2</title>\n",
       "<path fill=\"#63eb9c\" stroke=\"black\" d=\"M245.62,-202.75C245.62,-202.75 138.88,-202.75 138.88,-202.75 132.88,-202.75 126.88,-196.75 126.88,-190.75 126.88,-190.75 126.88,-121.25 126.88,-121.25 126.88,-115.25 132.88,-109.25 138.88,-109.25 138.88,-109.25 245.62,-109.25 245.62,-109.25 251.62,-109.25 257.62,-115.25 257.62,-121.25 257.62,-121.25 257.62,-190.75 257.62,-190.75 257.62,-196.75 251.62,-202.75 245.62,-202.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"192.25\" y=\"-185.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">颜色强度 &lt;= 5.958</text>\n",
       "<text text-anchor=\"middle\" x=\"192.25\" y=\"-165.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.672</text>\n",
       "<text text-anchor=\"middle\" x=\"192.25\" y=\"-150.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 17</text>\n",
       "<text text-anchor=\"middle\" x=\"192.25\" y=\"-135.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 14, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"192.25\" y=\"-120.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;2 -->\n",
       "<g id=\"edge2\" class=\"edge\">\n",
       "<title>1&#45;&gt;2</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M281.71,-238.47C271.79,-229.44 261.32,-219.9 251.16,-210.65\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"253.59,-208.13 243.84,-203.98 248.87,-213.3 253.59,-208.13\"/>\n",
       "</g>\n",
       "<!-- 5 -->\n",
       "<g id=\"node6\" class=\"node\">\n",
       "<title>5</title>\n",
       "<path fill=\"#9253e8\" stroke=\"black\" d=\"M383,-202.75C383,-202.75 287.5,-202.75 287.5,-202.75 281.5,-202.75 275.5,-196.75 275.5,-190.75 275.5,-190.75 275.5,-121.25 275.5,-121.25 275.5,-115.25 281.5,-109.25 287.5,-109.25 287.5,-109.25 383,-109.25 383,-109.25 389,-109.25 395,-115.25 395,-121.25 395,-121.25 395,-190.75 395,-190.75 395,-196.75 389,-202.75 383,-202.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"335.25\" y=\"-185.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">类黄酮 &lt;= 0.761</text>\n",
       "<text text-anchor=\"middle\" x=\"335.25\" y=\"-165.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.523</text>\n",
       "<text text-anchor=\"middle\" x=\"335.25\" y=\"-150.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 34</text>\n",
       "<text text-anchor=\"middle\" x=\"335.25\" y=\"-135.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 30]</text>\n",
       "<text text-anchor=\"middle\" x=\"335.25\" y=\"-120.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 1&#45;&gt;5 -->\n",
       "<g id=\"edge5\" class=\"edge\">\n",
       "<title>1&#45;&gt;5</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M333.33,-238.47C333.52,-230.62 333.71,-222.37 333.9,-214.27\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"337.4,-214.56 334.13,-204.48 330.4,-214.39 337.4,-214.56\"/>\n",
       "</g>\n",
       "<!-- 3 -->\n",
       "<g id=\"node4\" class=\"node\">\n",
       "<title>3</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M104.5,-73.25C104.5,-73.25 12,-73.25 12,-73.25 6,-73.25 0,-67.25 0,-61.25 0,-61.25 0,-12 0,-12 0,-6 6,0 12,0 12,0 104.5,0 104.5,0 110.5,0 116.5,-6 116.5,-12 116.5,-12 116.5,-61.25 116.5,-61.25 116.5,-67.25 110.5,-73.25 104.5,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 14</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 14, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"58.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</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=\"M139.67,-108.95C129.13,-99.71 118.09,-90.04 107.67,-80.91\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"110.04,-78.34 100.21,-74.38 105.43,-83.6 110.04,-78.34\"/>\n",
       "</g>\n",
       "<!-- 4 -->\n",
       "<g id=\"node5\" class=\"node\">\n",
       "<title>4</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M242,-73.25C242,-73.25 146.5,-73.25 146.5,-73.25 140.5,-73.25 134.5,-67.25 134.5,-61.25 134.5,-61.25 134.5,-12 134.5,-12 134.5,-6 140.5,0 146.5,0 146.5,0 242,0 242,0 248,0 254,-6 254,-12 254,-12 254,-61.25 254,-61.25 254,-67.25 248,-73.25 242,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 3</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 3]</text>\n",
       "<text text-anchor=\"middle\" x=\"194.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 2&#45;&gt;4 -->\n",
       "<g id=\"edge4\" class=\"edge\">\n",
       "<title>2&#45;&gt;4</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M193.03,-108.95C193.17,-101.01 193.31,-92.74 193.45,-84.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"196.94,-84.96 193.61,-74.9 189.94,-84.84 196.94,-84.96\"/>\n",
       "</g>\n",
       "<!-- 6 -->\n",
       "<g id=\"node7\" class=\"node\">\n",
       "<title>6</title>\n",
       "<path fill=\"#8139e5\" stroke=\"black\" d=\"M382,-73.25C382,-73.25 286.5,-73.25 286.5,-73.25 280.5,-73.25 274.5,-67.25 274.5,-61.25 274.5,-61.25 274.5,-12 274.5,-12 274.5,-6 280.5,0 286.5,0 286.5,0 382,0 382,0 388,0 394,-6 394,-12 394,-12 394,-61.25 394,-61.25 394,-67.25 388,-73.25 382,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"334.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"334.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 18</text>\n",
       "<text text-anchor=\"middle\" x=\"334.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 0, 18]</text>\n",
       "<text text-anchor=\"middle\" x=\"334.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;6 -->\n",
       "<g id=\"edge6\" class=\"edge\">\n",
       "<title>5&#45;&gt;6</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M334.86,-108.95C334.79,-101.01 334.72,-92.74 334.65,-84.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"338.15,-84.87 334.57,-74.9 331.15,-84.93 338.15,-84.87\"/>\n",
       "</g>\n",
       "<!-- 7 -->\n",
       "<g id=\"node8\" class=\"node\">\n",
       "<title>7</title>\n",
       "<path fill=\"#ab7bee\" stroke=\"black\" d=\"M520,-73.25C520,-73.25 424.5,-73.25 424.5,-73.25 418.5,-73.25 412.5,-67.25 412.5,-61.25 412.5,-61.25 412.5,-12 412.5,-12 412.5,-6 418.5,0 424.5,0 424.5,0 520,0 520,0 526,0 532,-6 532,-12 532,-12 532,-61.25 532,-61.25 532,-67.25 526,-73.25 520,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"472.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.811</text>\n",
       "<text text-anchor=\"middle\" x=\"472.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 16</text>\n",
       "<text text-anchor=\"middle\" x=\"472.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 4, 12]</text>\n",
       "<text text-anchor=\"middle\" x=\"472.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 贝尔摩德</text>\n",
       "</g>\n",
       "<!-- 5&#45;&gt;7 -->\n",
       "<g id=\"edge7\" class=\"edge\">\n",
       "<title>5&#45;&gt;7</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M389,-108.95C399.89,-99.62 411.29,-89.85 422.05,-80.64\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"424.05,-83.53 429.36,-74.37 419.49,-78.22 424.05,-83.53\"/>\n",
       "</g>\n",
       "<!-- 9 -->\n",
       "<g id=\"node10\" class=\"node\">\n",
       "<title>9</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M522.5,-192.62C522.5,-192.62 430,-192.62 430,-192.62 424,-192.62 418,-186.62 418,-180.62 418,-180.62 418,-131.38 418,-131.38 418,-125.38 424,-119.38 430,-119.38 430,-119.38 522.5,-119.38 522.5,-119.38 528.5,-119.38 534.5,-125.38 534.5,-131.38 534.5,-131.38 534.5,-180.62 534.5,-180.62 534.5,-186.62 528.5,-192.62 522.5,-192.62\"/>\n",
       "<text text-anchor=\"middle\" x=\"476.25\" y=\"-175.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"476.25\" y=\"-160.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 17</text>\n",
       "<text text-anchor=\"middle\" x=\"476.25\" y=\"-145.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 17, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"476.25\" y=\"-130.32\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;9 -->\n",
       "<g id=\"edge9\" class=\"edge\">\n",
       "<title>8&#45;&gt;9</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M477.53,-238.47C477.35,-227.35 477.17,-215.45 476.99,-204.28\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"480.49,-204.42 476.84,-194.47 473.5,-204.53 480.49,-204.42\"/>\n",
       "</g>\n",
       "<!-- 10 -->\n",
       "<g id=\"node11\" class=\"node\">\n",
       "<title>10</title>\n",
       "<path fill=\"#eb9c64\" stroke=\"black\" d=\"M664.25,-202.75C664.25,-202.75 564.25,-202.75 564.25,-202.75 558.25,-202.75 552.25,-196.75 552.25,-190.75 552.25,-190.75 552.25,-121.25 552.25,-121.25 552.25,-115.25 558.25,-109.25 564.25,-109.25 564.25,-109.25 664.25,-109.25 664.25,-109.25 670.25,-109.25 676.25,-115.25 676.25,-121.25 676.25,-121.25 676.25,-190.75 676.25,-190.75 676.25,-196.75 670.25,-202.75 664.25,-202.75\"/>\n",
       "<text text-anchor=\"middle\" x=\"614.25\" y=\"-185.45\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">酒精 &lt;= 12.719</text>\n",
       "<text text-anchor=\"middle\" x=\"614.25\" y=\"-165.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.677</text>\n",
       "<text text-anchor=\"middle\" x=\"614.25\" y=\"-150.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 56</text>\n",
       "<text text-anchor=\"middle\" x=\"614.25\" y=\"-135.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 10, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"614.25\" y=\"-120.2\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 8&#45;&gt;10 -->\n",
       "<g id=\"edge10\" class=\"edge\">\n",
       "<title>8&#45;&gt;10</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M527.35,-238.47C536.98,-229.44 547.16,-219.9 557.03,-210.65\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"559.22,-213.39 564.12,-204 554.43,-208.28 559.22,-213.39\"/>\n",
       "</g>\n",
       "<!-- 11 -->\n",
       "<g id=\"node12\" class=\"node\">\n",
       "<title>11</title>\n",
       "<path fill=\"#39e581\" stroke=\"black\" d=\"M652.75,-73.25C652.75,-73.25 567.75,-73.25 567.75,-73.25 561.75,-73.25 555.75,-67.25 555.75,-61.25 555.75,-61.25 555.75,-12 555.75,-12 555.75,-6 561.75,0 567.75,0 567.75,0 652.75,0 652.75,0 658.75,0 664.75,-6 664.75,-12 664.75,-12 664.75,-61.25 664.75,-61.25 664.75,-67.25 658.75,-73.25 652.75,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"610.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.0</text>\n",
       "<text text-anchor=\"middle\" x=\"610.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 7</text>\n",
       "<text text-anchor=\"middle\" x=\"610.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [0, 7, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"610.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 雪莉</text>\n",
       "</g>\n",
       "<!-- 10&#45;&gt;11 -->\n",
       "<g id=\"edge11\" class=\"edge\">\n",
       "<title>10&#45;&gt;11</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M612.68,-108.95C612.41,-101.01 612.13,-92.74 611.86,-84.78\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"615.36,-84.77 611.52,-74.9 608.36,-85.01 615.36,-84.77\"/>\n",
       "</g>\n",
       "<!-- 12 -->\n",
       "<g id=\"node13\" class=\"node\">\n",
       "<title>12</title>\n",
       "<path fill=\"#e78946\" stroke=\"black\" d=\"M787.5,-73.25C787.5,-73.25 695,-73.25 695,-73.25 689,-73.25 683,-67.25 683,-61.25 683,-61.25 683,-12 683,-12 683,-6 689,0 695,0 695,0 787.5,0 787.5,0 793.5,0 799.5,-6 799.5,-12 799.5,-12 799.5,-61.25 799.5,-61.25 799.5,-67.25 793.5,-73.25 787.5,-73.25\"/>\n",
       "<text text-anchor=\"middle\" x=\"741.25\" y=\"-55.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">entropy = 0.332</text>\n",
       "<text text-anchor=\"middle\" x=\"741.25\" y=\"-40.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">samples = 49</text>\n",
       "<text text-anchor=\"middle\" x=\"741.25\" y=\"-25.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">value = [46, 3, 0]</text>\n",
       "<text text-anchor=\"middle\" x=\"741.25\" y=\"-10.95\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">class = 琴酒</text>\n",
       "</g>\n",
       "<!-- 10&#45;&gt;12 -->\n",
       "<g id=\"edge12\" class=\"edge\">\n",
       "<title>10&#45;&gt;12</title>\n",
       "<path fill=\"none\" stroke=\"black\" d=\"M664.08,-108.95C673.97,-99.81 684.32,-90.24 694.12,-81.18\"/>\n",
       "<polygon fill=\"black\" stroke=\"black\" points=\"696.48,-83.77 701.45,-74.41 691.73,-78.63 696.48,-83.77\"/>\n",
       "</g>\n",
       "</g>\n",
       "</svg>\n"
      ],
      "text/plain": [
       "<graphviz.sources.Source at 0x2873f2430>"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf=tree.DecisionTreeClassifier(criterion=\"entropy\"\n",
    "                               ,random_state=30\n",
    "                               ,splitter=\"random\"\n",
    "                               ,max_depth=3\n",
    "                               #,min_samples_leaf=10\n",
    "                               #,min_samples_split=10\n",
    "                               )\n",
    "\n",
    "clf=clf.fit(Xtrain,Ytrain)\n",
    "\n",
    "dot_data=tree.export_graphviz(clf\n",
    "                              ,feature_names=feature_name\n",
    "                              ,class_names=[\"琴酒\",\"雪莉\",\"贝尔摩德\"]\n",
    "                              ,filled=True\n",
    "                              ,rounded=True\n",
    "                             )\n",
    "\n",
    "graph=graphviz.Source(dot_data)\n",
    "graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "f317b93a-22c8-4600-a371-1de1c55bbc7d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9259259259259259"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf.score(Xtrain,Ytrain)\n",
    "clf.score(Xtest,Ytest)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24428ec8-4d6b-46d1-8486-87534eb1a6aa",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.8.19"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}

标签:gt,45,value,源码,entropy,samples,class,决策树
From: https://blog.csdn.net/Darling912/article/details/142288806

相关文章