Skip to content

add butcher methods for dbarts::bart() - #240

Merged
juliasilge merged 3 commits into
mainfrom
bart-234
Jan 11, 2023
Merged

juliasilge merged 3 commits into
mainfrom
bart-234

Conversation

@simonpcouch

@simonpcouch simonpcouch commented Dec 22, 2022 •

Copy link
Copy Markdown
Contributor

Related to #234. I haven't added a NEWS entry, as I anticipate putting in a few of these PRs today, and don't want to introduce merge conflicts for you!

Unfortunately, the "heaviest" entry by far, $fit, is required for prediction.😫 That slot is only occupied when keeptrees = TRUE, which is not a default.

library(butcher)
library(dbarts)

fit_bart <- function() {
  boop <- runif(1e6)
  dbarts::bart(mtcars[,2:5], mtcars[,1], verbose = FALSE, keeptrees = TRUE)
}

res <- fit_bart()
res_b <- butcher(res)

weigh(res)
#> # A tibble: 9 × 2
#>   object              size
#>   <chr>              <dbl>
#> 1 fit             1.85    
#> 2 yhat.train      0.256   
#> 3 varcount        0.0167  
#> 4 sigma           0.00805 
#> 5 call            0.00196 
#> 6 first.sigma     0.000848
#> 7 yhat.train.mean 0.000304
#> 8 y               0.000304
#> 9 sigest          0.000056
weigh(res_b)
#> # A tibble: 9 × 2
#>   object              size
#>   <chr>              <dbl>
#> 1 fit             1.85    
#> 2 first.sigma     0.000848
#> 3 y               0.000304
#> 4 call            0.000112
#> 5 sigest          0.000056
#> 6 sigma           0.000048
#> 7 yhat.train      0.000048
#> 8 yhat.train.mean 0.000048
#> 9 varcount        0.000048

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

@juliasilge juliasilge left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great! Thank you so much 🙌

@juliasilge
juliasilge merged commit e7da4fa into main Jan 11, 2023
@juliasilge
juliasilge deleted the bart-234 branch January 11, 2023 23:45
@github-actions

Copy link
Copy Markdown
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 Jan 26, 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