Skip to content

Commit 62e6ef0

Browse files
author
ArturoAmorQ
committed
Iter
1 parent 734b4b8 commit 62e6ef0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

python_scripts/trees_sol_01.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,12 @@
152152
import numpy as np
153153
from matplotlib import cm
154154

155+
classes = np.unique(tree.classes_)
155156
_, axs = plt.subplots(ncols=3, nrows=1, sharey=True, figsize=(12, 5))
156157
plt.suptitle("Predicted probabilities for decision tree model", y=1.05)
157158
plt.subplots_adjust(bottom=0.45)
158159

159-
for idx, class_of_interest in enumerate(np.unique(tree.classes_)):
160+
for idx, class_of_interest in enumerate(classes):
160161
axs[idx].set_title(f"Class {class_of_interest}")
161162
disp = DecisionBoundaryDisplay.from_estimator(
162163
tree,
@@ -179,9 +180,7 @@
179180

180181
ax = plt.axes([0.15, 0.14, 0.7, 0.05])
181182
plt.colorbar(
182-
cm.ScalarMappable(norm=None, cmap="viridis"),
183-
cax=ax,
184-
orientation="horizontal",
183+
cm.ScalarMappable(cmap="viridis"), cax=ax, orientation="horizontal"
185184
)
186185
_ = plt.title("Probability")
187186

0 commit comments

Comments
 (0)