Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visTree: Make .generateYColor robust towards NaN and degenerate trees #443

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vspinu
Copy link

@vspinu vspinu commented Aug 27, 2022

Make color ramp generation robust against two degenerate cases:

  1. Presence of NaN values in object$frame$yval.
  2. Duplicated values of object$frame$yval which might result in yval range in a tree being 0 which results in division by 0 in this line.

Both cases can occur in trees which were refit to new data. That is, yval values and node counts are recomputed on new data but preserving the tree structure. Unfortunately there is no built in functionality for such a "refit" in rpart, so I have my own custom code for that. Thus cannot provide a simple repro. But hopefully the PR is simple enough not to require that.

An example of such a tree:

n= 2944 

node), split, n, deviance, yval
      * denotes terminal node

1) root 2944 1940000000 257  
  2) var< 2.17e+03 2944  278000000 257 *
  3) var>=2.17e+03 0 1640000000 NaN *

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant