Skip to content

apply postprocessor in augment.workflow() - #276

Merged
simonpcouch merged 3 commits into
mainfrom
augment-275
Jan 13, 2025
Merged

apply postprocessor in augment.workflow()#276
simonpcouch merged 3 commits into
mainfrom
augment-275

Conversation

@simonpcouch

Copy link
Copy Markdown
Contributor

Closes #275.

With this PR:

library(tidymodels)
library(tailor)
library(probably)
#> 
#> Attaching package: 'probably'
#> The following objects are masked from 'package:base':
#> 
#>     as.factor, as.ordered

tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)

set.seed(900)
reg_train <- sim_regression(5000)
reg_cal <- sim_regression(500)
reg_test <- sim_regression(500)


rf_spec <- rand_forest(trees = 5, min_n = 200) %>%
  set_mode("regression")

cal_post <- tailor() %>%
  adjust_numeric_calibration(method = "isotonic_boot")

rf_wflow <- workflow(outcome ~ ., rf_spec)
rf_cal_wflow <- workflow(outcome ~ ., rf_spec, cal_post)


set.seed(1)
rf_fit <- fit(rf_wflow, reg_train)
rf_pred <- rf_fit %>% augment(reg_test) 

set.seed(1)
rf_cal_fit <- fit(rf_cal_wflow, data = reg_train, calibration = reg_cal)
rf_cal_pred <- rf_cal_fit %>% augment(reg_test) 

all.equal(rf_pred, rf_cal_pred)
#> [1] "Component \".pred\": Mean relative difference: 0.2442093"

Created on 2025-01-10 with reprex v2.1.1

@simonpcouch
simonpcouch requested a review from topepo January 10, 2025 18:12

@topepo topepo 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.

Perfect! Thanks!

@simonpcouch
simonpcouch merged commit 2b31e8f into main Jan 13, 2025
@simonpcouch
simonpcouch deleted the augment-275 branch January 13, 2025 14:44
@github-actions

Copy link
Copy Markdown

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 28, 2025
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.

augment() does not include postprocessors

2 participants