【发布时间】:2019-12-26 08:35:10
【问题描述】:
我有这个简单的 python scikit-learn 脚本来演示使用决策树算法进行性别分类。
https://github.com/Sarbjyotsingh/Gender-Classification-with-Python
from sklearn import tree
clf = tree.DecisionTreeClassifier()
# [height, weight, shoe_size]
X = [[181, 80, 44], [177, 70, 43], [160, 60, 38], [154, 54, 37], [166, 65, 40],
[190, 90, 47], [175, 64, 39],
[177, 70, 40], [159, 55, 37], [171, 75, 42], [181, 85, 43]]
Y = ['male', 'male', 'female', 'female', 'male', 'male', 'female', 'female',
'female', 'male', 'male']
clf = clf.fit(X, Y)
prediction = clf.predict([[160, 60, 22]])
print(prediction)
脚本运行良好。如何修改它以显示图形树,显示决策树如何解释输入数据以预测输出?
我使用的是 python 3.7,scikit-learn 0.21.3
【问题讨论】:
-
为什么2票反对?那些投反对票的人可以解释一下,以便我知道出了什么问题吗?
标签: python machine-learning scikit-learn decision-tree