Skip to content

Commit 8920333

Browse files
committed
many more experts (even of specific S3 methods)
1 parent 8b73b3b commit 8920333

27 files changed

+208
-139
lines changed

NAMESPACE

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@ S3method(predict,model_spec)
2525
S3method(predict,nullmodel)
2626
S3method(predict_class,"_lognet")
2727
S3method(predict_class,"_multnet")
28+
S3method(predict_class,model_fit)
2829
S3method(predict_classprob,"_lognet")
2930
S3method(predict_classprob,"_multnet")
31+
S3method(predict_classprob,model_fit)
32+
S3method(predict_confint,model_fit)
3033
S3method(predict_numeric,"_elnet")
34+
S3method(predict_numeric,model_fit)
35+
S3method(predict_quantile,model_fit)
3136
S3method(predict_raw,"_elnet")
3237
S3method(predict_raw,"_lognet")
3338
S3method(predict_raw,"_multnet")
39+
S3method(predict_raw,model_fit)
3440
S3method(print,boost_tree)
3541
S3method(print,control_parsnip)
3642
S3method(print,decision_tree)
@@ -92,7 +98,9 @@ export(boost_tree)
9298
export(check_empty_ellipse)
9399
export(check_final_param)
94100
export(control_parsnip)
101+
export(convert_stan_interval)
95102
export(decision_tree)
103+
export(eval_args)
96104
export(fit)
97105
export(fit.model_spec)
98106
export(fit_control)
@@ -122,6 +130,13 @@ export(null_value)
122130
export(nullmodel)
123131
export(pred_value_template)
124132
export(predict.model_fit)
133+
export(predict_class.model_fit)
134+
export(predict_classprob.model_fit)
135+
export(predict_confint.model_fit)
136+
export(predict_numeric)
137+
export(predict_numeric.model_fit)
138+
export(predict_quantile.model_fit)
139+
export(predict_raw.model_fit)
125140
export(rand_forest)
126141
export(rpart_train)
127142
export(set_args)
@@ -144,6 +159,7 @@ export(svm_poly)
144159
export(svm_rbf)
145160
export(tidy.model_fit)
146161
export(translate)
162+
export(translate.default)
147163
export(update_dot_check)
148164
export(update_main_parameters)
149165
export(varying)

R/aaa.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ maybe_multivariate <- function(results, object) {
1313
results
1414
}
1515

