Commit Graph

47 Commits

Author SHA1 Message Date
Rüdiger Busche d300f406ae MAINT Simplify super() calls (#12812) 2019-01-10 22:27:06 +01: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
Andreas Mueller eec7649236 MAINT Complete 0.20 deprecations (#9570) 2018-06-24 23:06:26 +10:00
Mabel c62338feb5 FIX export_graphviz should work with a sklearn.tree._tree.Tree (#10234) 2017-12-04 13:28:19 +11:00
Luciano Viola 964a7f78b4 added tree of type "regressor" to the docstring of exportviz (#9530) 2017-08-11 16:06:30 -04:00
Jean Helie ac41281451 [MRG+1] Fix alerts found with lgtm (#9278)
* compare values rather than references

* add __ne__ to class

* add missing self parameter

* properly initialise child class using super()

* remove useless loop variables and assigments

* remove useless return statements

* respect PEP8 style

* fix another flake8 check
2017-07-05 17:22:21 +10: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
themrmax 14666a81ae add object inheritence to class definition 2016-09-21 09:34:10 +10:00
themrmax b69d5fa818 remove lambda for flake8 linting 2016-09-19 09:04:09 +10:00
themrmax f92123169b only show DepreciationWarning if out_file paramater is actually missing 2016-09-15 15:31:41 +10:00
themrmax 205b3a1938 edit depreciation warning and add versionadded to docstring 2016-09-15 12:07:44 +10:00
themrmax 7dfed858da use double quotes 2016-09-15 09:36:21 +10: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 b4b23a3404 only return string if out_file is None 2016-09-13 10:11:34 +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
Nelson Liu d2aaf0f4bb doc: fix spellings of 'license' 2016-03-31 17:25:31 -07:00
tracer0tong 65a2b8fe8e Fixed codestyle 2016-02-18 23:02:10 +09: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
Jacob Schreiber 5978c0bbdf ENH split _tree.pyx into several files 2015-09-09 11:28:24 +02:00
Frank Zalkow 03e95efb1f added a test and reverted string to friedman_mse 2015-08-14 11:31:42 +02:00
Frank Zalkow 108404767e now uses isinstance and keeps original name (FriedmanMSE) 2015-08-14 10:21:24 +02:00
Frank Zalkow a08482aaaf missed elif 2015-08-13 10:01:01 +02:00
Frank Zalkow 5aab0afe60 added a string for FriedmanMSE (instead impurity) when exporting a dot file 2015-08-12 13:08:14 +02:00
Andreas Mueller 0650d5502e DOC adding backlinks to docstrings 2015-06-03 00:24:04 -04:00
trevorstephens 271849953f Pretty decision trees 2015-05-09 17:06:07 -07:00
Andreas Mueller 2fe9da701d DOC Add note about sample weights in export_graphviz. 2014-11-06 10:23:45 -05:00
Lars Buitinck 56057c9630 MAINT remove deprecated code 2014-07-23 16:19:40 +02:00
Lars Buitinck ac9bfdb3ba MAINT make export_graphviz more exception-safe 2014-05-09 14:18:02 +02:00
Gilles Louppe 1a887dda68 COSMIT: Various PEP8 2014-01-16 14:34:10 +01:00
Arnaud Joly 7551a82e89 ENH reduce memory overhead of storing tree ensemble 2013-09-12 14:25:49 +02:00
Mathieu Blondel b6f439370e Merge pull request #2411 from Balu-Varanasi/remove_unused_import
removed unused import from example
2013-08-31 02:34:19 -07:00
balu b38366e33a removed unused import from example 2013-08-31 12:44:58 +05:30
balu 616dda35d7 add expected blank line 2013-08-31 12:23:23 +05:30
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
Lars Buitinck 613d025d66 TST skip Graphviz export docstring in trees
Leaves temp files lying around on Python 3.x.
2013-07-22 15:18:18 +02:00
Gilles Louppe 52b193a239 WIP: PEP8 a few things 2013-07-22 12:20:00 +02:00
Gilles Louppe 3200735d1c WIP: fix export functions 2013-07-22 12:19:56 +02:00
Robert Layton dacfd8bd5d DOC: Replaced all BSD style licenses with "BSD 3 clause"
Replaced all BSD style licenses with "BSD 3 clause"
Not checked yet!

Removed duplicate "3 clause, 3 clause"

Removed trailing period if exists

Fixed some missed licences, still about 50 to do, but those can be automated

Think I got the last of them.

Apparently me and sed have different ideas of regex.

Found a few more
2013-04-30 08:34:46 +02:00
Gilles Louppe 2b01f3aada ENH: output criterion name instead of "error" in export_graphviz 2013-04-16 12:29:58 +02:00
Gilles Louppe 813d1a4049 ENH: add max_depth to export_graphviz 2013-04-16 12:29:58 +02:00
Gilles Louppe e084727613 ENH: moved export_graphviz to sklearn/tree/export.py 2013-04-16 12:29:58 +02:00