question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add threshold comparison above arrow in plot_tree

See original GitHub issue

I realised after #13971 and also a lecture that I gave that we don’t add “True/False”, “Yes/No” above the arrow in plot_tree. Therefore, we know the criterion for the decision and the further splits but we don’t have any idea what path a sample will take (or at least it makes it more difficult to infer it).

I think that we should annotate the arrow depending if the comparison in the node is True/False.

@amueller @NicolasHug @thomasjpfan WDYT?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
d-kleinecommented, Sep 2, 2022

I found an interesting insight to above issue:

import numpy as np
from matplotlib import pyplot as plt

from sklearn.model_selection import train_test_split
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier

iris = load_iris()
X = iris.data
y = iris.target
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)

clf = DecisionTreeClassifier(max_leaf_nodes=3, random_state=0)
clf.fit(X_train, y_train)

When using plot_tree(), it does not show the “True”/“False” labels for the threshold:

from sklearn import tree

tree.plot_tree(clf, feature_names=iris.feature_names, class_names=iris.target_names, filled=True)
plt.show()

But the “True”/“False” labels will be printed when using export_graphviz():

import graphviz

dot_data = tree.export_graphviz(clf, 
                                out_file=None, 
                                feature_names=iris.feature_names,  
                                class_names=iris.target_names,
                                filled=True)

graphviz.Source(dot_data, format="png") 

Seems like export_graphviz() is creating “True”/“False” labels for the first condition, but plot_tree() does not.

1reaction
glemaitrecommented, Feb 12, 2020

Go for it

On Mon, 27 Jan 2020 at 14:32, Rick Mackenbach notifications@github.com wrote:

I could work on this

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/scikit-learn/scikit-learn/issues/16153?email_source=notifications&email_token=ABY32P37FBSRJTLKBPA25CTQ73O6HA5CNFSM4KISEEJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ7P2HY#issuecomment-578747679, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABY32P3DH65VKOQPXE6CCELQ73O6HANCNFSM4KISEEJA .

– Guillaume Lemaitre Scikit-learn @ Inria Foundation https://glemaitre.github.io/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Phylogenetic Tools for Comparative Biology (and Other Things)
add.arrow, Add an arrow pointing to a tip or node on the tree ... ancThresh, Ancestral character estimation under the threshold model using...
Read more >
phytools.pdf
A broad range of plotting methods for phylogenies and comparative data in- clude, but are not restricted to, methods for mapping trait evolution ......
Read more >
Visualizing and Annotating Phylogenetic Trees with R+ggtree
The horizontal dimension in this plot shows the amount of genetic change, and the branches and represent evolutionary lineages changing over time.
Read more >
Chapter 5 Phylogenetic Tree Annotation | Data Integration ...
geom_inset, Adds insets (subplots) to tree nodes ... Some evolutionary events (e.g., reassortment, horizontal gene transfer) cannot be modeled by a simple ...
Read more >
Add an arrow pointing to a tip or node on the tree in phytools
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. See Also.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found