16+
#' Convenience function for intervals
1617
#' @importFrom stats quantile
18+
#' @export
19+
#' @keywords internal
20+
#' @param x A fitted model object
21+
#' @param level Level of uncertainty for intervals
22+
#' @param lower Is `level` the lower level?
1723
convert_stan_interval <- function(x, level = 0.95, lower = TRUE) {
1824
alpha <- (1 - level) / 2
1925
if (!lower) {

R/arguments.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ maybe_eval <- function(x) {
103103
y
104104
}
105105

106+
#' Evaluate parsnip model arguments
107+
#' @export
108+
#' @keywords internal
109+
#' @param spec A model specification
110+
#' @param ... Not used.
106111
eval_args <- function(spec, ...) {
107112
spec$args <- purrr::map(spec$args, maybe_eval)
108113
spec$eng_args <- purrr::map(spec$eng_args, maybe_eval)

R/predict_class.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Other predict methods.
2-
#
3-
# These are internal functions not meant to be directly called by the user.
4-
#
5-
# @keywords internal
6-
# @rdname other_predict
7-
# @inheritParams predict.model_fit
8-
# @method predict_class model_fit
9-
# @export predict_class.model_fit
10-
# @export
1+
#' Other predict methods.
2+
#'
3+
#' These are internal functions not meant to be directly called by the user.
4+
#'
5+
#' @keywords internal
6+
#' @rdname other_predict
7+
#' @inheritParams predict.model_fit
8+
#' @method predict_class model_fit
9+
#' @export predict_class.model_fit
10+
#' @export
1111
predict_class.model_fit <- function(object, new_data, ...) {
1212
if (object$spec$mode != "classification")
1313
rlang::abort("`predict.model_fit()` is for predicting factor outcomes.")

R/predict_classprob.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# @keywords internal
2-
# @rdname other_predict
3-
# @inheritParams predict.model_fit
4-
# @method predict_classprob model_fit
5-
# @export predict_classprob.model_fit
6-
# @export
1+
#' @keywords internal
2+
#' @rdname other_predict
3+
#' @inheritParams predict.model_fit
4+
#' @method predict_classprob model_fit
5+
#' @export predict_classprob.model_fit
6+
#' @export
77
#' @importFrom tibble as_tibble is_tibble tibble
88
predict_classprob.model_fit <- function(object, new_data, ...) {
99
if (object$spec$mode != "classification")

R/predict_interval.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# @keywords internal
2-
# @rdname other_predict
3-
# @param level A single numeric value between zero and one for the
4-
# interval estimates.
5-
# @param std_error A single logical for wether the standard error should be
6-
# returned (assuming that the model can compute it).
7-
# @inheritParams predict.model_fit
8-
# @method predict_confint model_fit
9-
# @export predict_confint.model_fit
10-
# @export
1+
#' @keywords internal
2+
#' @rdname other_predict
3+
#' @param level A single numeric value between zero and one for the
4+
#' interval estimates.
5+
#' @param std_error A single logical for wether the standard error should be
6+
#' returned (assuming that the model can compute it).
7+
#' @inheritParams predict.model_fit
8+
#' @method predict_confint model_fit
9+
#' @export predict_confint.model_fit
10+
#' @export
1111
predict_confint.model_fit <- function(object, new_data, level = 0.95, std_error = FALSE, ...) {
1212

1313
if (is.null(object$spec$method$pred$conf_int))

R/predict_numeric.R

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
# @keywords internal
2-
# @rdname other_predict
3-
# @inheritParams predict.model_fit
4-
# @method predict_numeric model_fit
5-
# @export predict_numeric.model_fit
6-
# @export
7-
1+
#' @keywords internal
2+
#' @rdname other_predict
3+
#' @inheritParams predict.model_fit
4+
#' @method predict_numeric model_fit
5+
#' @export predict_numeric.model_fit
6+
#' @export
87
predict_numeric.model_fit <- function(object, new_data, ...) {
98
if (object$spec$mode != "regression")
109
rlang::abort(glue::glue("`predict_numeric()` is for predicting numeric outcomes. ",
@@ -45,9 +44,9 @@ predict_numeric.model_fit <- function(object, new_data, ...) {
4544
}
4645

4746

48-
# @export
49-
# @keywords internal
50-
# @rdname other_predict
51-
# @inheritParams predict_numeric.model_fit
47+
#' @export
48+
#' @keywords internal
49+
#' @rdname other_predict
50+
#' @inheritParams predict_numeric.model_fit
5251
predict_numeric <- function(object, ...)
5352
UseMethod("predict_numeric")

R/predict_quantile.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# @keywords internal
2-
# @rdname other_predict
3-
# @param quant A vector of numbers between 0 and 1 for the quantile being
4-
# predicted.
5-
# @inheritParams predict.model_fit
6-
# @method predict_quantile model_fit
7-
# @export predict_quantile.model_fit
8-
# @export
1+
#' @keywords internal
2+
#' @rdname other_predict
3+
#' @param quant A vector of numbers between 0 and 1 for the quantile being
4+
#' predicted.
5+
#' @inheritParams predict.model_fit
6+
#' @method predict_quantile model_fit
7+
#' @export predict_quantile.model_fit
8+
#' @export
99
predict_quantile.model_fit <-
10-
function (object, new_data, quantile = (1:9)/10, ...) {
10+
function(object, new_data, quantile = (1:9)/10, ...) {
1111

1212
if (is.null(object$spec$method$pred$quantile))
1313
rlang::abort("No quantile prediction method defined for this engine.")

R/predict_raw.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# @rdname predict.model_fit
2-
# @inheritParams predict.model_fit
3-
# @method predict_raw model_fit
4-
# @export predict_raw.model_fit
5-
# @export
1+
#' @rdname predict.model_fit
2+
#' @method predict_raw model_fit
3+
#' @export predict_raw.model_fit
4+
#' @export
65
predict_raw.model_fit <- function(object, new_data, opts = list(), ...) {
76
protected_args <- names(object$spec$method$pred$raw$args)
87
dup_args <- names(opts) %in% protected_args

R/translate.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#' It translates generic parameters to their counterparts.
66
#'
77
#' @param x A model specification.
8+
#' @param engine The computational engine for the model (see `?set_engine`).
89
#' @param ... Not currently used.
910
#' @details
1011
#' `translate()` produces a _template_ call that lacks the specific
@@ -47,7 +48,9 @@ translate <- function(x, ...)
4748
#' @importFrom utils getFromNamespace
4849
#' @importFrom purrr list_modify
4950
#' @importFrom rlang lgl
51+
#' @rdname translate
5052
#' @export
53+
#' @export translate.default
5154
translate.default <- function(x, engine = x$engine, ...) {
5255
check_empty_ellipse(...)
5356
if (is.null(engine))

0 commit comments

Comments
 (0)