Reputation: 81
I am using decision tree classifier and want to plot the tree using matplotlib
I am using this but nodes are small and not clear:
from sklearn import tree
import matplotlib.pyplot as plt
plt.figure(figsize=(15,15))
tree.plot_tree(model_dt_smote,filled=True)
Upvotes: 2
Views: 2635
Reputation: 24049
You can pass axe
to tree.plot_tree
with large figsize
and set larger fontsize
like below:
(I can't run your code then I send an example)
from sklearn.datasets import load_iris
import matplotlib.pyplot as plt
from sklearn import tree
clf = tree.DecisionTreeClassifier(random_state=0)
iris = load_iris()
clf = clf.fit(iris.data, iris.target)
fig, axe = plt.subplots(figsize=(20,10))
tree.plot_tree(clf, ax = axe, fontsize=15)
Output:
Upvotes: 2