Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sklearn.datasets import load_iris
- from sklearn.tree import DecisionTreeClassifier, plot_tree
- import matplotlib.pyplot as plt
- # Load the Iris dataset as an example
- iris = load_iris()
- X, y = iris.data, iris.target
- # Create a decision tree classifier
- clf = DecisionTreeClassifier(random_state=42)
- clf.fit(X, y)
- # Plot the decision tree
- plt.figure(figsize=(12, 8))
- plot_tree(clf, feature_names=iris.feature_names, class_names=iris.target_names, filled=True, rounded=True)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement