diff --git a/pkgdown.yml b/pkgdown.yml
index 1a11cb3..0dc617b 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -2,7 +2,7 @@ pandoc: 3.1.11
pkgdown: 2.1.1
pkgdown_sha: ~
articles: {}
-last_built: 2024-12-11T15:36Z
+last_built: 2024-12-11T15:57Z
urls:
reference: https://tailor.tidymodels.org/reference
article: https://tailor.tidymodels.org/articles
diff --git a/reference/adjust_equivocal_zone.html b/reference/adjust_equivocal_zone.html
index 7a662d6..6076fbb 100644
--- a/reference/adjust_equivocal_zone.html
+++ b/reference/adjust_equivocal_zone.html
@@ -47,7 +47,7 @@
Apply an equivocal zone to a binary classification model.
Usage
-
adjust_equivocal_zone(x, value = 0.1, threshold = 1/2)
+
adjust_equivocal_zone(x, value = 0.1, threshold = NULL)
@@ -64,7 +64,9 @@
Argumentsthreshold
-A numeric value (between zero and one) or hardhat::tune()
.
+A numeric value (between zero and one) or hardhat::tune()
.
+Defaults to adjust_probability_threshold(threshold)
if previously set
+in x
, or 1 / 2
if not.
diff --git a/search.json b/search.json
index fe83001..a4f7d7b 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":[]},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tailor","title":"Contributing to tailor","text":"outlines propose change tailor. detailed discussion contributing tidyverse packages, please see development contributing guide code review principles.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to tailor","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to tailor","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See guide create great issue advice.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to tailor","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"tidymodels/tailor\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to tailor","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to tailor","text":"Please note tailor project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://tailor.tidymodels.org/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 tailor authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with tailor","title":"Getting help with tailor","text":"Thanks using tailor! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with tailor","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty incredible ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with tailor","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with tailor","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://tailor.tidymodels.org/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Simon Couch. Author. Hannah Frick. Author. Emil HvitFeldt. Author. Max Kuhn. Author, maintainer. Posit Software, PBC. Copyright holder, funder.","code":""},{"path":"https://tailor.tidymodels.org/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Couch S, Frick H, HvitFeldt E, Kuhn M (2024). tailor: Iterative Steps Postprocessing Model Predictions. R package version 0.0.0.9001, https://tailor.tidymodels.org, https://github.com/tidymodels/tailor.","code":"@Manual{, title = {tailor: Iterative Steps for Postprocessing Model Predictions}, author = {Simon Couch and Hannah Frick and Emil HvitFeldt and Max Kuhn}, year = {2024}, note = {R package version 0.0.0.9001, https://tailor.tidymodels.org}, url = {https://github.com/tidymodels/tailor}, }"},{"path":"https://tailor.tidymodels.org/index.html","id":"tailor","dir":"","previous_headings":"","what":"Iterative Steps for Postprocessing Model Predictions","title":"Iterative Steps for Postprocessing Model Predictions","text":"Postprocessors refine predictions outputted machine learning models improve predictive performance better satisfy distributional limitations. package introduces ‘tailor’ objects, compose iterative adjustments model predictions. addition utilities create new adjustments, package provides number pre-written ones: probability distributions: calibration transformation probabilities hard class predictions: thresholds, equivocal zones numeric distributions: calibration, range Tailors tightly integrated tidymodels framework. greatest ease use, situate tailors model workflows add_tailor(). package active development; please treat experimental don’t depend syntax staying .","code":""},{"path":"https://tailor.tidymodels.org/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Iterative Steps for Postprocessing Model Predictions","text":"can install development version tailor like :","code":"pak::pak(\"tidymodels/tailor\")"},{"path":"https://tailor.tidymodels.org/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Iterative Steps for Postprocessing Model Predictions","text":"two_class_example dataset modeldata gives true value outcome variable truth well predicted probabilities (Class1 Class2). hard class predictions, predicted, \"Class1\" probability assigned \"Class1\" .5, \"Class2\" otherwise. model predicts \"Class1\" often \"Class2\". wanted model predict \"Class2\" often, increase probability threshold assigned \"Class1\" hard class prediction \"Class1\". tailor package, adjustment implemented adjust_probability_threshold(), can situated tailor object. tailors must fitted can predict new data. adjustments like adjust_probability_threshold(), ’s training actually happens fit() step besides recording name type relevant variables. adjustments, like probability calibration adjust_probability_calibration(), parameters actually estimated fit() step separate data used train postprocessor evaluate performance. case, though, can fit() whole dataset. resulting object still tailor, now flagged trained. used model workflow via add_tailor(), arguments fit() tailor set automatically (addition data splitting needed postprocessors require training). Now, passed new data, trained tailor determine outputted class based whether probability assigned level \"Class1\" .9, resulting predictions \"Class2\" . Tailors compose adjustments; several adjust_*() functions called iteratively, tailors apply order fit() predict() time.","code":"library(tailor) library(modeldata) 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 head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 post_obj <- tailor() %>% adjust_probability_threshold(threshold = .9) post_obj #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.9. post_res <- fit( post_obj, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) post_res #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.9. [trained] predict(post_res, two_class_example) %>% count(predicted) #> # A tibble: 2 × 2 #> predicted n #> #> 1 Class1 180 #> 2 Class2 320"},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"Equivocal zones describe intervals predicted probabilities deemed uncertain ambiguous assigned hard class. Rather predicting hard class probability close threshold, tailors using adjustment predict \"[EQ]\".","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"","code":"adjust_equivocal_zone(x, value = 0.1, threshold = 1/2)"},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"x tailor(). value numeric value (zero 1/2) hardhat::tune(). value size buffer around threshold. threshold numeric value (zero one) hardhat::tune().","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"function transforms class prediction column estimate type class_pred probably::class_pred(). can loosely think column type factor, except possible entry [EQ] level excluded performance metric calculations. result, output column number levels input, except now possible entry [EQ] tidymodels funcitons know exclude analyses.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"","code":"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 library(modeldata) head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 # `predicted` gives hard class predictions based on probabilities two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 # when probabilities are within (.25, .75), consider them equivocal tlr <- tailor() %>% adjust_equivocal_zone(value = 1 / 4) tlr #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Add equivocal zone of size 0.25. # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) tlr_fit #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Add equivocal zone of size 0.25. [trained] # adjust hard class predictions predict(tlr_fit, two_class_example) %>% count(predicted) #> # A tibble: 3 × 2 #> predicted n #> #> 1 [EQ] 86 #> 2 Class1 229 #> 3 Class2 185"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-calibrate numeric predictions — adjust_numeric_calibration","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"Calibration regression models involves adjusting model's predictions adjust correlated errors, ensuring predicted values align closely actual observed values across entire range outputs.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"","code":"adjust_numeric_calibration(x, method = NULL)"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"x tailor(). method Character. One \"linear\", \"isotonic\", \"isotonic_boot\", corresponding function probably package probably::cal_estimate_linear(), probably::cal_estimate_isotonic(), probably::cal_estimate_isotonic_boot(), respectively.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"adjustment requires estimation , , different subsets data used train evaluate predictions. See section name ?workflows::add_tailor() information preventing data leakage postprocessors require estimation. situated workflow, tailors automatically estimated appropriate subsets data.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"","code":"library(tibble) # create example data set.seed(1) d_calibration <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d_test <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d_calibration #> # A tibble: 100 × 2 #> y y_pred #> #> 1 -0.626 -0.934 #> 2 0.184 0.134 #> 3 -0.836 -1.33 #> 4 1.60 0.956 #> 5 0.330 -0.490 #> 6 -0.820 1.36 #> 7 0.487 0.960 #> 8 0.738 1.28 #> 9 0.576 0.672 #> 10 -0.305 1.53 #> # ℹ 90 more rows # specify calibration tlr <- tailor() %>% adjust_numeric_calibration(method = \"linear\") # train tailor on a subset of data. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit(tlr, d_calibration, outcome = y, estimate = y_pred) # apply to predictions on another subset of data d_test #> # A tibble: 100 × 2 #> y y_pred #> #> 1 0.409 1.10 #> 2 1.69 -0.203 #> 3 1.59 2.76 #> 4 -0.331 -0.549 #> 5 -2.29 0.512 #> 6 2.50 2.76 #> 7 0.667 0.416 #> 8 0.541 0.838 #> 9 -0.0134 -1.03 #> 10 0.510 0.578 #> # ℹ 90 more rows predict(tlr_fit, d_test) #> # A tibble: 100 × 2 #> y y_pred #> #> 1 0.409 0.497 #> 2 1.69 0.162 #> 3 1.59 0.580 #> 4 -0.331 -0.0230 #> 5 -2.29 0.408 #> 6 2.50 0.580 #> 7 0.667 0.386 #> 8 0.541 0.463 #> 9 -0.0134 -0.319 #> 10 0.510 0.421 #> # ℹ 90 more rows"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":null,"dir":"Reference","previous_headings":"","what":"Truncate the range of numeric predictions — adjust_numeric_range","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"Truncating ranges involves limiting output model specific range values, typically avoid extreme unrealistic predictions. technique can help improve practical applicability model's outputs constraining within reasonable bounds based domain knowledge physical limitations.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"","code":"adjust_numeric_range(x, lower_limit = -Inf, upper_limit = Inf)"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"x tailor(). upper_limit, lower_limit numeric value, NA (truncation) hardhat::tune().","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"","code":"if (FALSE) { library(tibble) # create example data set.seed(1) d <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d # specify calibration tlr <- tailor() %>% adjust_numeric_range(lower_limit = 1) # train tailor by passing column names. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit(tlr, d, outcome = y, estimate = y_pred) predict(tlr_fit, d) }"},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":null,"dir":"Reference","previous_headings":"","what":"Change or add variables — adjust_predictions_custom","title":"Change or add variables — adjust_predictions_custom","text":"adjustment functions allows arbitrary transformations model predictions using dplyr::mutate() statements.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change or add variables — adjust_predictions_custom","text":"","code":"adjust_predictions_custom(x, ..., .pkgs = character(0))"},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change or add variables — adjust_predictions_custom","text":"x tailor(). ... Name-value pairs expressions. See dplyr::mutate(). .pkgs character string extra packages needed execute commands.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Change or add variables — adjust_predictions_custom","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change or add variables — adjust_predictions_custom","text":"","code":"library(modeldata) head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 tlr <- tailor() %>% adjust_equivocal_zone() %>% adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2)) tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) predict(tlr_fit, two_class_example) %>% head() #> # A tibble: 6 × 5 #> truth Class1 Class2 predicted linear_predictor #> #> 1 Class2 0.00359 0.996 Class2 5.63 #> 2 Class1 0.679 0.321 Class1 -0.747 #> 3 Class2 0.111 0.889 Class2 2.08 #> 4 Class1 0.735 0.265 Class1 -1.02 #> 5 Class2 0.0162 0.984 Class2 4.10 #> 6 Class1 0.999 0.000725 Class1 -7.23"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-calibrate classification probability predictions — adjust_probability_calibration","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"Calibration process adjusting model's outputted probabilities match observed frequencies events. technique aims ensure model predicts certain probability outcome, probability accurately reflects true likelihood outcome occurring.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"","code":"adjust_probability_calibration(x, method = NULL)"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"x tailor(). method Character. One \"logistic\", \"multinomial\", \"beta\", \"isotonic\", \"isotonic_boot\", corresponding function probably package probably::cal_estimate_logistic(), probably::cal_estimate_multinomial(), etc., respectively.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"adjustment requires estimation , , different subsets data used train evaluate predictions. See section name ?workflows::add_tailor() information preventing data leakage postprocessors require estimation. situated workflow, tailors automatically estimated appropriate subsets data.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"","code":"if (FALSE) { library(modeldata) # split example data set.seed(1) in_rows <- sample(c(TRUE, FALSE), nrow(two_class_example), replace = TRUE) d_calibration <- two_class_example[in_rows, ] d_test <- two_class_example[!in_rows, ] head(d_calibration) # specify calibration tlr <- tailor() %>% adjust_probability_calibration(method = \"logistic\") # train tailor on a subset of data. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit( tlr, d_calibration, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) # apply to predictions on another subset of data head(d_test) predict(tlr_fit, d_test) }"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Change the event threshold — adjust_probability_threshold","title":"Change the event threshold — adjust_probability_threshold","text":"Many machine learning systems determine hard class predictions first predicting probability event predicting event occur respective probability 0.5. adjustment allows practitioners determine hard class predictions using threshold 0.5. setting appropriate thresholds, one can balance trade-different types errors (false positives false negatives) optimize model's performance specific use cases.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change the event threshold — adjust_probability_threshold","text":"","code":"adjust_probability_threshold(x, threshold = 0.5)"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change the event threshold — adjust_probability_threshold","text":"x tailor(). threshold numeric value (zero one) hardhat::tune().","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Change the event threshold — adjust_probability_threshold","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change the event threshold — adjust_probability_threshold","text":"","code":"library(modeldata) # `predicted` gives hard class predictions based on probability threshold .5 head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 # use a threshold of .1 instead: tlr <- tailor() %>% adjust_probability_threshold(.1) # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) # adjust hard class predictions predict(tlr_fit, two_class_example) %>% head() #> # A tibble: 6 × 4 #> truth Class1 Class2 predicted #> #> 1 Class2 0.00359 0.996 Class2 #> 2 Class1 0.679 0.321 Class1 #> 3 Class2 0.111 0.889 Class1 #> 4 Class1 0.735 0.265 Class1 #> 5 Class2 0.0162 0.984 Class2 #> 6 Class1 0.999 0.000725 Class1"},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit and predict from tailors — fit.tailor","title":"Fit and predict from tailors — fit.tailor","text":"functions apply fit() predict() methods adjustment added tailor, order applied. Users need interface methods directly tailors situated inside model workflows ?workflows::add_tailor().","code":""},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit and predict from tailors — fit.tailor","text":"","code":"# S3 method for class 'tailor' fit(object, .data, outcome, estimate, probabilities = c(), ...) # S3 method for class 'tailor' predict(object, new_data, ...)"},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit and predict from tailors — fit.tailor","text":"object tailor(). .data, new_data data frame containing predictions model. outcome required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name outcome variable. estimate required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name point estimate (e.g. predicted class), tidymodels, corresponds column names .pred, .pred_class, .pred_time. probabilities required used independently ?workflows::add_tailor() \"binary\" \"multiclass\" types, can also passed fit() time instead. column names class probability estimates. given order factor levels estimate. ... Currently ignored.","code":""},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Fit and predict from tailors — fit.tailor","text":"adjustments require estimating parameters, training fit() simply evaluates tidyselect expressions logs column names. others, adjust_numeric_calibration(), adjustments actually learn data; case, separate subsets data used training tailor evaluating performance predictions. See Data Usage section ?workflows::add_tailor() information tidymodels makes split; situated model workflow, tailors automatically trained appropriate subset data.","code":""},{"path":"https://tailor.tidymodels.org/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. dplyr %>% generics fit, required_pkgs, tidy, tunable, tune_args hardhat extract_parameter_dials, extract_parameter_set_dials","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor-internals.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal tailor functions — tailor-internals","title":"Internal tailor functions — tailor-internals","text":"Utilities use downstream packages.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor-internals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal tailor functions — tailor-internals","text":"","code":"tailor_fully_trained(x) tailor_requires_fit(x)"},{"path":"https://tailor.tidymodels.org/reference/tailor-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","title":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","text":"Postprocessors refine predictions outputted machine learning models improve predictive performance better satisfy distributional limitations. package introduces 'tailor' objects, compose iterative adjustments model predictions. number pre-written adjustments provided package, like calibration equivocal zones, well utilities compose new ones. Tailors tightly integrated 'tidymodels' framework.","code":""},{"path":[]},{"path":"https://tailor.tidymodels.org/reference/tailor-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","text":"Maintainer: Max Kuhn max@posit.co Authors: Simon Couch simon.couch@posit.co Hannah Frick hannah@posit.co Emil HvitFeldt emil.hvitfeldt@posit.co contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Declare post-processing for model predictions — tailor","title":"Declare post-processing for model predictions — tailor","text":"Tailors compose iterative adjustments model predictions. initializing tailor function, add adjustment specifications adjust_*() functions: probability distributions: adjust_probability_calibration() transformation probabilities hard class predictions: adjust_probability_threshold(), adjust_equivocal_zone() numeric distributions: adjust_numeric_calibration(), adjust_numeric_range() ad-hoc adjustments, see adjust_predictions_custom(). Tailors must trained fit() applied new data predict(). Tailors tightly integrated tidymodels framework; greatest ease use, situate tailors model workflows ?workflows::add_tailor().","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Declare post-processing for model predictions — tailor","text":"","code":"tailor(outcome = NULL, estimate = NULL, probabilities = NULL)"},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Declare post-processing for model predictions — tailor","text":"outcome required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name outcome variable. estimate required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name point estimate (e.g. predicted class), tidymodels, corresponds column names .pred, .pred_class, .pred_time. probabilities required used independently ?workflows::add_tailor() \"binary\" \"multiclass\" types, can also passed fit() time instead. column names class probability estimates. given order factor levels estimate.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ordering-of-adjustments","dir":"Reference","previous_headings":"","what":"Ordering of adjustments","title":"Declare post-processing for model predictions — tailor","text":"composing multiple adjustments tailor object, order matters must follow specific rules depending type predictions adjusted (classification regression). classification problems (binary multiclass), adjustments modify probability estimates (e.g., adjust_probability_calibration()) must applied adjustments change hard class predictions (including adjust_equivocal_zone()). ensures class predictions based final calibrated probabilities. regression problems, adjust_numeric_calibration() must applied numeric adjustments. ensures subsequent adjustments work calibrated predictions. Generally, adjustments duplicated (.e. adjustment type used multiple times tailor object), though adjust_predictions_custom() can used multiple times. Adjustments different prediction types mixed—numeric adjustments (regression) probability adjustments (classification) used tailor object. ordering rules violated, tailor() raise error describing issue.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Declare post-processing for model predictions — tailor","text":"","code":"library(dplyr) library(modeldata) # `predicted` gives hard class predictions based on probabilities two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 # change the probability threshold to allot one class vs the other tlr <- tailor() %>% adjust_probability_threshold(threshold = .1) tlr #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) tlr_fit #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. [trained] # adjust hard class predictions predict(tlr_fit, two_class_example) %>% count(predicted) #> # A tibble: 2 × 2 #> predicted n #> #> 1 Class1 362 #> 2 Class2 138"},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy a tailor object — tidy.tailor","title":"Tidy a tailor object — tidy.tailor","text":"Describe tailor's adjustments tibble one row per adjustment.","code":""},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy a tailor object — tidy.tailor","text":"","code":"# S3 method for class 'tailor' tidy(x, number = NA, ...)"},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy a tailor object — tidy.tailor","text":"x tailor() object. number Optional. single integer 1 number adjustments. ... Currently unused; must empty.","code":""},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tidy a tailor object — tidy.tailor","text":"tibble containing information tailor's adjustments including ordering, whether trained, whether require training separate calibration set.","code":""}]
+[{"path":[]},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"our-pledge","dir":"","previous_headings":"","what":"Our Pledge","title":"Contributor Covenant Code of Conduct","text":"members, contributors, leaders pledge make participation community harassment-free experience everyone, regardless age, body size, visible invisible disability, ethnicity, sex characteristics, gender identity expression, level experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, sexual identity orientation. pledge act interact ways contribute open, welcoming, diverse, inclusive, healthy community.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"our-standards","dir":"","previous_headings":"","what":"Our Standards","title":"Contributor Covenant Code of Conduct","text":"Examples behavior contributes positive environment community include: Demonstrating empathy kindness toward people respectful differing opinions, viewpoints, experiences Giving gracefully accepting constructive feedback Accepting responsibility apologizing affected mistakes, learning experience Focusing best just us individuals, overall community Examples unacceptable behavior include: use sexualized language imagery, sexual attention advances kind Trolling, insulting derogatory comments, personal political attacks Public private harassment Publishing others’ private information, physical email address, without explicit permission conduct reasonably considered inappropriate professional setting","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement-responsibilities","dir":"","previous_headings":"","what":"Enforcement Responsibilities","title":"Contributor Covenant Code of Conduct","text":"Community leaders responsible clarifying enforcing standards acceptable behavior take appropriate fair corrective action response behavior deem inappropriate, threatening, offensive, harmful. Community leaders right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct, communicate reasons moderation decisions appropriate.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"scope","dir":"","previous_headings":"","what":"Scope","title":"Contributor Covenant Code of Conduct","text":"Code Conduct applies within community spaces, also applies individual officially representing community public spaces. Examples representing community include using official e-mail address, posting via official social media account, acting appointed representative online offline event.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement","dir":"","previous_headings":"","what":"Enforcement","title":"Contributor Covenant Code of Conduct","text":"Instances abusive, harassing, otherwise unacceptable behavior may reported community leaders responsible enforcement codeofconduct@posit.co. complaints reviewed investigated promptly fairly. community leaders obligated respect privacy security reporter incident.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"enforcement-guidelines","dir":"","previous_headings":"","what":"Enforcement Guidelines","title":"Contributor Covenant Code of Conduct","text":"Community leaders follow Community Impact Guidelines determining consequences action deem violation Code Conduct:","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_1-correction","dir":"","previous_headings":"Enforcement Guidelines","what":"1. Correction","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Use inappropriate language behavior deemed unprofessional unwelcome community. Consequence: private, written warning community leaders, providing clarity around nature violation explanation behavior inappropriate. public apology may requested.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_2-warning","dir":"","previous_headings":"Enforcement Guidelines","what":"2. Warning","title":"Contributor Covenant Code of Conduct","text":"Community Impact: violation single incident series actions. Consequence: warning consequences continued behavior. interaction people involved, including unsolicited interaction enforcing Code Conduct, specified period time. includes avoiding interactions community spaces well external channels like social media. Violating terms may lead temporary permanent ban.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_3-temporary-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"3. Temporary Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: serious violation community standards, including sustained inappropriate behavior. Consequence: temporary ban sort interaction public communication community specified period time. public private interaction people involved, including unsolicited interaction enforcing Code Conduct, allowed period. Violating terms may lead permanent ban.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"id_4-permanent-ban","dir":"","previous_headings":"Enforcement Guidelines","what":"4. Permanent Ban","title":"Contributor Covenant Code of Conduct","text":"Community Impact: Demonstrating pattern violation community standards, including sustained inappropriate behavior, harassment individual, aggression toward disparagement classes individuals. Consequence: permanent ban sort public interaction within community.","code":""},{"path":"https://tailor.tidymodels.org/CODE_OF_CONDUCT.html","id":"attribution","dir":"","previous_headings":"","what":"Attribution","title":"Contributor Covenant Code of Conduct","text":"Code Conduct adapted Contributor Covenant, version 2.1, available https://www.contributor-covenant.org/version/2/1/code_of_conduct.html. Community Impact Guidelines inspired [Mozilla’s code conduct enforcement ladder][https://github.com/mozilla/inclusion]. answers common questions code conduct, see FAQ https://www.contributor-covenant.org/faq. Translations available https://www.contributor-covenant.org/translations.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to tailor","title":"Contributing to tailor","text":"outlines propose change tailor. detailed discussion contributing tidyverse packages, please see development contributing guide code review principles.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to tailor","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to tailor","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See guide create great issue advice.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to tailor","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"tidymodels/tailor\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to tailor","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"https://tailor.tidymodels.org/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to tailor","text":"Please note tailor project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"https://tailor.tidymodels.org/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"MIT License","title":"MIT License","text":"Copyright (c) 2024 tailor authors Permission hereby granted, free charge, person obtaining copy software associated documentation files (“Software”), deal Software without restriction, including without limitation rights use, copy, modify, merge, publish, distribute, sublicense, /sell copies Software, permit persons Software furnished , subject following conditions: copyright notice permission notice shall included copies substantial portions Software. SOFTWARE PROVIDED “”, WITHOUT WARRANTY KIND, EXPRESS IMPLIED, INCLUDING LIMITED WARRANTIES MERCHANTABILITY, FITNESS PARTICULAR PURPOSE NONINFRINGEMENT. EVENT SHALL AUTHORS COPYRIGHT HOLDERS LIABLE CLAIM, DAMAGES LIABILITY, WHETHER ACTION CONTRACT, TORT OTHERWISE, ARISING , CONNECTION SOFTWARE USE DEALINGS SOFTWARE.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with tailor","title":"Getting help with tailor","text":"Thanks using tailor! filing issue, places explore pieces put together make process smooth possible.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with tailor","text":"Start making minimal reproducible example using reprex package. haven’t heard used reprex , ’re treat! Seriously, reprex make R-question-asking endeavors easier (pretty incredible ROI five ten minutes ’ll take learn ’s ). additional reprex pointers, check Get help! section tidyverse site.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"where-to-ask","dir":"","previous_headings":"","what":"Where to ask?","title":"Getting help with tailor","text":"Armed reprex, next step figure ask. ’s question: start community.rstudio.com, /StackOverflow. people answer questions. ’s bug: ’re right place, file issue. ’re sure: let community help figure ! problem bug feature request, can easily return report . opening new issue, sure search issues pull requests make sure bug hasn’t reported /already fixed development version. default, search pre-populated :issue :open. can edit qualifiers (e.g. :pr, :closed) needed. example, ’d simply remove :open search issues repo, open closed.","code":""},{"path":"https://tailor.tidymodels.org/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with tailor","text":"efficient possible, development tidyverse packages tends bursty, shouldn’t worry don’t get immediate response. Typically don’t look repo sufficient quantity issues accumulates, ’s burst intense activity focus efforts. makes development efficient avoids expensive context switching problems, cost taking longer get back . process makes good reprex particularly important might multiple months initial report start working . can’t reproduce bug, can’t fix !","code":""},{"path":"https://tailor.tidymodels.org/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Simon Couch. Author. Hannah Frick. Author. Emil HvitFeldt. Author. Max Kuhn. Author, maintainer. Posit Software, PBC. Copyright holder, funder.","code":""},{"path":"https://tailor.tidymodels.org/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Couch S, Frick H, HvitFeldt E, Kuhn M (2024). tailor: Iterative Steps Postprocessing Model Predictions. R package version 0.0.0.9001, https://tailor.tidymodels.org, https://github.com/tidymodels/tailor.","code":"@Manual{, title = {tailor: Iterative Steps for Postprocessing Model Predictions}, author = {Simon Couch and Hannah Frick and Emil HvitFeldt and Max Kuhn}, year = {2024}, note = {R package version 0.0.0.9001, https://tailor.tidymodels.org}, url = {https://github.com/tidymodels/tailor}, }"},{"path":"https://tailor.tidymodels.org/index.html","id":"tailor","dir":"","previous_headings":"","what":"Iterative Steps for Postprocessing Model Predictions","title":"Iterative Steps for Postprocessing Model Predictions","text":"Postprocessors refine predictions outputted machine learning models improve predictive performance better satisfy distributional limitations. package introduces ‘tailor’ objects, compose iterative adjustments model predictions. addition utilities create new adjustments, package provides number pre-written ones: probability distributions: calibration transformation probabilities hard class predictions: thresholds, equivocal zones numeric distributions: calibration, range Tailors tightly integrated tidymodels framework. greatest ease use, situate tailors model workflows add_tailor(). package active development; please treat experimental don’t depend syntax staying .","code":""},{"path":"https://tailor.tidymodels.org/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Iterative Steps for Postprocessing Model Predictions","text":"can install development version tailor like :","code":"pak::pak(\"tidymodels/tailor\")"},{"path":"https://tailor.tidymodels.org/index.html","id":"example","dir":"","previous_headings":"","what":"Example","title":"Iterative Steps for Postprocessing Model Predictions","text":"two_class_example dataset modeldata gives true value outcome variable truth well predicted probabilities (Class1 Class2). hard class predictions, predicted, \"Class1\" probability assigned \"Class1\" .5, \"Class2\" otherwise. model predicts \"Class1\" often \"Class2\". wanted model predict \"Class2\" often, increase probability threshold assigned \"Class1\" hard class prediction \"Class1\". tailor package, adjustment implemented adjust_probability_threshold(), can situated tailor object. tailors must fitted can predict new data. adjustments like adjust_probability_threshold(), ’s training actually happens fit() step besides recording name type relevant variables. adjustments, like probability calibration adjust_probability_calibration(), parameters actually estimated fit() step separate data used train postprocessor evaluate performance. case, though, can fit() whole dataset. resulting object still tailor, now flagged trained. used model workflow via add_tailor(), arguments fit() tailor set automatically (addition data splitting needed postprocessors require training). Now, passed new data, trained tailor determine outputted class based whether probability assigned level \"Class1\" .9, resulting predictions \"Class2\" . Tailors compose adjustments; several adjust_*() functions called iteratively, tailors apply order fit() predict() time.","code":"library(tailor) library(modeldata) 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 head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 post_obj <- tailor() %>% adjust_probability_threshold(threshold = .9) post_obj #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.9. post_res <- fit( post_obj, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) post_res #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.9. [trained] predict(post_res, two_class_example) %>% count(predicted) #> # A tibble: 2 × 2 #> predicted n #> #> 1 Class1 180 #> 2 Class2 320"},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":null,"dir":"Reference","previous_headings":"","what":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"Equivocal zones describe intervals predicted probabilities deemed uncertain ambiguous assigned hard class. Rather predicting hard class probability close threshold, tailors using adjustment predict \"[EQ]\".","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"","code":"adjust_equivocal_zone(x, value = 0.1, threshold = NULL)"},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"x tailor(). value numeric value (zero 1/2) hardhat::tune(). value size buffer around threshold. threshold numeric value (zero one) hardhat::tune(). Defaults adjust_probability_threshold(threshold) previously set x, 1 / 2 .","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"function transforms class prediction column estimate type class_pred probably::class_pred(). can loosely think column type factor, except possible entry [EQ] level excluded performance metric calculations. result, output column number levels input, except now possible entry [EQ] tidymodels funcitons know exclude analyses.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_equivocal_zone.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Apply an equivocal zone to a binary classification model. — adjust_equivocal_zone","text":"","code":"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 library(modeldata) head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 # `predicted` gives hard class predictions based on probabilities two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 # when probabilities are within (.25, .75), consider them equivocal tlr <- tailor() %>% adjust_equivocal_zone(value = 1 / 4) tlr #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Add equivocal zone of size 0.25. # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) tlr_fit #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Add equivocal zone of size 0.25. [trained] # adjust hard class predictions predict(tlr_fit, two_class_example) %>% count(predicted) #> # A tibble: 3 × 2 #> predicted n #> #> 1 [EQ] 86 #> 2 Class1 229 #> 3 Class2 185"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-calibrate numeric predictions — adjust_numeric_calibration","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"Calibration regression models involves adjusting model's predictions adjust correlated errors, ensuring predicted values align closely actual observed values across entire range outputs.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"","code":"adjust_numeric_calibration(x, method = NULL)"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"x tailor(). method Character. One \"linear\", \"isotonic\", \"isotonic_boot\", corresponding function probably package probably::cal_estimate_linear(), probably::cal_estimate_isotonic(), probably::cal_estimate_isotonic_boot(), respectively.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"adjustment requires estimation , , different subsets data used train evaluate predictions. See section name ?workflows::add_tailor() information preventing data leakage postprocessors require estimation. situated workflow, tailors automatically estimated appropriate subsets data.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_calibration.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Re-calibrate numeric predictions — adjust_numeric_calibration","text":"","code":"library(tibble) # create example data set.seed(1) d_calibration <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d_test <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d_calibration #> # A tibble: 100 × 2 #> y y_pred #> #> 1 -0.626 -0.934 #> 2 0.184 0.134 #> 3 -0.836 -1.33 #> 4 1.60 0.956 #> 5 0.330 -0.490 #> 6 -0.820 1.36 #> 7 0.487 0.960 #> 8 0.738 1.28 #> 9 0.576 0.672 #> 10 -0.305 1.53 #> # ℹ 90 more rows # specify calibration tlr <- tailor() %>% adjust_numeric_calibration(method = \"linear\") # train tailor on a subset of data. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit(tlr, d_calibration, outcome = y, estimate = y_pred) # apply to predictions on another subset of data d_test #> # A tibble: 100 × 2 #> y y_pred #> #> 1 0.409 1.10 #> 2 1.69 -0.203 #> 3 1.59 2.76 #> 4 -0.331 -0.549 #> 5 -2.29 0.512 #> 6 2.50 2.76 #> 7 0.667 0.416 #> 8 0.541 0.838 #> 9 -0.0134 -1.03 #> 10 0.510 0.578 #> # ℹ 90 more rows predict(tlr_fit, d_test) #> # A tibble: 100 × 2 #> y y_pred #> #> 1 0.409 0.497 #> 2 1.69 0.162 #> 3 1.59 0.580 #> 4 -0.331 -0.0230 #> 5 -2.29 0.408 #> 6 2.50 0.580 #> 7 0.667 0.386 #> 8 0.541 0.463 #> 9 -0.0134 -0.319 #> 10 0.510 0.421 #> # ℹ 90 more rows"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":null,"dir":"Reference","previous_headings":"","what":"Truncate the range of numeric predictions — adjust_numeric_range","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"Truncating ranges involves limiting output model specific range values, typically avoid extreme unrealistic predictions. technique can help improve practical applicability model's outputs constraining within reasonable bounds based domain knowledge physical limitations.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"","code":"adjust_numeric_range(x, lower_limit = -Inf, upper_limit = Inf)"},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"x tailor(). upper_limit, lower_limit numeric value, NA (truncation) hardhat::tune().","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_numeric_range.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Truncate the range of numeric predictions — adjust_numeric_range","text":"","code":"if (FALSE) { library(tibble) # create example data set.seed(1) d <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) d # specify calibration tlr <- tailor() %>% adjust_numeric_range(lower_limit = 1) # train tailor by passing column names. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit(tlr, d, outcome = y, estimate = y_pred) predict(tlr_fit, d) }"},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":null,"dir":"Reference","previous_headings":"","what":"Change or add variables — adjust_predictions_custom","title":"Change or add variables — adjust_predictions_custom","text":"adjustment functions allows arbitrary transformations model predictions using dplyr::mutate() statements.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change or add variables — adjust_predictions_custom","text":"","code":"adjust_predictions_custom(x, ..., .pkgs = character(0))"},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change or add variables — adjust_predictions_custom","text":"x tailor(). ... Name-value pairs expressions. See dplyr::mutate(). .pkgs character string extra packages needed execute commands.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Change or add variables — adjust_predictions_custom","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_predictions_custom.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change or add variables — adjust_predictions_custom","text":"","code":"library(modeldata) head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 tlr <- tailor() %>% adjust_equivocal_zone() %>% adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2)) tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) predict(tlr_fit, two_class_example) %>% head() #> # A tibble: 6 × 5 #> truth Class1 Class2 predicted linear_predictor #> #> 1 Class2 0.00359 0.996 Class2 5.63 #> 2 Class1 0.679 0.321 Class1 -0.747 #> 3 Class2 0.111 0.889 Class2 2.08 #> 4 Class1 0.735 0.265 Class1 -1.02 #> 5 Class2 0.0162 0.984 Class2 4.10 #> 6 Class1 0.999 0.000725 Class1 -7.23"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":null,"dir":"Reference","previous_headings":"","what":"Re-calibrate classification probability predictions — adjust_probability_calibration","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"Calibration process adjusting model's outputted probabilities match observed frequencies events. technique aims ensure model predicts certain probability outcome, probability accurately reflects true likelihood outcome occurring.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"","code":"adjust_probability_calibration(x, method = NULL)"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"x tailor(). method Character. One \"logistic\", \"multinomial\", \"beta\", \"isotonic\", \"isotonic_boot\", corresponding function probably package probably::cal_estimate_logistic(), probably::cal_estimate_multinomial(), etc., respectively.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"adjustment requires estimation , , different subsets data used train evaluate predictions. See section name ?workflows::add_tailor() information preventing data leakage postprocessors require estimation. situated workflow, tailors automatically estimated appropriate subsets data.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_calibration.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Re-calibrate classification probability predictions — adjust_probability_calibration","text":"","code":"if (FALSE) { library(modeldata) # split example data set.seed(1) in_rows <- sample(c(TRUE, FALSE), nrow(two_class_example), replace = TRUE) d_calibration <- two_class_example[in_rows, ] d_test <- two_class_example[!in_rows, ] head(d_calibration) # specify calibration tlr <- tailor() %>% adjust_probability_calibration(method = \"logistic\") # train tailor on a subset of data. situate in a modeling workflow with # `workflows::add_tailor()` to avoid having to specify column names manually tlr_fit <- fit( tlr, d_calibration, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) # apply to predictions on another subset of data head(d_test) predict(tlr_fit, d_test) }"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":null,"dir":"Reference","previous_headings":"","what":"Change the event threshold — adjust_probability_threshold","title":"Change the event threshold — adjust_probability_threshold","text":"Many machine learning systems determine hard class predictions first predicting probability event predicting event occur respective probability 0.5. adjustment allows practitioners determine hard class predictions using threshold 0.5. setting appropriate thresholds, one can balance trade-different types errors (false positives false negatives) optimize model's performance specific use cases.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Change the event threshold — adjust_probability_threshold","text":"","code":"adjust_probability_threshold(x, threshold = 0.5)"},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Change the event threshold — adjust_probability_threshold","text":"x tailor(). threshold numeric value (zero one) hardhat::tune().","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Change the event threshold — adjust_probability_threshold","text":"adjustment require estimation , , data used train fit() can predicted predict(); fitting adjustment just collects metadata supplied column names risk data leakage.","code":""},{"path":"https://tailor.tidymodels.org/reference/adjust_probability_threshold.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Change the event threshold — adjust_probability_threshold","text":"","code":"library(modeldata) # `predicted` gives hard class predictions based on probability threshold .5 head(two_class_example) #> truth Class1 Class2 predicted #> 1 Class2 0.003589243 0.9964107574 Class2 #> 2 Class1 0.678621054 0.3213789460 Class1 #> 3 Class2 0.110893522 0.8891064779 Class2 #> 4 Class1 0.735161703 0.2648382969 Class1 #> 5 Class2 0.016239960 0.9837600397 Class2 #> 6 Class1 0.999275071 0.0007249286 Class1 # use a threshold of .1 instead: tlr <- tailor() %>% adjust_probability_threshold(.1) # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) # adjust hard class predictions predict(tlr_fit, two_class_example) %>% head() #> # A tibble: 6 × 4 #> truth Class1 Class2 predicted #> #> 1 Class2 0.00359 0.996 Class2 #> 2 Class1 0.679 0.321 Class1 #> 3 Class2 0.111 0.889 Class1 #> 4 Class1 0.735 0.265 Class1 #> 5 Class2 0.0162 0.984 Class2 #> 6 Class1 0.999 0.000725 Class1"},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit and predict from tailors — fit.tailor","title":"Fit and predict from tailors — fit.tailor","text":"functions apply fit() predict() methods adjustment added tailor, order applied. Users need interface methods directly tailors situated inside model workflows ?workflows::add_tailor().","code":""},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit and predict from tailors — fit.tailor","text":"","code":"# S3 method for class 'tailor' fit(object, .data, outcome, estimate, probabilities = c(), ...) # S3 method for class 'tailor' predict(object, new_data, ...)"},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit and predict from tailors — fit.tailor","text":"object tailor(). .data, new_data data frame containing predictions model. outcome required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name outcome variable. estimate required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name point estimate (e.g. predicted class), tidymodels, corresponds column names .pred, .pred_class, .pred_time. probabilities required used independently ?workflows::add_tailor() \"binary\" \"multiclass\" types, can also passed fit() time instead. column names class probability estimates. given order factor levels estimate. ... Currently ignored.","code":""},{"path":"https://tailor.tidymodels.org/reference/fit.tailor.html","id":"data-usage","dir":"Reference","previous_headings":"","what":"Data Usage","title":"Fit and predict from tailors — fit.tailor","text":"adjustments require estimating parameters, training fit() simply evaluates tidyselect expressions logs column names. others, adjust_numeric_calibration(), adjustments actually learn data; case, separate subsets data used training tailor evaluating performance predictions. See Data Usage section ?workflows::add_tailor() information tidymodels makes split; situated model workflow, tailors automatically trained appropriate subset data.","code":""},{"path":"https://tailor.tidymodels.org/reference/reexports.html","id":null,"dir":"Reference","previous_headings":"","what":"Objects exported from other packages — reexports","title":"Objects exported from other packages — reexports","text":"objects imported packages. Follow links see documentation. dplyr %>% generics fit, required_pkgs, tidy, tunable, tune_args hardhat extract_parameter_dials, extract_parameter_set_dials","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor-internals.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal tailor functions — tailor-internals","title":"Internal tailor functions — tailor-internals","text":"Utilities use downstream packages.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor-internals.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal tailor functions — tailor-internals","text":"","code":"tailor_fully_trained(x) tailor_requires_fit(x)"},{"path":"https://tailor.tidymodels.org/reference/tailor-package.html","id":null,"dir":"Reference","previous_headings":"","what":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","title":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","text":"Postprocessors refine predictions outputted machine learning models improve predictive performance better satisfy distributional limitations. package introduces 'tailor' objects, compose iterative adjustments model predictions. number pre-written adjustments provided package, like calibration equivocal zones, well utilities compose new ones. Tailors tightly integrated 'tidymodels' framework.","code":""},{"path":[]},{"path":"https://tailor.tidymodels.org/reference/tailor-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"tailor: Iterative Steps for Postprocessing Model Predictions — tailor-package","text":"Maintainer: Max Kuhn max@posit.co Authors: Simon Couch simon.couch@posit.co Hannah Frick hannah@posit.co Emil HvitFeldt emil.hvitfeldt@posit.co contributors: Posit Software, PBC [copyright holder, funder]","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Declare post-processing for model predictions — tailor","title":"Declare post-processing for model predictions — tailor","text":"Tailors compose iterative adjustments model predictions. initializing tailor function, add adjustment specifications adjust_*() functions: probability distributions: adjust_probability_calibration() transformation probabilities hard class predictions: adjust_probability_threshold(), adjust_equivocal_zone() numeric distributions: adjust_numeric_calibration(), adjust_numeric_range() ad-hoc adjustments, see adjust_predictions_custom(). Tailors must trained fit() applied new data predict(). Tailors tightly integrated tidymodels framework; greatest ease use, situate tailors model workflows ?workflows::add_tailor().","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Declare post-processing for model predictions — tailor","text":"","code":"tailor(outcome = NULL, estimate = NULL, probabilities = NULL)"},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Declare post-processing for model predictions — tailor","text":"outcome required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name outcome variable. estimate required used independently ?workflows::add_tailor(), can also passed fit() time instead. column name point estimate (e.g. predicted class), tidymodels, corresponds column names .pred, .pred_class, .pred_time. probabilities required used independently ?workflows::add_tailor() \"binary\" \"multiclass\" types, can also passed fit() time instead. column names class probability estimates. given order factor levels estimate.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ordering-of-adjustments","dir":"Reference","previous_headings":"","what":"Ordering of adjustments","title":"Declare post-processing for model predictions — tailor","text":"composing multiple adjustments tailor object, order matters must follow specific rules depending type predictions adjusted (classification regression). classification problems (binary multiclass), adjustments modify probability estimates (e.g., adjust_probability_calibration()) must applied adjustments change hard class predictions (including adjust_equivocal_zone()). ensures class predictions based final calibrated probabilities. regression problems, adjust_numeric_calibration() must applied numeric adjustments. ensures subsequent adjustments work calibrated predictions. Generally, adjustments duplicated (.e. adjustment type used multiple times tailor object), though adjust_predictions_custom() can used multiple times. Adjustments different prediction types mixed—numeric adjustments (regression) probability adjustments (classification) used tailor object. ordering rules violated, tailor() raise error describing issue.","code":""},{"path":"https://tailor.tidymodels.org/reference/tailor.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Declare post-processing for model predictions — tailor","text":"","code":"library(dplyr) library(modeldata) # `predicted` gives hard class predictions based on probabilities two_class_example %>% count(predicted) #> predicted n #> 1 Class1 277 #> 2 Class2 223 # change the probability threshold to allot one class vs the other tlr <- tailor() %>% adjust_probability_threshold(threshold = .1) tlr #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. # fit by supplying column names. situate in a modeling workflow # with `workflows::add_tailor()` to avoid having to do so manually tlr_fit <- fit( tlr, two_class_example, outcome = c(truth), estimate = c(predicted), probabilities = c(Class1, Class2) ) tlr_fit #> #> ── tailor ────────────────────────────────────────────────────────────────────── #> A binary postprocessor with 1 adjustment: #> #> • Adjust probability threshold to 0.1. [trained] # adjust hard class predictions predict(tlr_fit, two_class_example) %>% count(predicted) #> # A tibble: 2 × 2 #> predicted n #> #> 1 Class1 362 #> 2 Class2 138"},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":null,"dir":"Reference","previous_headings":"","what":"Tidy a tailor object — tidy.tailor","title":"Tidy a tailor object — tidy.tailor","text":"Describe tailor's adjustments tibble one row per adjustment.","code":""},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Tidy a tailor object — tidy.tailor","text":"","code":"# S3 method for class 'tailor' tidy(x, number = NA, ...)"},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Tidy a tailor object — tidy.tailor","text":"x tailor() object. number Optional. single integer 1 number adjustments. ... Currently unused; must empty.","code":""},{"path":"https://tailor.tidymodels.org/reference/tidy.tailor.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Tidy a tailor object — tidy.tailor","text":"tibble containing information tailor's adjustments including ordering, whether trained, whether require training separate calibration set.","code":""}]