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

Add plot.model_profile for two or more models #12

Closed
hbaniecki opened this issue Oct 21, 2022 · 2 comments · Fixed by #56
Closed

Add plot.model_profile for two or more models #12

hbaniecki opened this issue Oct 21, 2022 · 2 comments · Fixed by #56
Assignees
Labels
feature 💡 New feature or request

Comments

@hbaniecki
Copy link
Member

hbaniecki commented Oct 21, 2022

plot.model_profile in DALEX/ingredients uses the color parameter to choose a dimension for plot splitting, e.g. by the model (label). This allows for comparing two models in one plot.

library(DALEX)

titanic_glm_model <- glm(survived~., data = titanic_imputed, family = "binomial")
explainer_glm <- explain(titanic_glm_model, data = titanic_imputed, verbose = FALSE)
expl_glm <- model_profile(explainer_glm)

library("ranger")
titanic_ranger_model <- ranger(survived~., data = titanic_imputed, num.trees = 50,
                               probability = TRUE)
explainer_ranger  <- explain(titanic_ranger_model, data = titanic_imputed, verbose = FALSE)
expl_ranger <- model_profile(explainer_ranger)

plot(expl_ranger$agr_profiles, expl_glm$agr_profiles, color = "_label_") 
plot(expl_ranger$agr_profiles, expl_glm$agr_profiles)

It would be nice to have similar functionality in survex

ve_rf <- model_profile(explainer_rf, variables = "age")
plot(ve_rf)
ve_cox <- model_profile(explainer_cox, variables = "age")
plot(ve_cox, ve_rf) # won't work

Firstly, at this moment the above code should return an error

The idea is to add some facet parameter, which by default is set to variables but can be changed to _label_ etc.

plot(ve_cox, ve_rf, facet="_label_")

Mockup:

image

Using:

(plot(ve_rf) + ggtitle("rsf")) +
  (plot(ve_cox) + ggtitle("cph")) + 
  plot_annotation(subtitle="")
@hbaniecki hbaniecki added the feature 💡 New feature or request label Oct 21, 2022
@mikolajsp
Copy link
Collaborator

I agree this is useful functionality. I'm just wondering how to show this information in one plot.

Do you think one column per model would be a good way to show it? and then different variables in rows?

@hbaniecki
Copy link
Member Author

Perhaps, the most popular use cases consider 1-2-4 variables and 1-2-3 models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 💡 New feature or request
Projects
None yet
2 participants