Skip to content

Conversation

@EmilHvitfeldt
Copy link
Member

@EmilHvitfeldt EmilHvitfeldt commented May 31, 2022

This PR aims to close #713.

The changes are minimal and very invasive. Mainly involving from enquo() -> enexpr() and enquos() -> enexprs() everywhere, updating tests and making sure that the helper functions don't use quo_get_expr() as it is no longer needed.

TODO:

  • finish work related to requires_descrs()
  • Remove convert_args() and convert_arg()
  • Figure out ranger conf_int bug
  • Run all the tests
    • extratests
    • revdepcheck


.x_expr <- rlang::get_expr(x)
.x_env <- rlang::get_env(x, parent.frame())
.x_env <- rlang::get_env(x, parent.frame(n = 3))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since x is no longer a quosure, we have to find the environment differently sometimes. parent.frame(n = 3) get us to the right one

@EmilHvitfeldt
Copy link
Member Author

I am closing this PR since the implementation isn't good enough. In particular the following can't be done which is a dealbreaker

library(parsnip)

boost_tree(mode = "regression") %>%
  fit(mpg ~ ., data = mtcars)
#> parsnip model object
#> 
#> ##### xgb.Booster
#> raw: 21.5 Kb 
#> call:
#>   xgboost::xgb.train(params = list(eta = 0.3, max_depth = 6, gamma = 0, 
#>     colsample_bytree = 1, colsample_bynode = 1, min_child_weight = 1, 
#>     subsample = 1, objective = "reg:squarederror"), data = x$data, 
#>     nrounds = 15, watchlist = x$watchlist, verbose = 0, nthread = 1)
#> params (as set within xgb.train):
#>   eta = "0.3", max_depth = "6", gamma = "0", colsample_bytree = "1", colsample_bynode = "1", min_child_weight = "1", subsample = "1", objective = "reg:squarederror", nthread = "1", validate_parameters = "TRUE"
#> xgb.attributes:
#>   niter
#> callbacks:
#>   cb.evaluation.log()
#> # of features: 10 
#> niter: 15
#> nfeatures : 10 
#> evaluation_log:
#>     iter training_rmse
#>        1    14.9313149
#>        2    10.9568064
#> ---                   
#>       14     0.5628964
#>       15     0.4603055


f <- function(mtry = 2) {
  boost_tree(mode = "regression", mtry = mtry) %>%
    fit(mpg ~ ., data = mtcars)
}

f()
#> Error in FUN(X[[i]], ...): object 'mtry' not found

Created on 2022-06-03 by the reprex package (v2.0.1)

@github-actions
Copy link
Contributor

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parsnip should capture args/engine_args as expressions rather than quosures

2 participants