Skip to content

Commit e24c13c

Browse files
rprkhjeremiedbb
andauthored
FIX accept array-like in feature_names for plot_tree (scikit-learn#27292)
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
1 parent 52b6925 commit e24c13c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

doc/whats_new/v1.3.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ Changelog
7070
- |Fix| :func:`tree.plot_tree` now accepts `class_names=True` as documented.
7171
:pr:`26903` by :user:`Thomas Roehr <2maz>`
7272

73+
- |Fix| The `feature_names` parameter of :func:`tree.plot_tree` now accepts any kind of
74+
array-like instead of just a list. :pr:`27292` by :user:`Rahil Parikh <rprkh>`.
75+
7376
.. _changes_1_3:
7477

7578
Version 1.3.0

sklearn/tree/_export.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __repr__(self):
7878
{
7979
"decision_tree": [DecisionTreeClassifier, DecisionTreeRegressor],
8080
"max_depth": [Interval(Integral, 0, None, closed="left"), None],
81-
"feature_names": [list, None],
81+
"feature_names": ["array-like", None],
8282
"class_names": ["array-like", "boolean", None],
8383
"label": [StrOptions({"all", "root", "none"})],
8484
"filled": ["boolean"],
@@ -130,7 +130,7 @@ def plot_tree(
130130
The maximum depth of the representation. If None, the tree is fully
131131
generated.
132132
133-
feature_names : list of str, default=None
133+
feature_names : array-like of str, default=None
134134
Names of each of the features.
135135
If None, generic names will be used ("x[0]", "x[1]", ...).
136136

0 commit comments

Comments
 (0)