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

dbarts: add standard error for interval predictions #978

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Conversation

hfrick
Copy link
Member

@hfrick hfrick commented Jun 5, 2023

closes #976

library(parsnip)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
data(two_class_dat, package = "modeldata")

set.seed(1)
bt_cls_fit <- 
  parsnip::bart() %>% 
  set_mode("classification") %>% 
  set_engine("dbarts") %>% 
  fit(Class ~ ., data = two_class_dat)

set.seed(2)
bind_cols(
  predict(bt_cls_fit, two_class_dat, type = "prob"),
  predict(bt_cls_fit, two_class_dat, type = "pred_int", std_error = TRUE)
) %>%
 select(-contains(c("lower", "upper")))
#> # A tibble: 791 × 3
#>    .pred_Class1 .pred_Class2 .std_error
#>           <dbl>        <dbl>      <dbl>
#>  1       0.351         0.649      0.478
#>  2       0.823         0.177      0.356
#>  3       0.54          0.46       0.498
#>  4       0.552         0.448      0.497
#>  5       0.454         0.546      0.495
#>  6       0.222         0.778      0.420
#>  7       0.6           0.4        0.486
#>  8       0.412         0.588      0.495
#>  9       0.979         0.021      0.133
#> 10       0.0790        0.921      0.276
#> # ℹ 781 more rows

Created on 2023-06-05 with reprex v2.0.2

@hfrick hfrick requested a review from topepo June 5, 2023 12:50
@topepo topepo merged commit 086ad63 into main Jun 8, 2023
@topepo topepo deleted the dbart-std-error branch June 8, 2023 13:11
@github-actions
Copy link

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 23, 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.

bart model predictions do not provide the standard error for the predictions
2 participants