From 7ac87cf3d96a2a6cf0ef95bea96d66821c51ce6e Mon Sep 17 00:00:00 2001 From: Thomas Roehr Date: Wed, 26 Jul 2023 12:05:59 +0200 Subject: [PATCH 1/4] sklearn.tree: Fix validation of class_names argument for plot_tree --- sklearn/tree/_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_export.py b/sklearn/tree/_export.py index 02f8ea81404c7..e84d806621991 100644 --- a/sklearn/tree/_export.py +++ b/sklearn/tree/_export.py @@ -79,7 +79,7 @@ def __repr__(self): "decision_tree": [DecisionTreeClassifier, DecisionTreeRegressor], "max_depth": [Interval(Integral, 0, None, closed="left"), None], "feature_names": [list, None], - "class_names": [list, None], + "class_names": ["array-like", "boolean", None], "label": [StrOptions({"all", "root", "none"})], "filled": ["boolean"], "impurity": ["boolean"], From 4e284bac4a0f67e1b4e6e7d8f857b59c84878c60 Mon Sep 17 00:00:00 2001 From: Thomas Roehr Date: Thu, 27 Jul 2023 08:55:44 +0200 Subject: [PATCH 2/4] sklearn.tree: update documentation of class_names for plot_tree True is the only available boolean option --- sklearn/tree/_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/tree/_export.py b/sklearn/tree/_export.py index e84d806621991..c89333aa49831 100644 --- a/sklearn/tree/_export.py +++ b/sklearn/tree/_export.py @@ -134,7 +134,7 @@ def plot_tree( Names of each of the features. If None, generic names will be used ("x[0]", "x[1]", ...). - class_names : list of str or bool, default=None + class_names : array-like of str or True, default=None Names of each of the target classes in ascending numerical order. Only relevant for classification and not supported for multi-output. If ``True``, shows a symbolic representation of the class name. From a5a8afdbafeef361de22d7e247841f2ce3d29ff2 Mon Sep 17 00:00:00 2001 From: Thomas Roehr Date: Thu, 27 Jul 2023 09:01:47 +0200 Subject: [PATCH 3/4] Add doc entry for fix --- doc/whats_new/v1.3.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/whats_new/v1.3.rst b/doc/whats_new/v1.3.rst index 8d39ca2fed143..716d4c05241ac 100644 --- a/doc/whats_new/v1.3.rst +++ b/doc/whats_new/v1.3.rst @@ -758,6 +758,9 @@ Changelog `feature_names` and `class_names` as array-like rather than lists. :pr:`26289` by :user:`Yao Xiao ` +- |Fix| :func:`tree.plot_tree` now accepts `class_names=True` as documented. + :pr:`26903` by :user:`Thomas Roehr <2maz>` + :mod:`sklearn.utils` .................... From ab3583c3cc7322cd8015813d8dbcf79248ac1518 Mon Sep 17 00:00:00 2001 From: "Thomas J. Fan" Date: Thu, 27 Jul 2023 09:41:30 -0400 Subject: [PATCH 4/4] DOC Move to 1.3.1 --- doc/whats_new/v1.3.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/whats_new/v1.3.rst b/doc/whats_new/v1.3.rst index 716d4c05241ac..e0df3c1beba4b 100644 --- a/doc/whats_new/v1.3.rst +++ b/doc/whats_new/v1.3.rst @@ -23,6 +23,12 @@ Changelog :attr:`sklearn.neighbors.KDTree.valid_metrics` as public class attributes. :pr:`26754` by :user:`Julien Jerphanion `. +:mod:`sklearn.tree` +................... + +- |Fix| :func:`tree.plot_tree` now accepts `class_names=True` as documented. + :pr:`26903` by :user:`Thomas Roehr <2maz>` + .. _changes_1_3: Version 1.3.0 @@ -758,9 +764,6 @@ Changelog `feature_names` and `class_names` as array-like rather than lists. :pr:`26289` by :user:`Yao Xiao ` -- |Fix| :func:`tree.plot_tree` now accepts `class_names=True` as documented. - :pr:`26903` by :user:`Thomas Roehr <2maz>` - :mod:`sklearn.utils` ....................