决策树之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()
相关推荐
巧克力味的桃子15 小时前
学习笔记:查找数组第K小的数(去重排名)
笔记·学习·算法
星云POLOAPI15 小时前
大模型API调用延迟过高?深度解析影响首Token时间的五大因素及优化方案
人工智能·python·算法·ai
88号技师15 小时前
2026年1月一区SCI-波动光学优化算法Wave Optics Optimizer-附Matlab免费代码
开发语言·算法·数学建模·matlab·优化算法
Nobuggggg15 小时前
LabelImg使用时报错:TypeError: setValue(self, val: int)
python·scikit-learn
明朝百晓生15 小时前
强化学习[chapter8] [page17] Value Function Methods
人工智能·算法
POLITE315 小时前
Leetcode 56.合并区间 JavaScript (Day 6)
算法·leetcode·职场和发展
历程里程碑16 小时前
滑动窗口秒解LeetCode字母异位词
java·c语言·开发语言·数据结构·c++·算法·leetcode
ghie909016 小时前
使用直接节点积分法进行无网格法2D悬臂梁计算
算法
Helibo4416 小时前
2025年12月gesp3级题解
数据结构·c++·算法
p&f°16 小时前
垃圾回收两种算法
java·jvm·算法