Skip to content
Snippets Groups Projects
Commit 2f1c9786 authored by Li Li's avatar Li Li Committed by (Venkat) Raghav (Rajagopalan)
Browse files

[MRG+1] check length of feature_names in export_graphviz (#8477) (#8512)

* #8477

check length of feature_names in export_graphviz

- raise ValueError if len(feature_names) > tree.n_features
- add unit test for len(feature_names) > tree.n_features
- change the comment of existing unit test for len(feature_names) <
tree.n_features

* fix error and warning

- include length of feature_names and number of features in tree in the
error and warning message.
- raise error for too few feature_names
- for too much feature_names, will use the first n_features. raise an
warning for users
- use assert_raise_message and assert_warns_message in test to check
message.

* move the error and warning from node_to_str to export_graphviz so it will fail early for wrong length of feature_names

* raise error if length of feature_names does not match number of features in the decision tree

* fix pep8

* remove unused assert_warns_message import in test_export.py

* add bug fix in doc/whats_new.rst

* fix the english in doc/whats_new.rst

* fix the format and english in sklearn/tree/export.py

* fix contributor format in doc/whats_new.rst

* fix english, use bracket and avoid \ in error message

* fix pep8

* fix pep8
parent 28a0d560
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment