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 butcher methods for xrf::xrf() #242

Merged
merged 4 commits into from
Jan 17, 2023
Merged

add butcher methods for xrf::xrf() #242

merged 4 commits into from
Jan 17, 2023

Conversation

simonpcouch
Copy link
Contributor

@simonpcouch simonpcouch commented Dec 22, 2022

Related to #234. Same story as #240 with NEWS entries.🐣

xrf just wraps glmnet and xgboost, but the glmnet object it carries around in the $glm slot is a bit modified (and given class glmnot) so we still need to do some subsetting in there beyond dispatching those packages' methods.

library(butcher)
library(xrf)

fit_xrf <- function() {
  boop <- runif(1e6)
  xrf(y ~ x, data.frame(y = rnorm(1e4), x = rnorm(1e4)), family = "gaussian")
}

xrf_fit <- fit_xrf()
xrf_res <- butcher(xrf_fit)

weigh(xrf_fit)
#> # A tibble: 43 × 2
#>    object                             size
#>    <chr>                             <dbl>
#>  1 glm.model.glmnet.fit.call       11.1   
#>  2 glm.formula                     10.1   
#>  3 rule_augmented_formula           8.36  
#>  4 base_formula                     8.17  
#>  5 glm.model.glmnet.fit.beta        0.490 
#>  6 xgb.raw                          0.117 
#>  7 rules.rule_id                    0.0518
#>  8 rules.split_id                   0.0494
#>  9 xgb.callbacks.cb.evaluation.log  0.0354
#> 10 rules.feature                    0.0155
#> # … with 33 more rows
weigh(xrf_res)
#> # A tibble: 43 × 2
#>    object                       size
#>    <chr>                       <dbl>
#>  1 glm.formula               1.93   
#>  2 glm.model.glmnet.fit.beta 0.490  
#>  3 rule_augmented_formula    0.146  
#>  4 xgb.raw                   0.117  
#>  5 rules.rule_id             0.0518 
#>  6 rules.split_id            0.0494 
#>  7 rules.feature             0.0155 
#>  8 rules.split               0.0155 
#>  9 rules.less_than           0.00775
#> 10 glm.model.glmnet.fit.a0   0.00669
#> # … with 33 more rows

Created on 2022-12-22 with reprex v2.0.2

Copy link
Member

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

That is a pretty complicated structure inside! Thank you 🙏

@juliasilge juliasilge merged commit 312c621 into main Jan 17, 2023
@juliasilge juliasilge deleted the xrf-234 branch January 17, 2023 22:16
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

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 Feb 1, 2023
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.

2 participants