Update file to allow plotting of 'id's other than 1#27
Merged
Conversation
Here is a reproducible example of the error that this proposed fix solves:
Y_train <- HR$status
x_train <- HR[ , -6]
set.seed(123)
model_rf <- randomForest(x = x_train, y = Y_train, ntree = 50)
p_function <- function(model, data) predict(model, newdata = data, type = "prob")
ive_rf <- individual_variable_effect(model_rf, data = x_train, predict_function = p_function,
new_observation = x_train[1:2,], nsamples = 50)
plot.individual_variable_effect(ive_rf, id = 1)
plot.individual_variable_effect(ive_rf, id = 2) # error, this is solved with the propsed fix
Contributor
Author
|
This fix still wont work when submitting multiple id's though. Also, maybe consider setting the default id not to 1 but rather to NULL and then set it to the first element in the individual_effect data frame i.e.: id == NULL
if(is.null(id)){
id = x$`_id_`[1]
}
|
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is a reproducible example of the error that this proposed fix solves: