-
Notifications
You must be signed in to change notification settings - Fork 105
Description
Could you consider having an engine = argument to each model_spec function, rather than requiring set_engine() afterward? For instance:
# Instead of requiring:
logistic_reg() %>%
set_engine("glm")
# Allow
logistic_reg(engine = "glm")
This is more compact, particularly since it becomes more straightforward to pass a model spec as an argument (e.g. to set_model()) without giving it its own two lines of code for assignment. (Besides being shorter, not having to create an object means not having to give it a name like lin_mod that might need to change in two places if you change the model spec).
I'd also find it a more natural workflow if these engines had defaults, like "lm" for linear_reg(). parsnip is already opinionated about the model if set_engine() is not called, like choosing "ranger" for rand_forest(), though it gives a warning about that. (Some like nearest_neighbor() or prophet() have only one engine implemented, but still give the warning, which seems especially harsh).
None of this precludes set_engine() still keeping its current functionality for the sake of reverse compatibility, ability to modify an existing recipe. and setting extra arguments (Similarly, in ggplot2 you can do either ggplot(data, aes(...)) or ggplot(data) + aes(...)).