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

Simplify specification of aesthetics in vip() #80

Closed
bgreenwell opened this issue Dec 14, 2019 · 6 comments
Closed

Simplify specification of aesthetics in vip() #80

bgreenwell opened this issue Dec 14, 2019 · 6 comments

Comments

@bgreenwell
Copy link
Member

For example,

vip(fit, type = "dotplot", aesthetics = list(size = 3))

instead of

vip(fit, type = "dotplot", size = 3)
@bradleyboehmke
Copy link
Member

What if - rather than do a hard backward compatibility break with branch issue-79-80 we do deprecation warning? This would require us to retain more code since we'd have to still allow aesthetics as they were stated in current versions plus allow the new aesthetics option but it wouldn't force a hard version break.

Just an option if we're worried about ticking off early adopters of the package with a hard version break.

@bgreenwell
Copy link
Member Author

Seems reasonable. It’ll take a bit of code but I’ll work on it!

@bgreenwell
Copy link
Member Author

bgreenwell commented Dec 15, 2019

@bradleyboehmke got it. The old approach should still work, but with a warning that these features will be removed in the next planned version.

Example:

# Load required packages
library(ggplot2)  # for `aes_string()` function

# Load the sample data
data(mtcars)

# Fit a linear regression model
model <- lm(mpg ~ ., data = mtcars)

# Construct variable importance plots
p1 <- vip(model)
p2 <- vip(model, mapping = aes_string(color = "Sign"))
p3 <- vip(model, geom = "point")
p4 <- vip(model, geom = "point", mapping = aes_string(color = "Variable"),
          aesthetics = list(size = 3))
grid.arrange(p1, p2, p3, p4, nrow = 2)

# Make sure old approach still works, albeit with a warning
vip(model, bar = FALSE)
vip(model, bar = FALSE, color = "red")
vip(model, bar = TRUE, color = "red", fill = "green")
vip(model, bar = TRUE, color = "red", fill = "green", width = 1/3)

@bgreenwell
Copy link
Member Author

Try to break it if you can and I'll merge when we're happy with it.

@bradleyboehmke
Copy link
Member

bradleyboehmke commented Dec 16, 2019

The updates look good. Not sure if you realize or not but the type arguments you provided don't do anything (older version??).

i.e.:

vip(model, type = "dotplot")  # old
vip(rf_model, type = "impurity", geom = "point")  # new

@bgreenwell
Copy link
Member Author

Oops, forgot to mention. I renamed the new type argument to geom so that it doesn't conflict with the type argument to vi_model() which can be passed via ... in vi() and vip(). I updated the docs in ?vip::vip quite a bit make it clear.

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

No branches or pull requests

2 participants