Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: probably
Title: Tools for Post-Processing Predicted Values
Version: 1.1.1.9000
Version: 1.1.1.9001
Authors@R: c(
person("Max", "Kuhn", , "max@posit.co", role = c("aut", "cre")),
person("Davis", "Vaughan", , "davis@posit.co", role = "aut"),
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ S3method(required_pkgs,cal_estimate_multinomial)
S3method(required_pkgs,cal_estimate_multinomial_spline)
S3method(required_pkgs,cal_estimate_none)
S3method(required_pkgs,cal_object)
S3method(required_pkgs,int_conformal_cv)
S3method(required_pkgs,int_conformal_full)
S3method(required_pkgs,int_conformal_quantile)
S3method(required_pkgs,int_conformal_split)
S3method(threshold_perf,data.frame)
S3method(type_sum,cal_object)
S3method(vec_cast,character.class_pred)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# probably (development version)

* Add `required_pkgs()` methods to `int_conformal_cv()`, `int_conformal_full()`, `int_conformal_quantile()`, and `int_conformal_split()`. (#190)

# probably 1.1.1

* Updated unit tests for new ggplot2 release (#180).
Expand Down
10 changes: 10 additions & 0 deletions R/conformal_infer.R
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ print.int_conformal_full <- function(x, ...) {
invisible(x)
}

#' @rdname required_pkgs.int_conformal_cv
#' @keywords internal
#' @export
required_pkgs.int_conformal_full <- function(x, ...) {
model_pkgs <- required_pkgs(x$wflow)
model_pkgs <- c(model_pkgs, "probably")
model_pkgs <- unique(model_pkgs)
model_pkgs
}

# ------------------------------------------------------------------------------

#' Prediction intervals from conformal methods
Expand Down
13 changes: 13 additions & 0 deletions R/conformal_infer_cv.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,19 @@ print.int_conformal_cv <- function(x, ...) {
invisible(x)
}

#' S3 methods to track which additional packages are needed for prediction
#' intervals via conformal inference
#' @param x a conformal interval object
#' @inheritParams generics::required_pkgs
#' @export
required_pkgs.int_conformal_cv <- function(x, ...) {
model_pkgs <- map(x$models, required_pkgs)
model_pkgs <- unlist(model_pkgs)
model_pkgs <- c(model_pkgs, "probably")
model_pkgs <- unique(model_pkgs)
model_pkgs
}

# ------------------------------------------------------------------------------
# helpers

Expand Down
10 changes: 10 additions & 0 deletions R/conformal_infer_quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ print.int_conformal_quantile <- function(x, ...) {
invisible(x)
}

#' @rdname required_pkgs.int_conformal_cv
#' @keywords internal
#' @export
required_pkgs.int_conformal_quantile <- function(x, ...) {
model_pkgs <- required_pkgs(x$wflow)
model_pkgs <- c(model_pkgs, "probably")
model_pkgs <- unique(model_pkgs)
model_pkgs
}

#' @export
#' @rdname predict.int_conformal_full
predict.int_conformal_quantile <- function(object, new_data, ...) {
Expand Down
10 changes: 10 additions & 0 deletions R/conformal_infer_split.R
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ print.int_conformal_split <- function(x, ...) {
invisible(x)
}

#' @rdname required_pkgs.int_conformal_cv
#' @keywords internal
#' @export
required_pkgs.int_conformal_split <- function(x, ...) {
model_pkgs <- required_pkgs(x$wflow)
model_pkgs <- c(model_pkgs, "probably")
model_pkgs <- unique(model_pkgs)
model_pkgs
}

#' @export
#' @rdname predict.int_conformal_full
predict.int_conformal_split <- function(object, new_data, level = 0.95, ...) {
Expand Down
71 changes: 71 additions & 0 deletions man/int_conformal_full.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions man/required_pkgs.int_conformal_cv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions tests/testthat/test-conformal-intervals-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ test_that("split conformal quantile intervals", {
nrow(new_int),
nrow(sim_new)
)

expect_identical(
required_pkgs(lm_int),
c(required_pkgs(lm_int$wflow), "probably")
)
})
5 changes: 5 additions & 0 deletions tests/testthat/test-conformal-intervals-split.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,9 @@ test_that("split conformal intervals", {
nrow(new_int),
nrow(sim_new)
)

expect_identical(
required_pkgs(lm_int),
c(required_pkgs(lm_int$wflow), "probably")
)
})
10 changes: 10 additions & 0 deletions tests/testthat/test-conformal-intervals.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ test_that("conformal intervals", {
expect_true(
all(grid_bounds$.pred_lower < grid_bounds_90$.pred_lower)
)

expect_identical(
required_pkgs(smol_obj),
c(required_pkgs(smol_obj$wflow), "probably")
)

expect_identical(
required_pkgs(grid_int),
c(unique(unlist(map(grid_int$models, required_pkgs))), "probably")
)
})

test_that("conformal control", {
Expand Down