Python K-means聚类算法实采用莺尾花数据花瓣长<=2.45 entropy =1.585 samples =150 value=[50,50,_50] class =山鸢尾 entropy =0.0 花瓣宽<=1.75 samples =50 entropy =1.0 value = [50,0,0] samples =100 class =山鸢尾 value = [0,50,50] class =变色鸢尾 花瓣长<=4.95 花瓣长<=4.95 entropy =0.445 entropy =0.151 samples =54 samples =46 value = [0,49,5] value = [0,1,45] class =变色鸢尾 class =维吉尼亚鸢尾 花萼长<=5.15 entropy =0.918 entropy =0.65 entropy =0.0 entropy =0.146 samples =6 samples =6 samples =48 samples =40 value = [0,47,1] value = [0,2,4] value = [0,1,5] value = [0,0,40] class =变色鸢尾 class =维吉尼亚鸢尾 class =维吉尼亚鸢尾 class =维吉尼亚鸢尾 entropy =0.722 entropy =0.0 samples =5 samples =43 value = [0,4,1] value = [0,43,0] class =变色鸢尾 class =变色鸢尾编程画出决策图
时间: 2023-08-15 16:05:31 浏览: 78
很抱歉,我是一名语言模型AI,无法进行代码绘图操作。但我可以为您提供使用Python和sklearn库绘制莺尾花数据集的决策树的代码示例:
```python
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
from sklearn.tree import export_graphviz
import graphviz
# 加载莺尾花数据集
iris = load_iris()
# 构建决策树模型
dtc = DecisionTreeClassifier()
dtc.fit(iris.data, iris.target)
# 绘制决策树图形
dot_data = export_graphviz(dtc, out_file=None,
feature_names=iris.feature_names,
class_names=iris.target_names,
filled=True, rounded=True,
special_characters=True)
graph = graphviz.Source(dot_data)
graph.render("iris_decision_tree") # 保存决策树图形到文件中
graph.view() # 在窗口中展示决策树图形
```
这段代码可以将训练好的决策树模型绘制为一张图形,并保存到文件中。您可以根据需要修改代码中的参数。
阅读全文