决策树之scikit-learn

实例

python 复制代码
from sklearn.datasets import load_iris
from sklearn import tree
import matplotlib.pyplot as plt

# Load iris dataset
iris = load_iris()
X, y = iris.data, iris.target

# Fit the classifier
clf = tree.DecisionTreeClassifier()
clf = clf.fit(X, y)

# Plot the decision tree
plt.figure(figsize=(15, 10))
tree.plot_tree(clf)
plt.show()
相关推荐
ZhengEnCi9 分钟前
S10-蓝桥杯 17822 乐乐的积木塔
算法
贾斯汀玛尔斯11 分钟前
每天学一个算法--拓扑排序(Topological Sort)
算法·深度优先
大龄程序员狗哥17 分钟前
第25篇:Q-Learning算法解析——强化学习中的经典“价值”学习(原理解析)
人工智能·学习·算法
exp_add320 分钟前
质数相关知识
算法
小辉同志1 小时前
215. 数组中的第K个最大元素
数据结构·算法·leetcode··快速选择
小O的算法实验室2 小时前
2025年IEEE TITS,基于矩阵的进化计算+面向无线传感器网络数据收集无人机路径规划,深度解析+性能实测
算法·论文复现·智能算法·智能算法改进
OidEncoder2 小时前
编码器分辨率与机械精度的关系
人工智能·算法·机器人·自动化
memcpy02 小时前
LeetCode 2615. 等值距离和【相同元素分组+前缀和;考虑距离和的增量】中等
算法·leetcode·职场和发展
炽烈小老头2 小时前
【 每天学习一点算法 2026/04/22】四数相加 II
学习·算法
alphaTao3 小时前
LeetCode 每日一题 2026/4/20-2026/4/26
算法·leetcode·职场和发展