Commit Graph

54 Commits

Author SHA1 Message Date
Thomas J. Fan 3ae7c76153
STY Enables black with experimental_string_processing=true (#20412) 2021-06-29 09:47:04 +02:00
Thomas J. Fan 82df48934e
MNT Applies black formatting to most of the code base (#18948) 2021-06-17 14:21:09 -04:00
Jérémie du Boisberranger 32b60fb976
MNT Clean deprecations for 1.0 | plot_tree (#19324) 2021-05-11 16:40:50 -04:00
Christian Lorentzen b9d6db81ec
[MRG] ENH Consistent loss name for squared error (#19310) 2021-03-19 15:21:34 +01:00
Zero 34de1b9b21
ENH add fontname argument in export_graphviz for non-English characters (#18959) 2021-01-10 19:42:09 +01:00
Guillaume Lemaitre 2218ec4622
MNT change 0.25 to 1.0 and 0.26 to 1.1 in deprecation messages (#19005)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
2020-12-18 16:09:19 +00:00
Thomas J Fan 388999b59d
API Deprecate positional arguments in tree module (#16966) 2020-04-22 09:20:57 -04:00
Rick Mackenbach c6fe262bc6
ENH Improve error message for not fitted trees in plot_tree (#16253) 2020-01-29 10:33:42 +01:00
Chiara Marmo 9c62eee695 MNT Deprecate unused 'rotate' parameter in tree.plot_tree. (#15806)
* Deprecate unused 'rotate' parameter in tree.plot_tree.

* Clarify warning and docstring. Add test.

* Fix lint error and adress comment.

* Fix python lint error.

* Add what's new entry. Conform to skl convention.

* Update sklearn/tree/tests/test_export.py

Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org>
2019-12-07 18:36:40 +01:00
Samesh Lakhotia e74e03294a MAINT: Fix assert raises in `sklearn/tree/tests/` (#14737) 2019-08-28 10:00:58 +03:00
Nicolas Hug f3eb9d2206 [MRG] MNT removing assert_equal, etc -- continued (#14232) 2019-07-02 14:53:51 +10:00
Adrin Jalali 19c068a2ec MNT towards removing assert_equal, etc (#14222) 2019-07-01 09:13:32 -04:00
Thomas J Fan e2b6bff0ac BUG Fixes export_text with single feature (#14053) 2019-06-18 14:51:00 +02:00
Roman Yurchak ccd3331f7e MNT remove unused imports (#14021) 2019-06-04 23:15:19 +10:00
Frank Hoang fa383a4aca FIX plot_tree now displays correct criterion (#13947) 2019-05-27 17:43:11 +10:00
Guillaume Lemaitre b34751b7ed [MRG] MAINT: add fixture for init and clean-up with matplotlib (#13708) 2019-05-06 09:41:46 +02:00
Giuseppe Vettigli a061ada48e FEA Print Decision Trees in ASCII format (#9424) 2019-02-12 10:23:48 +11:00
Andreas Mueller 952ef6637a MRG Drop legacy python / remove six dependencies (#12639) 2019-01-03 15:50:05 +02:00
Andreas Mueller c13ba26c47
[MRG] Matplotlib tree plotting (#9251)
* add reingold tillford tree layout algorithm

* add first silly implementation of matplotlib based plotting for trees

* object oriented design for export_graphviz so it can be extended

* add class for mlp export

* add colors

* separately scale x and y, add arrowheads, fix strings

* implement max_depth

* don't use alpha for coloring because it makes boxes transparent

* remove unused variables

* vertical center of boxes

* fix/simplify newline trimming

* somewhere in the middle of stuff

trying to get rid of scalex, scaley

* remove "find_longest_child" for now, fix tests

* make scalex and scaley internal, and ax local.

render everything once to get the bbox sizes, then again to actually plot it with known extents.

* add some margin to the max bbox width

* add _BaseTreeExporter baseclass

* add docstring to plot_tree

* use data coordinates so we can put the plot in a subplot, remove some hacks.

* remove scalex, scaley, add automatic font size

* use rendered stuff for setting limits (well nearly there)

* import plot_tree into tree module

* set limits before font size adjustment?

* add tree plotting via matplotlib to iris example and to docs

* pep8 fix

* skip doctest on plot_tree because matplotlib is not installed on all CI machines

* redo everything in axis pixel coordinates

re-introduce scalex, scaley
add max_extents to tree to get tree size before plotting

* fix max-depth

parent node positioning and don't consider deep nodes in layouting

* consider height in fontsize computation

in case someone gave us a very flat figure

* fix error when max_depth is None

* add docstring for tree plotting fontsize

* starting on jnothman's review

* renaming fixes

* whatsnew for tree plotting

* clear axes prior to doing anything.

* fix doctests

* skip matplotlib doctest

* trying to debug circle failure

* trying to show full traceback

* more print debugging

* remove debugging crud

* hack around matplotlib <1.5 issues

* copy bbox args because old matplotlib is weird.

* pep8 fixes

* add explicit boxstyle

* more pep8

* even more pep8

* add comment about matplotlib version requirement

* remove redundant file

* add whatsnew entry that the merge lost

* fix merge issue

* more merge issues

* whitespace ...

* remove doctest skip to see what's happening

* added some simple invariance tests buchheim function

* refactor
___init__ into superclass

* added some tests of plot_tree

* put skip back in, fix typo, fix versionadded number

* remove unused parameters special_characters and parallel_leaves from mpl plotting

* rename tests to test_reingold_tilford

* added license header from pymag-trees repo

* remove duplicate test file.
2018-10-11 15:42:02 -04:00
ksemb 77418a0275 MAINT Fix escape sequences that are deprecated in Python 3.6 (#10578)
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
2018-02-07 10:41:21 +11:00
Mabel c62338feb5 FIX export_graphviz should work with a sklearn.tree._tree.Tree (#10234) 2017-12-04 13:28:19 +11:00
Minghui Liu ffe9866e5f Use base.is_classifier instead instead of isinstance (#9482) 2017-08-08 14:36:03 +02:00
Guillaume Lemaitre 00da9cc534 [MRG+1] EHN add decimals parameter for export_graphviz (#8698)
* EHN add decimals parameter for export_graphviz

* FIX address comments

* TST add test for classification

* TST/FIX address comments

* FIX comments raghav
2017-04-29 15:14:57 +02:00
Li Li 2f1c9786cc [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
2017-04-26 21:58:20 +02:00
Hanmin Qin 2beefbc4b3 [MRG] Improve the error message of export_graphviz if a not-fitted decision tree is provided (#8776) 2017-04-23 11:34:08 +10:00
Konstantin Podshumok 9b2aac9e5c [MRG + 1] [TST] (half-cosmetic) use less nose.tools import to simplify future transition to py.test (#7384)
* use less nose.tools import to simplify future transition to activly developing test suites/runners

* assert_equal -> assert_array_equal in test_feature_hasher_pairs_with_string_values

and one missed ImportError that should be replaced with AttributeError

* test for py2.6 compat with except AttributeError

* fix importing of SkipTest

* force using nose in python2.6 for now

* there was no assert_dict_equal in py2.6. but we can use assert_equal

although failed test will look a little bit ugly

* remove nose imports from doc/datasets
2016-10-07 12:46:52 -04:00
themrmax 500b768ea6 add depreciation warning for out_file default 2016-09-15 09:33:43 +10:00
themrmax ba5563f632 retain default behaviour of out_file=tree.dot 2016-09-14 16:10:39 +10:00
themrmax 2a0bd7b653 fix lint error 2016-09-13 13:34:46 +10:00
themrmax 284ae9c58f fix indentation 2016-09-13 10:12:01 +10:00
themrmax 95655ac542 fix lint issues 2016-09-12 14:38:17 +10:00
themrmax 802814ee01 make export_graphviz return string if out_file is None 2016-09-12 13:47:08 +10:00
tracer0tong 53713c95d5 Fix for issue #6352 2016-02-17 02:05:25 +00:00
trevorstephens 9a0c421962 fix rounding, adjust tests for 32 bit export_graphviz 2015-10-30 16:18:22 -07:00
yelite fea218e5cf In tree, min_samples_split and min_samples_leaf now accept float number as percentage. 2015-10-24 23:18:52 +02:00
Frank Zalkow a8976e710a fixes 2015-08-14 20:31:57 +02:00
Frank Zalkow d0ce6322b7 added newline (for pep8) and reverted to regex solution due to 0.0/-0.0 problem on windows 2015-08-14 20:27:01 +02:00
Frank Zalkow 6d78d3d678 implemented improvement suggestions 2015-08-14 14:58:43 +02:00
Andreas Mueller a8626b36a6 TST/COSMIT remove nose call boilerplate 2015-05-28 14:54:01 -04:00
trevorstephens 271849953f Pretty decision trees 2015-05-09 17:06:07 -07:00
Raghav R V cd2ee7e454 MAINT docstring --> comments to prevent nose from using doc in verbose mode 2015-03-21 11:16:49 +05:30
Gilles Louppe 2d16aee90e FIX: use XorShift random number generator 2013-09-22 19:36:09 +02:00
Gilles Louppe 9c07ca32b9 FIX: module RAND_R_MAX 2013-09-22 19:35:39 +02:00
Noel Dawe b62b0d3dc5 tree export_graphviz: remove unused close parameter and close the file if out_file is a string 2013-08-26 00:43:09 -07:00
Gilles Louppe a3985775b1 FIX: broken tests based on rng 2013-07-22 12:20:01 +02:00
Lars Buitinck c7266ec712 ENH back-port rand_r from 4.4BSD
This function is not available on Windows and is deprecated by POSIX.
Fetched from OpenBSD:
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/stdlib/rand.c

This reverts commit 6f737ad8d5b29a098df6b2ad0fdd1db38e801db8.
2013-07-22 12:20:01 +02:00
Gilles Louppe 0c795872c8 WIP: revert use of rand_r 2013-07-22 12:20:01 +02:00
Gilles Louppe 4c032ac02f WIP: use re-entrant rand_r 2013-07-22 12:20:01 +02:00
Gilles Louppe 167bbec3e1 FIX: export_graphviz test 2013-07-22 12:19:58 +02:00
Gilles Louppe 3200735d1c WIP: fix export functions 2013-07-22 12:19:56 +02:00