决策树之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()
相关推荐
寂静山林1 天前
UVa 10228 A Star not a Tree?
算法
Neverfadeaway1 天前
【C语言】深入理解函数指针数组应用(4)
c语言·开发语言·算法·回调函数·转移表·c语言实现计算器
Madison-No71 天前
【C++】探秘vector的底层实现
java·c++·算法
Swift社区1 天前
LeetCode 401 - 二进制手表
算法·leetcode·ssh
派大星爱吃猫1 天前
顺序表算法题(LeetCode)
算法·leetcode·职场和发展
liu****1 天前
8.list的模拟实现
linux·数据结构·c++·算法·list
地平线开发者1 天前
征程 6 | 征程 6 工具链如何支持 Matmul/Conv 双 int16 输入量化?
算法·自动驾驶
程序员大雄学编程1 天前
「深度学习笔记4」深度学习优化算法完全指南:从梯度下降到Adam的实战详解
笔记·深度学习·算法·机器学习
小O的算法实验室1 天前
2022年ASOC SCI2区TOP,基于竞争与合作策略的金字塔粒子群算法PPSO,深度解析+性能实测,深度解析+性能实测
算法·论文复现·智能算法·智能算法改进
南莺莺1 天前
邻接矩阵的基本操作
数据结构·算法··邻接矩阵