决策树之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()
相关推荐
民乐团扒谱机40 分钟前
【微实验】谐波乘积谱(HPS)算法深度解析:原理、数学与代码实现
开发语言·人工智能·python·算法·语音识别·音乐
Nil20844 分钟前
leetcode 73矩阵置0
算法·leetcode·矩阵
忍冬k2 小时前
DeepSeek harness安装指南
java·开发语言·数据结构·c++·算法
何以解忧,唯有..2 小时前
预订酒店问题
算法
No8g攻城狮3 小时前
【算法】什么是 DFS 与 BFS 及他们的区别
算法·深度优先·宽度优先
旖旎夜光3 小时前
LeetCode 1658:将 x 减到 0 的最小操作数(滑动窗口) —— 题解
数据结构·c++·算法·leetcode·滑动窗口
zww89491113 小时前
家政派单系统实战指南:从需求分析到智能调度算法落地
算法·需求分析
手写码匠3 小时前
华为云Flexus+DeepSeek征文|Dify 多 Agent 评测实战:用 DeepSeek-R1 当裁判,打造多智能体系统的自动化质量保障体系
人工智能·深度学习·算法·aigc
ZC跨境爬虫3 小时前
LeetCode 88. 合并两个有序数组(双指针详解 + Java Python 实现)
java·python·算法·leetcode
Nil2083 小时前
leetcode 238除了自身以外数组的乘积
数据结构·算法·leetcode