Skip to content

Commit

Permalink
container -> tailor (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored May 3, 2024
1 parent 1412531 commit d1283f3
Show file tree
Hide file tree
Showing 48 changed files with 253 additions and 253 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
^container\.Rproj$
^tailor\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
Expand Down
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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.
8 changes: 4 additions & 4 deletions .github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Package: container
Package: tailor
Title: Sandbox for a postprocessor object
Version: 0.0.0.9001
Authors@R: c(
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2024
COPYRIGHT HOLDER: container authors
COPYRIGHT HOLDER: tailor authors
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions R/adjust-equivocal-zone.R
Original file line number Diff line number Diff line change
@@ -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()].
Expand All @@ -9,7 +9,7 @@
#' library(modeldata)
#'
#' post_obj <-
#' container() %>%
#' tailor() %>%
#' adjust_equivocal_zone(value = 1 / 4)
#'
#'
Expand All @@ -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)
}
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand All @@ -97,15 +97,15 @@ predict.equivocal_zone <- function(object, new_data, container, ...) {

#' @export
required_pkgs.equivocal_zone <- function(x, ...) {
c("container", "probably")
c("tailor", "probably")
}

#' @export
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"
))
Expand Down
28 changes: 14 additions & 14 deletions R/adjust-numeric-calibration.R
Original file line number Diff line number Diff line change
@@ -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()],
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -65,17 +65,17 @@ 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 <-
eval_bare(
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"
)
)
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions R/adjust-numeric-range.R
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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"
))
Expand Down
Loading

0 comments on commit d1283f3

Please sign in to comment.