决策树之scikit-learn

实例

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

决策树之scikit-learn_第1张图片

你可能感兴趣的:(决策树,scikit-learn,算法)