Skip to content

Update file to allow plotting of 'id's other than 1#27

Merged
maksymiuks merged 1 commit into
ModelOriented:masterfrom
Beirnaert:patch-1
Apr 15, 2020
Merged

Update file to allow plotting of 'id's other than 1#27
maksymiuks merged 1 commit into
ModelOriented:masterfrom
Beirnaert:patch-1

Conversation

@Beirnaert
Copy link
Copy Markdown
Contributor

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(ive_rf, id = 1)
plot(ive_rf, id = 2) # error, this is solved with the propsed fix

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
@Beirnaert
Copy link
Copy Markdown
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]
    }

@maksymiuks maksymiuks merged commit 8ce4c38 into ModelOriented:master Apr 15, 2020
@maksymiuks
Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants