Python 编写创建决策树程序的步骤是什么?

Python 编写创建决策树程序的步骤是什么?,python,machine-learning,cart-analysis,Python,Machine Learning,Cart Analysis,我想知道在Python中创建决策树(ID3)的步骤是什么?看起来像下面这样的东西?(是一吨的if-then-else还是比那更好呢?)对于创建一个ID3树,我应该计算熵吗?怎么做 thal = fixed_defect [4 6] | ca <= 0.500000 [4 0]: negative | ca > 0.500000 [0 6]: positive thal = normal [84 19] | thalach <= 111.500000 [0 4]: p

我想知道在Python中创建决策树(ID3)的步骤是什么?看起来像下面这样的东西?(是一吨的if-then-else还是比那更好呢?)对于创建一个ID3树,我应该计算熵吗?怎么做

thal = fixed_defect [4 6]
|   ca <= 0.500000 [4 0]: negative
|   ca > 0.500000 [0 6]: positive
thal = normal [84 19]
|   thalach <= 111.500000 [0 4]: positive
|   thalach > 111.500000 [84 15]
|   |   age <= 55.500000 [56 4]
|   |   |   trestbps <= 113.500000 [9 3]
|   |   |   |   oldpeak <= 0.300000 [3 3]
|   |   |   |   |   cp = typ_angina [0 0]: negative
|   |   |   |   |   cp = asympt [0 2]: positive
|   |   |   |   |   cp = non_anginal [1 1]
|   |   |   |   |   |   age <= 44.000000 [1 0]: negative
|   |   |   |   |   |   age > 44.000000 [0 1]: positive
|   |   |   |   |   cp = atyp_angina [2 0]: negative
|   |   |   |   oldpeak > 0.300000 [6 0]: negative
|   |   |   trestbps > 113.500000 [47 1]
|   |   |   |   oldpeak <= 3.550000 [47 0]: negative
|   |   |   |   oldpeak > 3.550000 [0 1]: positive
|   |   age > 55.500000 [28 11]
|   |   |   chol <= 248.500000 [14 1]
|   |   |   |   oldpeak <= 2.800000 [14 0]: negative
|   |   |   |   oldpeak > 2.800000 [0 1]: positive
|   |   |   chol > 248.500000 [14 10]
|   |   |   |   sex = female [13 3]
|   |   |   |   |   cp = typ_angina [1 0]: negative
|   |   |   |   |   cp = asympt [3 3]
|   |   |   |   |   |   age <= 58.000000 [2 0]: negative
|   |   |   |   |   |   age > 58.000000 [1 3]
|   |   |   |   |   |   |   chol <= 362.000000 [0 3]: positive
|   |   |   |   |   |   |   chol > 362.000000 [1 0]: negative
|   |   |   |   |   cp = non_anginal [7 0]: negative
|   |   |   |   |   cp = atyp_angina [2 0]: negative
|   |   |   |   sex = male [1 7]
|   |   |   |   |   age <= 65.500000 [0 5]: positive
|   |   |   |   |   age > 65.500000 [1 2]
|   |   |   |   |   |   age <= 66.500000 [1 0]: negative
|   |   |   |   |   |   age > 66.500000 [0 2]: positive
thal = reversable_defect [20 67]
|   cp = typ_angina [3 1]
|   |   oldpeak <= 0.700000 [0 1]: positive
|   |   oldpeak > 0.700000 [3 0]: negative
|   cp = asympt [5 53]
|   |   oldpeak <= 0.650000 [5 10]
|   |   |   chol <= 240.500000 [5 2]
|   |   |   |   chol <= 192.000000 [1 2]
|   |   |   |   |   age <= 62.000000 [0 2]: positive
|   |   |   |   |   age > 62.000000 [1 0]: negative
|   |   |   |   chol > 192.000000 [4 0]: negative
|   |   |   chol > 240.500000 [0 8]: positive
|   |   oldpeak > 0.650000 [0 43]: positive
|   cp = non_anginal [9 10]
|   |   oldpeak <= 1.900000 [9 5]
|   |   |   trestbps <= 122.500000 [6 0]: negative
|   |   |   trestbps > 122.500000 [3 5]
|   |   |   |   chol <= 232.500000 [3 1]
|   |   |   |   |   trestbps <= 129.000000 [0 1]: positive
|   |   |   |   |   trestbps > 129.000000 [3 0]: negative
|   |   |   |   chol > 232.500000 [0 4]: positive
|   |   oldpeak > 1.900000 [0 5]: positive
|   cp = atyp_angina [3 3]
|   |   age <= 47.000000 [2 0]: negative
|   |   age > 47.000000 [1 3]
|   |   |   trestbps <= 109.000000 [1 0]: negative
|   |   |   trestbps > 109.000000 [0 3]: positive
thal=已修复缺陷[4 6]
|ca 0.500000[0.6]:阳性
塔尔=正常[84 19]
|塔拉赫111.500000[84 15]
||年龄55.500000[28 11]
|| | chol 248.500000[14 10]
|| | |性别=女性[13 3]
|| | | | | | cp=典型的心绞痛[10]:阴性
|| | | | cp=asympt[3]
|| | | | |年龄58.000000[13]
|| | | | | | chol 362.000000[10]:负
|| | | | | cp=非心绞痛[7 0]:阴性
|| | | | cp=atyp|U心绞痛[20]:阴性
|| | |性别=男性[17]
|| | | |年龄65.500000[1 2]
|年龄66.500000[02]:阳性
thal=可逆缺陷[20 67]
|cp=典型的心绞痛[3 1]
|| oldpeak 0.700000[30]:负
|cp=asympt[5 53]
|| oldpeak 0.650000[0 43]:正值
|cp=非心绞痛[9 10]
|| oldpeak 1.900000[0 5]:正
|cp=atyp_心绞痛[3]
||年龄47.000000[13]
|| | trestbps 109.000000[0 3]:正

ID3不处理连续变量我不知道。这是给我们的一个输出。我不知道。我一直在阅读有关ID3的文献,但在实现方面我一无所知。你能给我链接一些ID3的实施指南吗?如果我想使用Python本身,我不想使用任何外部库。