0
点赞
收藏
分享

微信扫一扫

决策树之scikit-learn

ZGtheGreat 2024-02-14 阅读 10

实例

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()

运行结果

举报

相关推荐

0 条评论