diff --git a/.Rbuildignore b/.Rbuildignore index c4bc749..e8d8e5f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,4 +1,4 @@ -^container\.Rproj$ +^tailor\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ ^README\.Rmd$ diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 50bf289..27668fe 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,6 +1,6 @@ -# Contributing to container +# Contributing to tailor -This outlines how to propose a change to container. +This outlines how to propose a change to tailor. For a detailed discussion on contributing to this and other tidyverse packages, please see the [development contributing guide](https://rstd.io/tidy-contrib) and our [code review principles](https://code-review.tidyverse.org/). ## Fixing typos @@ -18,7 +18,7 @@ See our guide on [how to create a great issue](https://code-review.tidyverse.org ### Pull request process -* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("tidymodels/container", fork = TRUE)`. +* Fork the package and clone onto your computer. If you haven't done this before, we recommend using `usethis::create_from_github("tidymodels/tailor", fork = TRUE)`. * Install all development dependencies with `devtools::install_dev_deps()`, and then make sure the package passes R CMD check by running `devtools::check()`. If R CMD check doesn't pass cleanly, it's a good idea to ask for help before continuing. @@ -42,6 +42,6 @@ See our guide on [how to create a great issue](https://code-review.tidyverse.org ## Code of Conduct -Please note that the container project is released with a +Please note that the tailor project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By contributing to this project you agree to abide by its terms. diff --git a/.github/SUPPORT.md b/.github/SUPPORT.md index d7ca002..17ab175 100644 --- a/.github/SUPPORT.md +++ b/.github/SUPPORT.md @@ -1,6 +1,6 @@ -# Getting help with container +# Getting help with tailor -Thanks for using container! +Thanks for using tailor! Before filing an issue, there are a few places to explore and pieces to put together to make the process as smooth as possible. ## Make a reprex @@ -16,12 +16,12 @@ Armed with your reprex, the next step is to figure out [where to ask](https://ww * If it's a question: start with [community.rstudio.com](https://community.rstudio.com/), and/or StackOverflow. There are more people there to answer questions. -* If it's a bug: you're in the right place, [file an issue](https://github.com/tidymodels/container/issues/new). +* If it's a bug: you're in the right place, [file an issue](https://github.com/tidymodels/tailor/issues/new). * If you're not sure: let the community help you figure it out! If your problem _is_ a bug or a feature request, you can easily return here and report it. -Before opening a new issue, be sure to [search issues and pull requests](https://github.com/tidymodels/container/issues) to make sure the bug hasn't been reported and/or already fixed in the development version. +Before opening a new issue, be sure to [search issues and pull requests](https://github.com/tidymodels/tailor/issues) to make sure the bug hasn't been reported and/or already fixed in the development version. By default, the search will be pre-populated with `is:issue is:open`. You can [edit the qualifiers](https://help.github.com/articles/searching-issues-and-pull-requests/) (e.g. `is:pr`, `is:closed`) as needed. For example, you'd simply remove `is:open` to search _all_ issues in the repo, open or closed. diff --git a/DESCRIPTION b/DESCRIPTION index 8d276a8..0b13cba 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: container +Package: tailor Title: Sandbox for a postprocessor object Version: 0.0.0.9001 Authors@R: c( @@ -10,8 +10,8 @@ Authors@R: c( ) Description: Sandbox for a postprocessor object. License: MIT + file LICENSE -URL: https://github.com/tidymodels/container -BugReports: https://github.com/tidymodels/container/issues +URL: https://github.com/tidymodels/tailor +BugReports: https://github.com/tidymodels/tailor/issues Imports: cli, dplyr, diff --git a/LICENSE b/LICENSE index 9b4dc49..7598fdd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,2 +1,2 @@ YEAR: 2024 -COPYRIGHT HOLDER: container authors +COPYRIGHT HOLDER: tailor authors diff --git a/LICENSE.md b/LICENSE.md index 8092cca..5b0a17c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,6 +1,6 @@ # MIT License -Copyright (c) 2024 container authors +Copyright (c) 2024 tailor authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/NAMESPACE b/NAMESPACE index 80050c2..7df0cac 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,26 +1,26 @@ # Generated by roxygen2: do not edit by hand -S3method(fit,container) S3method(fit,equivocal_zone) S3method(fit,numeric_calibration) S3method(fit,numeric_range) S3method(fit,predictions_custom) S3method(fit,probability_calibration) S3method(fit,probability_threshold) -S3method(predict,container) +S3method(fit,tailor) S3method(predict,equivocal_zone) S3method(predict,numeric_calibration) S3method(predict,numeric_range) S3method(predict,predictions_custom) S3method(predict,probability_calibration) S3method(predict,probability_threshold) -S3method(print,container) +S3method(predict,tailor) S3method(print,equivocal_zone) S3method(print,numeric_calibration) S3method(print,numeric_range) S3method(print,predictions_custom) S3method(print,probability_calibration) S3method(print,probability_threshold) +S3method(print,tailor) S3method(required_pkgs,equivocal_zone) S3method(required_pkgs,numeric_calibration) S3method(required_pkgs,numeric_range) @@ -40,11 +40,11 @@ export(adjust_numeric_range) export(adjust_predictions_custom) export(adjust_probability_calibration) export(adjust_probability_threshold) -export(container) export(extract_parameter_dials) export(extract_parameter_set_dials) export(fit) export(required_pkgs) +export(tailor) export(tidy) export(tunable) export(tune_args) diff --git a/R/adjust-equivocal-zone.R b/R/adjust-equivocal-zone.R index 8f785a1..bcc4508 100644 --- a/R/adjust-equivocal-zone.R +++ b/R/adjust-equivocal-zone.R @@ -1,6 +1,6 @@ #' Apply an equivocal zone to a binary classification model. #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param value A numeric value (between zero and 1/2) or [hardhat::tune()]. The #' value is the size of the buffer around the threshold. #' @param threshold A numeric value (between zero and one) or [hardhat::tune()]. @@ -9,7 +9,7 @@ #' library(modeldata) #' #' post_obj <- -#' container() %>% +#' tailor() %>% #' adjust_equivocal_zone(value = 1 / 4) #' #' @@ -24,7 +24,7 @@ #' predict(post_res, two_class_example) #' @export adjust_equivocal_zone <- function(x, value = 0.1, threshold = 1 / 2) { - check_container(x) + check_tailor(x) if (!is_tune(value)) { check_number_decimal(value, min = 0, max = 1 / 2) } @@ -42,7 +42,7 @@ adjust_equivocal_zone <- function(x, value = 0.1, threshold = 1 / 2) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -68,7 +68,7 @@ print.equivocal_zone <- function(x, ...) { } #' @export -fit.equivocal_zone <- function(object, data, container = NULL, ...) { +fit.equivocal_zone <- function(object, data, tailor = NULL, ...) { new_operation( class(object), inputs = object$inputs, @@ -80,9 +80,9 @@ fit.equivocal_zone <- function(object, data, container = NULL, ...) { } #' @export -predict.equivocal_zone <- function(object, new_data, container, ...) { - est_nm <- container$columns$estimate - prob_nm <- container$columns$probabilities[1] +predict.equivocal_zone <- function(object, new_data, tailor, ...) { + est_nm <- tailor$columns$estimate + prob_nm <- tailor$columns$probabilities[1] lvls <- levels(new_data[[est_nm]]) col_syms <- syms(prob_nm[1]) cls_pred <- probably::make_two_class_pred( @@ -97,7 +97,7 @@ predict.equivocal_zone <- function(object, new_data, container, ...) { #' @export required_pkgs.equivocal_zone <- function(x, ...) { - c("container", "probably") + c("tailor", "probably") } #' @export @@ -105,7 +105,7 @@ tunable.equivocal_zone <- function(x, ...) { tibble::new_tibble(list( name = "buffer", call_info = list(list(pkg = "dials", fun = "buffer")), - source = "container", + source = "tailor", component = "equivocal_zone", component_id = "equivocal_zone" )) diff --git a/R/adjust-numeric-calibration.R b/R/adjust-numeric-calibration.R index 7e38327..aeab2ac 100644 --- a/R/adjust-numeric-calibration.R +++ b/R/adjust-numeric-calibration.R @@ -1,6 +1,6 @@ #' Re-calibrate numeric predictions #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param method Character. One of `"linear"`, `"isotonic"`, or #' `"isotonic_boot"`, corresponding to the function from the \pkg{probably} #' package [probably::cal_estimate_linear()], @@ -18,18 +18,18 @@ #' dat #' #' # specify calibration -#' reg_ctr <- -#' container() %>% +#' reg_tailor <- +#' tailor() %>% #' adjust_numeric_calibration(method = "linear") #' -#' # train container -#' reg_ctr_trained <- fit(reg_ctr, dat, outcome = y, estimate = y_pred) +#' # train tailor +#' reg_tailor_trained <- fit(reg_tailor, dat, outcome = y, estimate = y_pred) #' -#' predict(reg_ctr_trained, dat) +#' predict(reg_tailor_trained, dat) #' @export adjust_numeric_calibration <- function(x, method = NULL) { # to-do: add argument specifying `prop` in initial_split - check_container(x, calibration_type = "numeric") + check_tailor(x, calibration_type = "numeric") # wait to `check_method()` until `fit()` time if (!is.null(method)) { arg_match0( @@ -48,7 +48,7 @@ adjust_numeric_calibration <- function(x, method = NULL) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -65,8 +65,8 @@ print.numeric_calibration <- function(x, ...) { } #' @export -fit.numeric_calibration <- function(object, data, container = NULL, ...) { - method <- check_method(object$method, container$type) +fit.numeric_calibration <- function(object, data, tailor = NULL, ...) { + method <- check_method(object$method, tailor$type) # todo: adjust_numeric_calibration() should take arguments to pass to # cal_estimate_* via dots fit <- @@ -74,8 +74,8 @@ fit.numeric_calibration <- function(object, data, container = NULL, ...) { call2( paste0("cal_estimate_", method), .data = data, - truth = container$columns$outcome, - estimate = container$columns$estimate, + truth = tailor$columns$outcome, + estimate = tailor$columns$estimate, .ns = "probably" ) ) @@ -91,14 +91,14 @@ fit.numeric_calibration <- function(object, data, container = NULL, ...) { } #' @export -predict.numeric_calibration <- function(object, new_data, container, ...) { +predict.numeric_calibration <- function(object, new_data, tailor, ...) { probably::cal_apply(new_data, object$results$fit) } # todo probably needs required_pkgs methods for cal objects #' @export required_pkgs.numeric_calibration <- function(x, ...) { - c("container", "probably") + c("tailor", "probably") } #' @export diff --git a/R/adjust-numeric-range.R b/R/adjust-numeric-range.R index 49b77bb..35691e5 100644 --- a/R/adjust-numeric-range.R +++ b/R/adjust-numeric-range.R @@ -1,12 +1,12 @@ #' Truncate the range of numeric predictions #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param upper_limit,lower_limit A numeric value, NA (for no truncation) or #' [hardhat::tune()]. #' @export adjust_numeric_range <- function(x, lower_limit = -Inf, upper_limit = Inf) { # remaining input checks are done via probably::bound_prediction - check_container(x) + check_tailor(x) op <- new_operation( @@ -18,7 +18,7 @@ adjust_numeric_range <- function(x, lower_limit = -Inf, upper_limit = Inf) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -57,7 +57,7 @@ print.numeric_range <- function(x, ...) { } #' @export -fit.numeric_range <- function(object, data, container = NULL, ...) { +fit.numeric_range <- function(object, data, tailor = NULL, ...) { new_operation( class(object), inputs = object$inputs, @@ -69,8 +69,8 @@ fit.numeric_range <- function(object, data, container = NULL, ...) { } #' @export -predict.numeric_range <- function(object, new_data, container, ...) { - est_nm <- container$columns$estimate +predict.numeric_range <- function(object, new_data, tailor, ...) { + est_nm <- tailor$columns$estimate lo <- object$arguments$lower_limit hi <- object$arguments$upper_limit @@ -82,7 +82,7 @@ predict.numeric_range <- function(object, new_data, container, ...) { #' @export required_pkgs.numeric_range <- function(x, ...) { - c("container", "probably") + c("tailor", "probably") } #' @export @@ -93,7 +93,7 @@ tunable.numeric_range <- function(x, ...) { list(pkg = "dials", fun = "lower_limit"), # todo make these dials functions list(pkg = "dials", fun = "upper_limit") ), - source = "container", + source = "tailor", component = "numeric_range", component_id = "numeric_range" )) diff --git a/R/adjust-predictions-custom.R b/R/adjust-predictions-custom.R index ef8e7c4..ea76318 100644 --- a/R/adjust-predictions-custom.R +++ b/R/adjust-predictions-custom.R @@ -1,6 +1,6 @@ #' Change or add variables #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param .pkgs A character string of extra packages that are needed to execute #' the commands. #' @param ... Name-value pairs of expressions. See [dplyr::mutate()]. @@ -9,7 +9,7 @@ #' library(modeldata) #' #' post_obj <- -#' container() %>% +#' tailor() %>% #' adjust_equivocal_zone() %>% #' adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2)) #' @@ -25,7 +25,7 @@ #' predict(post_res, two_class_example) #' @export adjust_predictions_custom <- function(x, ..., .pkgs = character(0)) { - check_container(x) + check_tailor(x) cmds <- enquos(...) op <- @@ -38,7 +38,7 @@ adjust_predictions_custom <- function(x, ..., .pkgs = character(0)) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -55,7 +55,7 @@ print.predictions_custom <- function(x, ...) { } #' @export -fit.predictions_custom <- function(object, data, container = NULL, ...) { +fit.predictions_custom <- function(object, data, tailor = NULL, ...) { new_operation( class(object), inputs = object$inputs, @@ -67,13 +67,13 @@ fit.predictions_custom <- function(object, data, container = NULL, ...) { } #' @export -predict.predictions_custom <- function(object, new_data, container, ...) { +predict.predictions_custom <- function(object, new_data, tailor, ...) { dplyr::mutate(new_data, !!!object$arguments$commands) } #' @export required_pkgs.predictions_custom <- function(x, ...) { - unique(c("container", x$arguments$pkgs)) + unique(c("tailor", x$arguments$pkgs)) } #' @export diff --git a/R/adjust-probability-calibration.R b/R/adjust-probability-calibration.R index 35ea6e3..428eda4 100644 --- a/R/adjust-probability-calibration.R +++ b/R/adjust-probability-calibration.R @@ -1,6 +1,6 @@ #' Re-calibrate classification probability predictions #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param method Character. One of `"logistic"`, `"multinomial"`, #' `"beta"`, `"isotonic"`, or `"isotonic_boot"`, corresponding to the #' function from the \pkg{probably} package [probably::cal_estimate_logistic()], @@ -8,7 +8,7 @@ #' @export adjust_probability_calibration <- function(x, method = NULL) { # to-do: add argument specifying `prop` in initial_split - check_container(x, calibration_type = "probability") + check_tailor(x, calibration_type = "probability") # wait to `check_method()` until `fit()` time if (!is.null(method)) { arg_match( @@ -27,7 +27,7 @@ adjust_probability_calibration <- function(x, method = NULL) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -44,8 +44,8 @@ print.probability_calibration <- function(x, ...) { } #' @export -fit.probability_calibration <- function(object, data, container = NULL, ...) { - method <- check_method(object$method, container$type) +fit.probability_calibration <- function(object, data, tailor = NULL, ...) { + method <- check_method(object$method, tailor$type) # todo: adjust_probability_calibration() should take arguments to pass to # cal_estimate_* via dots # to-do: add argument specifying `prop` in initial_split @@ -55,8 +55,8 @@ fit.probability_calibration <- function(object, data, container = NULL, ...) { paste0("cal_estimate_", method), .data = data, # todo: make getters for the entries in `columns` - truth = container$columns$outcome, - estimate = container$columns$estimate, + truth = tailor$columns$outcome, + estimate = tailor$columns$estimate, .ns = "probably" ) ) @@ -72,14 +72,14 @@ fit.probability_calibration <- function(object, data, container = NULL, ...) { } #' @export -predict.probability_calibration <- function(object, new_data, container, ...) { +predict.probability_calibration <- function(object, new_data, tailor, ...) { probably::cal_apply(new_data, object$results$fit) } # todo probably needs required_pkgs methods for cal objects #' @export required_pkgs.probability_calibration <- function(x, ...) { - c("container", "probably") + c("tailor", "probably") } #' @export diff --git a/R/adjust-probability-threshold.R b/R/adjust-probability-threshold.R index 69eed9c..f224a58 100644 --- a/R/adjust-probability-threshold.R +++ b/R/adjust-probability-threshold.R @@ -1,13 +1,13 @@ #' Change the event threshold #' -#' @param x A [container()]. +#' @param x A [tailor()]. #' @param threshold A numeric value (between zero and one) or [hardhat::tune()]. #' @examples #' library(dplyr) #' library(modeldata) #' #' post_obj <- -#' container() %>% +#' tailor() %>% #' adjust_probability_threshold(threshold = .1) #' #' two_class_example %>% count(predicted) @@ -23,7 +23,7 @@ #' predict(post_res, two_class_example) %>% count(predicted) #' @export adjust_probability_threshold <- function(x, threshold = 0.5) { - check_container(x) + check_tailor(x) if (!is_tune(threshold)) { check_number_decimal(threshold, min = 10^-10, max = 1 - 10^-10) } @@ -38,7 +38,7 @@ adjust_probability_threshold <- function(x, threshold = 0.5) { trained = FALSE ) - new_container( + new_tailor( type = x$type, operations = c(x$operations, list(op)), columns = x$dat, @@ -64,7 +64,7 @@ print.probability_threshold <- function(x, ...) { } #' @export -fit.probability_threshold <- function(object, data, container = NULL, ...) { +fit.probability_threshold <- function(object, data, tailor = NULL, ...) { new_operation( class(object), inputs = object$inputs, @@ -76,9 +76,9 @@ fit.probability_threshold <- function(object, data, container = NULL, ...) { } #' @export -predict.probability_threshold <- function(object, new_data, container, ...) { - est_nm <- container$columns$estimate - prob_nm <- container$columns$probabilities[1] +predict.probability_threshold <- function(object, new_data, tailor, ...) { + est_nm <- tailor$columns$estimate + prob_nm <- tailor$columns$probabilities[1] lvls <- levels(new_data[[est_nm]]) new_data[[est_nm]] <- @@ -89,7 +89,7 @@ predict.probability_threshold <- function(object, new_data, container, ...) { #' @export required_pkgs.probability_threshold <- function(x, ...) { - c("container") + c("tailor") } #' @export @@ -97,7 +97,7 @@ tunable.probability_threshold <- function(x, ...) { tibble::new_tibble(list( name = "threshold", call_info = list(list(pkg = "dials", fun = "threshold")), - source = "container", + source = "tailor", component = "probability_threshold", component_id = "probability_threshold" )) diff --git a/R/container-package.R b/R/tailor-package.R similarity index 100% rename from R/container-package.R rename to R/tailor-package.R diff --git a/R/container.R b/R/tailor.R similarity index 87% rename from R/container.R rename to R/tailor.R index d3a232a..397db3d 100644 --- a/R/container.R +++ b/R/tailor.R @@ -12,9 +12,9 @@ #' @param time The name of the predicted event time. (not yet supported) #' @examples #' -#' container() +#' tailor() #' @export -container <- function(type = "unknown", outcome = NULL, estimate = NULL, +tailor <- function(type = "unknown", outcome = NULL, estimate = NULL, probabilities = NULL, time = NULL) { columns <- list( @@ -25,7 +25,7 @@ container <- function(type = "unknown", outcome = NULL, estimate = NULL, time = time ) - new_container( + new_tailor( type, operations = list(), columns = columns, @@ -34,7 +34,7 @@ container <- function(type = "unknown", outcome = NULL, estimate = NULL, ) } -new_container <- function(type, operations, columns, ptype, call) { +new_tailor <- function(type, operations, columns, ptype, call) { type <- arg_match0(type, c("unknown", "regression", "binary", "multiclass")) if (!is.list(operations)) { @@ -56,13 +56,13 @@ new_container <- function(type, operations, columns, ptype, call) { type = type, operations = operations, columns = columns, ptype = ptype ) - class(res) <- "container" + class(res) <- "tailor" res } #' @export -print.container <- function(x, ...) { - cli::cli_h1("Container") +print.tailor <- function(x, ...) { + cli::cli_h1("tailor") num_op <- length(x$operations) cli::cli_text( @@ -79,7 +79,7 @@ print.container <- function(x, ...) { } #' @export -fit.container <- function(object, .data, outcome, estimate, probabilities = c(), +fit.tailor <- function(object, .data, outcome, estimate, probabilities = c(), time = c(), ...) { # ------------------------------------------------------------------------------ # set columns via tidyselect @@ -108,9 +108,9 @@ fit.container <- function(object, .data, outcome, estimate, probabilities = c(), } ptype <- .data[0, ] - object <- set_container_type(object, .data[[columns$outcome]]) + object <- set_tailor_type(object, .data[[columns$outcome]]) - object <- new_container( + object <- new_tailor( object$type, operations = object$operations, columns = columns, @@ -124,12 +124,12 @@ fit.container <- function(object, .data, outcome, estimate, probabilities = c(), .data <- predict(object$operations[[op]], .data, object) } - # todo Add a fitted container class? + # todo Add a fitted tailor class? object } #' @export -predict.container <- function(object, new_data, ...) { +predict.tailor <- function(object, new_data, ...) { # validate levels/classes num_oper <- length(object$operations) for (op in seq_len(num_oper)) { @@ -141,7 +141,7 @@ predict.container <- function(object, new_data, ...) { new_data } -set_container_type <- function(object, y) { +set_tailor_type <- function(object, y) { if (object$type != "unknown") { return(object) } diff --git a/R/utils.R b/R/utils.R index 616ed04..e35f98c 100644 --- a/R/utils.R +++ b/R/utils.R @@ -44,22 +44,22 @@ new_operation <- function(cls, inputs, outputs, arguments, results = list(), } # predicates ------------------------------------------------------------------- -is_container <- function(x) { - inherits(x, "container") +is_tailor <- function(x) { + inherits(x, "tailor") } # ad-hoc checking -------------------------------------------------------------- -check_container <- function(x, calibration_type = NULL, call = caller_env(), arg = caller_arg(x)) { - if (!is_container(x)) { +check_tailor <- function(x, calibration_type = NULL, call = caller_env(), arg = caller_arg(x)) { + if (!is_tailor(x)) { cli_abort( - "{.arg {arg}} should be a {.help [{.cls container}](container::container)}, \\ + "{.arg {arg}} should be a {.help [{.cls tailor}](tailor::tailor)}, \\ not {.obj_type_friendly {x}}.", call = call ) } # check that the type of calibration ("numeric" or "probability") is - # compatible with the container type + # compatible with the tailor type if (!is.null(calibration_type)) { type <- x$type switch( @@ -75,10 +75,10 @@ check_container <- function(x, calibration_type = NULL, call = caller_env(), arg } check_calibration_type <- function(calibration_type, calibration_type_expected, - container_type, call) { + tailor_type, call) { if (!identical(calibration_type, calibration_type_expected)) { cli_abort( - "A {.field {container_type}} container is incompatible with the operation \\ + "A {.field {tailor_type}} tailor is incompatible with the operation \\ {.fun {paste0('adjust_', calibration_type, '_calibration')}}.", call = call ) @@ -88,13 +88,13 @@ check_calibration_type <- function(calibration_type, calibration_type_expected, types_regression <- c("linear", "isotonic", "isotonic_boot") types_binary <- c("logistic", "beta", "isotonic", "isotonic_boot") types_multiclass <- c("multinomial", "beta", "isotonic", "isotonic_boot") -# a check function to be called when a container is being `fit()`ted. -# by the time a container is fitted, we have: +# a check function to be called when a tailor is being `fit()`ted. +# by the time a tailor is fitted, we have: # * `method`, the `method` argument passed to an `adjust_*` function # * this argument has already been checked to agree with the kind of # `adjust_*()` function via `arg_match0()`. -# * `container_type`, the `type` argument either specified in `container()` -# or inferred in `fit.container()`. +# * `tailor_type`, the `type` argument either specified in `tailor()` +# or inferred in `fit.tailor()`. check_method <- function(method, type, arg = caller_arg(method), diff --git a/README.Rmd b/README.Rmd index f1206b1..3f2f4fe 100644 --- a/README.Rmd +++ b/README.Rmd @@ -13,22 +13,22 @@ knitr::opts_chunk$set( ) ``` -# container +# tailor [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) -[![CRAN status](https://www.r-pkg.org/badges/version/container)](https://CRAN.R-project.org/package=container) -[![R-CMD-check](https://github.com/tidymodels/container/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/container/actions/workflows/R-CMD-check.yaml) +[![CRAN status](https://www.r-pkg.org/badges/version/tailor)](https://CRAN.R-project.org/package=tailor) +[![R-CMD-check](https://github.com/tidymodels/tailor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/tailor/actions/workflows/R-CMD-check.yaml) -The goal of container is to provide a container for postprocessing. +The goal of tailor is to provide a tailor for postprocessing. This is going to undergo massive changes (especially the name), so please treat it as experimental and don't depend on the syntax staying the same. ## Installation -You can install the development version of container like so: +You can install the development version of tailor like so: ``` r -pak::pak("tidymodels/container") +pak::pak("tidymodels/tailor") ``` diff --git a/README.md b/README.md index 0356729..82b654f 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ -# container +# tailor [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) [![CRAN -status](https://www.r-pkg.org/badges/version/container)](https://CRAN.R-project.org/package=container) -[![R-CMD-check](https://github.com/tidymodels/container/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/container/actions/workflows/R-CMD-check.yaml) +status](https://www.r-pkg.org/badges/version/tailor)](https://CRAN.R-project.org/package=tailor) +[![R-CMD-check](https://github.com/tidymodels/tailor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/tailor/actions/workflows/R-CMD-check.yaml) -The goal of container is to provide a container for postprocessing. +The goal of tailor is to provide a tailor for postprocessing. This is going to undergo massive changes (especially the name), so please treat it as experimental and don’t depend on the syntax staying @@ -20,8 +20,8 @@ the same. ## Installation -You can install the development version of container like so: +You can install the development version of tailor like so: ``` r -pak::pak("tidymodels/container") +pak::pak("tidymodels/tailor") ``` diff --git a/inst/examples/container_regression_example.qmd b/inst/examples/container_regression_example.qmd index 6ff8480..c2fab4c 100644 --- a/inst/examples/container_regression_example.qmd +++ b/inst/examples/container_regression_example.qmd @@ -1,8 +1,8 @@ --- -title: "container regression example" +title: "tailor regression example" --- -This is an example regression analysis to show how the container package might work. +This is an example regression analysis to show how the tailor package might work. We'll use the [food delivery data](https://aml4td.org/chapters/whole-game.html) and start with a three-way split: @@ -12,7 +12,7 @@ We'll use the [food delivery data](https://aml4td.org/chapters/whole-game.html) library(tidymodels) library(bonsai) -library(container) +library(tailor) library(probably) library(patchwork) ``` @@ -20,7 +20,7 @@ library(patchwork) #| label: startup library(tidymodels) library(bonsai) # also requires lightgbm package -library(container) # pak::pak(c("tidymodels/container@max"), ask = FALSE) +library(tailor) # pak::pak(c("tidymodels/tailor@max"), ask = FALSE) library(probably) library(patchwork) @@ -101,7 +101,7 @@ We could manually use `cal_apply()` to adjust predictions, but instead, we'll ad #| label: post-1 post_obj <- - container() %>% + tailor() %>% adjust_numeric_calibration(bst_cal) post_obj ``` diff --git a/man/adjust_equivocal_zone.Rd b/man/adjust_equivocal_zone.Rd index 75e55f5..d0ca951 100644 --- a/man/adjust_equivocal_zone.Rd +++ b/man/adjust_equivocal_zone.Rd @@ -7,7 +7,7 @@ adjust_equivocal_zone(x, value = 0.1, threshold = 1/2) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{value}{A numeric value (between zero and 1/2) or \code{\link[hardhat:tune]{hardhat::tune()}}. The value is the size of the buffer around the threshold.} @@ -22,7 +22,7 @@ library(dplyr) library(modeldata) post_obj <- - container() \%>\% + tailor() \%>\% adjust_equivocal_zone(value = 1 / 4) diff --git a/man/adjust_numeric_calibration.Rd b/man/adjust_numeric_calibration.Rd index f37da10..0cf6ef5 100644 --- a/man/adjust_numeric_calibration.Rd +++ b/man/adjust_numeric_calibration.Rd @@ -7,7 +7,7 @@ adjust_numeric_calibration(x, method = NULL) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{method}{Character. One of \code{"linear"}, \code{"isotonic"}, or \code{"isotonic_boot"}, corresponding to the function from the \pkg{probably} @@ -30,12 +30,12 @@ dat <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100)) dat # specify calibration -reg_ctr <- - container() \%>\% +reg_tailor <- + tailor() \%>\% adjust_numeric_calibration(method = "linear") -# train container -reg_ctr_trained <- fit(reg_ctr, dat, outcome = y, estimate = y_pred) +# train tailor +reg_tailor_trained <- fit(reg_tailor, dat, outcome = y, estimate = y_pred) -predict(reg_ctr_trained, dat) +predict(reg_tailor_trained, dat) } diff --git a/man/adjust_numeric_range.Rd b/man/adjust_numeric_range.Rd index 08911f8..451a7d8 100644 --- a/man/adjust_numeric_range.Rd +++ b/man/adjust_numeric_range.Rd @@ -7,7 +7,7 @@ adjust_numeric_range(x, lower_limit = -Inf, upper_limit = Inf) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{upper_limit, lower_limit}{A numeric value, NA (for no truncation) or \code{\link[hardhat:tune]{hardhat::tune()}}.} diff --git a/man/adjust_predictions_custom.Rd b/man/adjust_predictions_custom.Rd index 2413ec6..915f1f2 100644 --- a/man/adjust_predictions_custom.Rd +++ b/man/adjust_predictions_custom.Rd @@ -7,7 +7,7 @@ adjust_predictions_custom(x, ..., .pkgs = character(0)) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{...}{Name-value pairs of expressions. See \code{\link[dplyr:mutate]{dplyr::mutate()}}.} @@ -22,7 +22,7 @@ library(dplyr) library(modeldata) post_obj <- - container() \%>\% + tailor() \%>\% adjust_equivocal_zone() \%>\% adjust_predictions_custom(linear_predictor = binomial()$linkfun(Class2)) diff --git a/man/adjust_probability_calibration.Rd b/man/adjust_probability_calibration.Rd index e174da9..c4120c5 100644 --- a/man/adjust_probability_calibration.Rd +++ b/man/adjust_probability_calibration.Rd @@ -7,7 +7,7 @@ adjust_probability_calibration(x, method = NULL) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{method}{Character. One of \code{"logistic"}, \code{"multinomial"}, \code{"beta"}, \code{"isotonic"}, or \code{"isotonic_boot"}, corresponding to the diff --git a/man/adjust_probability_threshold.Rd b/man/adjust_probability_threshold.Rd index b6881df..1c42ae0 100644 --- a/man/adjust_probability_threshold.Rd +++ b/man/adjust_probability_threshold.Rd @@ -7,7 +7,7 @@ adjust_probability_threshold(x, threshold = 0.5) } \arguments{ -\item{x}{A \code{\link[=container]{container()}}.} +\item{x}{A \code{\link[=tailor]{tailor()}}.} \item{threshold}{A numeric value (between zero and one) or \code{\link[hardhat:tune]{hardhat::tune()}}.} } @@ -19,7 +19,7 @@ library(dplyr) library(modeldata) post_obj <- - container() \%>\% + tailor() \%>\% adjust_probability_threshold(threshold = .1) two_class_example \%>\% count(predicted) diff --git a/man/container-package.Rd b/man/tailor-package.Rd similarity index 63% rename from man/container-package.Rd rename to man/tailor-package.Rd index 8f314aa..327e19d 100644 --- a/man/container-package.Rd +++ b/man/tailor-package.Rd @@ -1,17 +1,17 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/container-package.R +% Please edit documentation in R/tailor-package.R \docType{package} -\name{container-package} -\alias{container-package} -\title{container: Sandbox for a postprocessor object} +\name{tailor-package} +\alias{tailor-package} +\title{tailor: Sandbox for a postprocessor object} \description{ Sandbox for a postprocessor object. } \seealso{ Useful links: \itemize{ - \item \url{https://github.com/tidymodels/container} - \item Report bugs at \url{https://github.com/tidymodels/container/issues} + \item \url{https://github.com/tidymodels/tailor} + \item Report bugs at \url{https://github.com/tidymodels/tailor/issues} } } diff --git a/man/container.Rd b/man/tailor.Rd similarity index 89% rename from man/container.Rd rename to man/tailor.Rd index 53b68f1..362ebd7 100644 --- a/man/container.Rd +++ b/man/tailor.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/container.R -\name{container} -\alias{container} +% Please edit documentation in R/tailor.R +\name{tailor} +\alias{tailor} \title{Declare post-processing for model predictions} \usage{ -container( +tailor( type = "unknown", outcome = NULL, estimate = NULL, @@ -33,5 +33,5 @@ Declare post-processing for model predictions } \examples{ -container() +tailor() } diff --git a/container.Rproj b/tailor.Rproj similarity index 100% rename from container.Rproj rename to tailor.Rproj diff --git a/tests/testthat.R b/tests/testthat.R index 0dd3535..27ef1aa 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -7,6 +7,6 @@ # * https://testthat.r-lib.org/articles/special-files.html library(testthat) -library(container) +library(tailor) -test_check("container") +test_check("tailor") diff --git a/tests/testthat/_snaps/adjust-equivocal-zone.md b/tests/testthat/_snaps/adjust-equivocal-zone.md index 392c9b9..376b1d7 100644 --- a/tests/testthat/_snaps/adjust-equivocal-zone.md +++ b/tests/testthat/_snaps/adjust-equivocal-zone.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_equivocal_zone() + tailor() %>% adjust_equivocal_zone() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Add equivocal zone of size 0.1. @@ -12,10 +12,10 @@ --- Code - container() %>% adjust_equivocal_zone(hardhat::tune()) + tailor() %>% adjust_equivocal_zone(hardhat::tune()) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Add equivocal zone of optimized size. diff --git a/tests/testthat/_snaps/adjust-numeric-calibration.md b/tests/testthat/_snaps/adjust-numeric-calibration.md index 06aac0e..6e8b8cd 100644 --- a/tests/testthat/_snaps/adjust-numeric-calibration.md +++ b/tests/testthat/_snaps/adjust-numeric-calibration.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_numeric_calibration() + tailor() %>% adjust_numeric_calibration() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Re-calibrate numeric predictions. @@ -12,7 +12,7 @@ # errors informatively with bad input Code - adjust_numeric_calibration(container(), "boop") + adjust_numeric_calibration(tailor(), "boop") Condition Error in `adjust_numeric_calibration()`: ! `method` must be one of "linear", "isotonic", or "isotonic_boot", not "boop". @@ -20,15 +20,15 @@ --- Code - container("binary") %>% adjust_numeric_calibration("linear") + tailor("binary") %>% adjust_numeric_calibration("linear") Condition Error in `adjust_numeric_calibration()`: - ! A binary container is incompatible with the operation `adjust_numeric_calibration()`. + ! A binary tailor is incompatible with the operation `adjust_numeric_calibration()`. --- Code - container("regression") %>% adjust_numeric_calibration("binary") + tailor("regression") %>% adjust_numeric_calibration("binary") Condition Error in `adjust_numeric_calibration()`: ! `method` must be one of "linear", "isotonic", or "isotonic_boot", not "binary". diff --git a/tests/testthat/_snaps/adjust-numeric-range.md b/tests/testthat/_snaps/adjust-numeric-range.md index 2e02acd..078d342 100644 --- a/tests/testthat/_snaps/adjust-numeric-range.md +++ b/tests/testthat/_snaps/adjust-numeric-range.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_numeric_range() + tailor() %>% adjust_numeric_range() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Constrain numeric predictions to be between [-Inf, Inf]. @@ -12,10 +12,10 @@ --- Code - container() %>% adjust_numeric_range(hardhat::tune()) + tailor() %>% adjust_numeric_range(hardhat::tune()) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Constrain numeric predictions to be between [?, Inf]. @@ -23,10 +23,10 @@ --- Code - container() %>% adjust_numeric_range(-1, hardhat::tune()) + tailor() %>% adjust_numeric_range(-1, hardhat::tune()) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Constrain numeric predictions to be between [-1, ?]. @@ -34,10 +34,10 @@ --- Code - container() %>% adjust_numeric_range(hardhat::tune(), 1) + tailor() %>% adjust_numeric_range(hardhat::tune(), 1) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Constrain numeric predictions to be between [?, 1]. diff --git a/tests/testthat/_snaps/adjust-predictions-custom.md b/tests/testthat/_snaps/adjust-predictions-custom.md index 50ccfce..b118d62 100644 --- a/tests/testthat/_snaps/adjust-predictions-custom.md +++ b/tests/testthat/_snaps/adjust-predictions-custom.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_predictions_custom() + tailor() %>% adjust_predictions_custom() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Adjust predictions using custom code. diff --git a/tests/testthat/_snaps/adjust-probability-calibration.md b/tests/testthat/_snaps/adjust-probability-calibration.md index 9b6376b..a92fd44 100644 --- a/tests/testthat/_snaps/adjust-probability-calibration.md +++ b/tests/testthat/_snaps/adjust-probability-calibration.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_probability_calibration("logistic") + tailor() %>% adjust_probability_calibration("logistic") Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Re-calibrate classification probabilities. @@ -12,7 +12,7 @@ # errors informatively with bad input Code - adjust_probability_calibration(container(), "boop") + adjust_probability_calibration(tailor(), "boop") Condition Error in `adjust_probability_calibration()`: ! `method` must be one of "logistic", "multinomial", "beta", "isotonic", or "isotonic_boot", not "boop". @@ -20,15 +20,15 @@ --- Code - container("regression") %>% adjust_probability_calibration("binary") + tailor("regression") %>% adjust_probability_calibration("binary") Condition Error in `adjust_probability_calibration()`: - ! A regression container is incompatible with the operation `adjust_probability_calibration()`. + ! A regression tailor is incompatible with the operation `adjust_probability_calibration()`. --- Code - container("binary") %>% adjust_probability_calibration("linear") + tailor("binary") %>% adjust_probability_calibration("linear") Condition Error in `adjust_probability_calibration()`: ! `method` must be one of "logistic", "multinomial", "beta", "isotonic", or "isotonic_boot", not "linear". diff --git a/tests/testthat/_snaps/adjust-probability-threshold.md b/tests/testthat/_snaps/adjust-probability-threshold.md index 5e4b29f..bd6b449 100644 --- a/tests/testthat/_snaps/adjust-probability-threshold.md +++ b/tests/testthat/_snaps/adjust-probability-threshold.md @@ -1,10 +1,10 @@ # adjustment printing Code - container() %>% adjust_probability_threshold() + tailor() %>% adjust_probability_threshold() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Adjust probability threshold to 0.5. @@ -12,10 +12,10 @@ --- Code - container() %>% adjust_probability_threshold(hardhat::tune()) + tailor() %>% adjust_probability_threshold(hardhat::tune()) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 1 operation: * Adjust probability threshold to optimized value. diff --git a/tests/testthat/_snaps/container.md b/tests/testthat/_snaps/tailor.md similarity index 55% rename from tests/testthat/_snaps/container.md rename to tests/testthat/_snaps/tailor.md index f5f9ab8..4678fe4 100644 --- a/tests/testthat/_snaps/container.md +++ b/tests/testthat/_snaps/tailor.md @@ -1,28 +1,28 @@ -# container printing +# tailor printing Code - container() + tailor() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A postprocessor with 0 operations. --- Code - container(type = "binary") + tailor(type = "binary") Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A binary postprocessor with 0 operations. --- Code - container(type = "binary") %>% adjust_probability_threshold(0.2) + tailor(type = "binary") %>% adjust_probability_threshold(0.2) Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A binary postprocessor with 1 operation: * Adjust probability threshold to 0.2. @@ -30,11 +30,11 @@ --- Code - container(type = "binary") %>% adjust_probability_threshold(0.2) %>% + tailor(type = "binary") %>% adjust_probability_threshold(0.2) %>% adjust_equivocal_zone() Message - -- Container ------------------------------------------------------------------- + -- tailor ---------------------------------------------------------------------- A binary postprocessor with 2 operations: * Adjust probability threshold to 0.2. diff --git a/tests/testthat/_snaps/utils.md b/tests/testthat/_snaps/utils.md index 8e52628..2f4aaf8 100644 --- a/tests/testthat/_snaps/utils.md +++ b/tests/testthat/_snaps/utils.md @@ -1,8 +1,8 @@ -# check_container raises informative error +# check_tailor raises informative error Code adjust_probability_threshold("boop") Condition Error in `adjust_probability_threshold()`: - ! `x` should be a (`?container::container()`), not a string. + ! `x` should be a (`?tailor::tailor()`), not a string. diff --git a/tests/testthat/_snaps/validation-rules.md b/tests/testthat/_snaps/validation-rules.md index 0e9f3ff..e639920 100644 --- a/tests/testthat/_snaps/validation-rules.md +++ b/tests/testthat/_snaps/validation-rules.md @@ -1,7 +1,7 @@ # validation of operations (regression) Code - container(type = "regression") %>% adjust_numeric_range(lower_limit = 2) %>% + tailor(type = "regression") %>% adjust_numeric_range(lower_limit = 2) %>% adjust_numeric_calibration() %>% adjust_predictions_custom(squared = .pred^2) Condition Error in `adjust_numeric_calibration()`: @@ -10,7 +10,7 @@ # validation of operations (classification) Code - container(type = "binary") %>% adjust_probability_threshold(threshold = 0.4) %>% + tailor(type = "binary") %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_calibration() Condition Error in `adjust_probability_calibration()`: @@ -19,7 +19,7 @@ --- Code - container() %>% adjust_probability_threshold(threshold = 0.4) %>% + tailor() %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_calibration() Condition Error in `adjust_probability_calibration()`: @@ -28,7 +28,7 @@ --- Code - container(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% + tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_calibration() Condition @@ -38,7 +38,7 @@ --- Code - container() %>% adjust_predictions_custom(veg = "potato") %>% + tailor() %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_calibration() Condition @@ -48,7 +48,7 @@ --- Code - container(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% + tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_threshold(threshold = 0.5) %>% adjust_probability_calibration() @@ -59,7 +59,7 @@ --- Code - container() %>% adjust_predictions_custom(veg = "potato") %>% + tailor() %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = 0.4) %>% adjust_probability_threshold(threshold = 0.5) %>% adjust_probability_calibration() @@ -70,7 +70,7 @@ --- Code - container(type = "binary") %>% adjust_equivocal_zone(value = 0.2) %>% + tailor(type = "binary") %>% adjust_equivocal_zone(value = 0.2) %>% adjust_probability_threshold(threshold = 0.4) Condition Error in `adjust_probability_threshold()`: @@ -79,7 +79,7 @@ --- Code - container() %>% adjust_equivocal_zone(value = 0.2) %>% + tailor() %>% adjust_equivocal_zone(value = 0.2) %>% adjust_probability_threshold(threshold = 0.4) Condition Error in `adjust_probability_threshold()`: diff --git a/tests/testthat/test-adjust-equivocal-zone.R b/tests/testthat/test-adjust-equivocal-zone.R index 4ba9b0c..f3e1af2 100644 --- a/tests/testthat/test-adjust-equivocal-zone.R +++ b/tests/testthat/test-adjust-equivocal-zone.R @@ -1,4 +1,4 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_equivocal_zone()) - expect_snapshot(container() %>% adjust_equivocal_zone(hardhat::tune())) + expect_snapshot(tailor() %>% adjust_equivocal_zone()) + expect_snapshot(tailor() %>% adjust_equivocal_zone(hardhat::tune())) }) diff --git a/tests/testthat/test-adjust-numeric-calibration.R b/tests/testthat/test-adjust-numeric-calibration.R index d9392ef..10d7aad 100644 --- a/tests/testthat/test-adjust-numeric-calibration.R +++ b/tests/testthat/test-adjust-numeric-calibration.R @@ -1,20 +1,20 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_numeric_calibration()) + expect_snapshot(tailor() %>% adjust_numeric_calibration()) }) test_that("errors informatively with bad input", { - # check for `adjust_numeric_calibration(container)` is in `utils.R` tests + # check for `adjust_numeric_calibration(tailor)` is in `utils.R` tests - expect_snapshot(error = TRUE, adjust_numeric_calibration(container(), "boop")) + expect_snapshot(error = TRUE, adjust_numeric_calibration(tailor(), "boop")) expect_snapshot( error = TRUE, - container("binary") %>% adjust_numeric_calibration("linear") + tailor("binary") %>% adjust_numeric_calibration("linear") ) expect_snapshot( error = TRUE, - container("regression") %>% adjust_numeric_calibration("binary") + tailor("regression") %>% adjust_numeric_calibration("binary") ) - expect_no_condition(adjust_numeric_calibration(container())) - expect_no_condition(adjust_numeric_calibration(container(), "linear")) + expect_no_condition(adjust_numeric_calibration(tailor())) + expect_no_condition(adjust_numeric_calibration(tailor(), "linear")) }) diff --git a/tests/testthat/test-adjust-numeric-range.R b/tests/testthat/test-adjust-numeric-range.R index a2fcad7..eda96d3 100644 --- a/tests/testthat/test-adjust-numeric-range.R +++ b/tests/testthat/test-adjust-numeric-range.R @@ -1,7 +1,7 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_numeric_range()) - expect_snapshot(container() %>% adjust_numeric_range(hardhat::tune())) - expect_snapshot(container() %>% adjust_numeric_range(-1, hardhat::tune())) - expect_snapshot(container() %>% adjust_numeric_range(hardhat::tune(), 1)) + expect_snapshot(tailor() %>% adjust_numeric_range()) + expect_snapshot(tailor() %>% adjust_numeric_range(hardhat::tune())) + expect_snapshot(tailor() %>% adjust_numeric_range(-1, hardhat::tune())) + expect_snapshot(tailor() %>% adjust_numeric_range(hardhat::tune(), 1)) }) diff --git a/tests/testthat/test-adjust-predictions-custom.R b/tests/testthat/test-adjust-predictions-custom.R index f74f6b5..5d6d92b 100644 --- a/tests/testthat/test-adjust-predictions-custom.R +++ b/tests/testthat/test-adjust-predictions-custom.R @@ -1,3 +1,3 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_predictions_custom()) + expect_snapshot(tailor() %>% adjust_predictions_custom()) }) diff --git a/tests/testthat/test-adjust-probability-calibration.R b/tests/testthat/test-adjust-probability-calibration.R index 170d12a..1f05a41 100644 --- a/tests/testthat/test-adjust-probability-calibration.R +++ b/tests/testthat/test-adjust-probability-calibration.R @@ -1,20 +1,20 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_probability_calibration("logistic")) + expect_snapshot(tailor() %>% adjust_probability_calibration("logistic")) }) test_that("errors informatively with bad input", { - # check for `adjust_probably_calibration(container)` is in `utils.R` tests + # check for `adjust_probably_calibration(tailor)` is in `utils.R` tests - expect_snapshot(error = TRUE, adjust_probability_calibration(container(), "boop")) + expect_snapshot(error = TRUE, adjust_probability_calibration(tailor(), "boop")) expect_snapshot( error = TRUE, - container("regression") %>% adjust_probability_calibration("binary") + tailor("regression") %>% adjust_probability_calibration("binary") ) expect_snapshot( error = TRUE, - container("binary") %>% adjust_probability_calibration("linear") + tailor("binary") %>% adjust_probability_calibration("linear") ) - expect_no_condition(adjust_numeric_calibration(container())) - expect_no_condition(adjust_numeric_calibration(container(), "linear")) + expect_no_condition(adjust_numeric_calibration(tailor())) + expect_no_condition(adjust_numeric_calibration(tailor(), "linear")) }) diff --git a/tests/testthat/test-adjust-probability-threshold.R b/tests/testthat/test-adjust-probability-threshold.R index 94933d7..8300e10 100644 --- a/tests/testthat/test-adjust-probability-threshold.R +++ b/tests/testthat/test-adjust-probability-threshold.R @@ -1,4 +1,4 @@ test_that("adjustment printing", { - expect_snapshot(container() %>% adjust_probability_threshold()) - expect_snapshot(container() %>% adjust_probability_threshold(hardhat::tune())) + expect_snapshot(tailor() %>% adjust_probability_threshold()) + expect_snapshot(tailor() %>% adjust_probability_threshold(hardhat::tune())) }) diff --git a/tests/testthat/test-container.R b/tests/testthat/test-container.R deleted file mode 100644 index 2bc3cfa..0000000 --- a/tests/testthat/test-container.R +++ /dev/null @@ -1,13 +0,0 @@ -test_that("container printing", { - expect_snapshot(container()) - expect_snapshot(container(type = "binary")) - expect_snapshot( - container(type = "binary") %>% - adjust_probability_threshold(.2) - ) - expect_snapshot( - container(type = "binary") %>% - adjust_probability_threshold(.2) %>% - adjust_equivocal_zone() - ) -}) diff --git a/tests/testthat/test-tailor.R b/tests/testthat/test-tailor.R new file mode 100644 index 0000000..1c38236 --- /dev/null +++ b/tests/testthat/test-tailor.R @@ -0,0 +1,13 @@ +test_that("tailor printing", { + expect_snapshot(tailor()) + expect_snapshot(tailor(type = "binary")) + expect_snapshot( + tailor(type = "binary") %>% + adjust_probability_threshold(.2) + ) + expect_snapshot( + tailor(type = "binary") %>% + adjust_probability_threshold(.2) %>% + adjust_equivocal_zone() + ) +}) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index f6bd959..baec6b1 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,4 +1,4 @@ -test_that("check_container raises informative error", { +test_that("check_tailor raises informative error", { expect_snapshot(error = TRUE, adjust_probability_threshold("boop")) - expect_no_condition(container() %>% adjust_probability_threshold(.5)) + expect_no_condition(tailor() %>% adjust_probability_threshold(.5)) }) diff --git a/tests/testthat/test-validation-rules.R b/tests/testthat/test-validation-rules.R index 1a6e477..a1579dd 100644 --- a/tests/testthat/test-validation-rules.R +++ b/tests/testthat/test-validation-rules.R @@ -1,7 +1,7 @@ test_that("validation of operations (regression)", { expect_no_condition( - reg_ctr <- - container(type = "regression") %>% + reg_tailor <- + tailor(type = "regression") %>% adjust_numeric_calibration() %>% adjust_numeric_range(lower_limit = 2) %>% adjust_predictions_custom(squared = .pred^2) @@ -9,7 +9,7 @@ test_that("validation of operations (regression)", { expect_snapshot( error = TRUE, - container(type = "regression") %>% + tailor(type = "regression") %>% adjust_numeric_range(lower_limit = 2) %>% adjust_numeric_calibration() %>% adjust_predictions_custom(squared = .pred^2) @@ -18,8 +18,8 @@ test_that("validation of operations (regression)", { # todo should we error if a mutate occurs beforehand? Can we detect if it # modifies the prediction? expect_no_condition( - reg_ctr <- - container(type = "regression") %>% + reg_tailor <- + tailor(type = "regression") %>% adjust_predictions_custom(squared = .pred^2) %>% adjust_numeric_calibration() %>% adjust_numeric_range(lower_limit = 2) @@ -28,15 +28,15 @@ test_that("validation of operations (regression)", { test_that("validation of operations (classification)", { expect_no_condition( - cls_ctr_1 <- - container(type = "binary") %>% + cls_tailor_1 <- + tailor(type = "binary") %>% adjust_probability_calibration("logistic") %>% adjust_probability_threshold(threshold = .4) ) expect_no_condition( - cls_ctr_2 <- - container(type = "binary") %>% + cls_tailor_2 <- + tailor(type = "binary") %>% adjust_predictions_custom(starch = "potato") %>% adjust_predictions_custom(veg = "green beans") %>% adjust_probability_calibration("logistic") %>% @@ -45,21 +45,21 @@ test_that("validation of operations (classification)", { expect_snapshot( error = TRUE, - container(type = "binary") %>% + tailor(type = "binary") %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_calibration() ) expect_snapshot( error = TRUE, - container() %>% + tailor() %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_calibration() ) expect_snapshot( error = TRUE, - container(type = "binary") %>% + tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_calibration() @@ -67,7 +67,7 @@ test_that("validation of operations (classification)", { expect_snapshot( error = TRUE, - container() %>% + tailor() %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_calibration() @@ -75,7 +75,7 @@ test_that("validation of operations (classification)", { expect_snapshot( error = TRUE, - container(type = "binary") %>% + tailor(type = "binary") %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_threshold(threshold = .5) %>% @@ -84,7 +84,7 @@ test_that("validation of operations (classification)", { expect_snapshot( error = TRUE, - container() %>% + tailor() %>% adjust_predictions_custom(veg = "potato") %>% adjust_probability_threshold(threshold = .4) %>% adjust_probability_threshold(threshold = .5) %>% @@ -93,14 +93,14 @@ test_that("validation of operations (classification)", { expect_snapshot( error = TRUE, - container(type = "binary") %>% + tailor(type = "binary") %>% adjust_equivocal_zone(value = .2) %>% adjust_probability_threshold(threshold = .4) ) expect_snapshot( error = TRUE, - container() %>% + tailor() %>% adjust_equivocal_zone(value = .2) %>% adjust_probability_threshold(threshold = .4) ) @@ -108,11 +108,11 @@ test_that("validation of operations (classification)", { test_that("validation of operations (ambiguous type)", { expect_no_condition( - ambiguous_ctr <- - container() %>% + ambiguous_tailor <- + tailor() %>% adjust_predictions_custom(squared = .pred^2) %>% adjust_predictions_custom(boop = boop) ) - expect_equal(ambiguous_ctr$type, "unknown") + expect_equal(ambiguous_tailor$type, "unknown") })