Skip to content

Commit 9333a0d

Browse files
authored
Merge pull request #276 from tidymodels/even-more-exports
Even more exports
2 parents 8b73b3b + 488dce9 commit 9333a0d

37 files changed

+234
-82
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: parsnip
2-
Version: 0.0.5.9000
2+
Version: 0.0.5.9001
33
Title: A Common API to Modeling and Analysis Functions
44
Description: A common interface is provided to allow users to specify a model without having to remember the different argument names across different functions or computational engines (e.g. 'R', 'Spark', 'Stan', etc).
55
Authors@R: c(

NAMESPACE

Lines changed: 17 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,10 @@ export(boost_tree)
9298
export(check_empty_ellipse)
9399
export(check_final_param)
94100
export(control_parsnip)
101+
export(convert_args)
102+
export(convert_stan_interval)
95103
export(decision_tree)
104+
export(eval_args)
96105
export(fit)
97106
export(fit.model_spec)
98107
export(fit_control)
@@ -122,6 +131,13 @@ export(null_value)
122131
export(nullmodel)
123132
export(pred_value_template)
124133
export(predict.model_fit)
134+
export(predict_class.model_fit)
135+
export(predict_classprob.model_fit)
136+
export(predict_confint.model_fit)
137+
export(predict_numeric)
138+
export(predict_numeric.model_fit)
139+
export(predict_quantile.model_fit)
140+
export(predict_raw.model_fit)
125141
export(rand_forest)
126142
export(rpart_train)
127143
export(set_args)
@@ -144,6 +160,7 @@ export(svm_poly)
144160
export(svm_rbf)
145161
export(tidy.model_fit)
146162
export(translate)
163+
export(translate.default)
147164
export(update_dot_check)
148165
export(update_main_parameters)
149166
export(varying)

R/aaa.R

Lines changed: 10 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) {
@@ -24,6 +30,10 @@ convert_stan_interval <- function(x, level = 0.95, lower = TRUE) {
2430
res
2531
}
2632

33+
#' Make a table of arguments
34+
#' @param model_name A character string for the model
35+
#' @keywords internal
36+
#' @export
2737
convert_args <- function(model_name) {
2838
envir <- get_model_env()
2939

R/aaa_multi_predict.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,18 @@ multi_predict_args.default <- function(object, ...) {
117117
#' @export
118118
#' @rdname has_multi_predict
119119
multi_predict_args.model_fit <- function(object, ...) {
120-
existing_mthds <- methods("multi_predict")
121-
cls <- class(object)
122-
tst <- paste0("multi_predict.", cls)
123-
.fn <- tst[tst %in% existing_mthds]
124-
if (length(.fn) == 0) {
125-
return(NA_character_)
120+
model_type <- class(object$spec)[1]
121+
arg_info <- get_from_env(paste0(model_type, "_args"))
122+
arg_info <- arg_info[arg_info$engine == object$spec$engine,]
123+
arg_info <- arg_info[arg_info$has_submodel,]
124+
125+
if (nrow(arg_info) == 0) {
126+
res <- NA_character_
127+
} else {
128+
res <- arg_info[["parsnip"]]
126129
}
127130

128-
.fn <- getFromNamespace(.fn, ns = "parsnip")
129-
omit <- c('object', 'new_data', 'type', '...')
130-
args <- names(formals(.fn))
131-
args[!(args %in% omit)]
131+
res
132132
}
133133

134134
#' @export

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/linear_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
#' separately saved to disk. In a new session, the object can be
106106
#' reloaded and reattached to the `parsnip` object.
107107
#'
108-
#' @seealso [[fit()], [set_engine()]
108+
#' @seealso [fit()], [set_engine()]
109109
#' @examples
110110
#' linear_reg()
111111
#' # Parameters can be represented by a placeholder:

R/linear_reg_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ set_model_arg(
293293
parsnip = "penalty",
294294
original = "reg_param",
295295
func = list(pkg = "dials", fun = "penalty"),
296-
has_submodel = TRUE
296+
has_submodel = FALSE
297297
)
298298

299299
set_model_arg(

R/logistic_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
#' separately saved to disk. In a new session, the object can be
105105
#' reloaded and reattached to the `parsnip` object.
106106
#'
107-
#' @seealso [[fit()]
107+
#' @seealso [fit()]
108108
#' @examples
109109
#' logistic_reg()
110110
#' # Parameters can be represented by a placeholder:

R/mars.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
#' attached.
6363
#'
6464
#' @importFrom purrr map_lgl
65-
#' @seealso [[fit()]
65+
#' @seealso [fit()]
6666
#' @examples
6767
#' mars(mode = "regression", num_terms = 5)
6868
#' @export

R/mlp.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::mlp(mode = "regression"), "nnet")}
8585
#'
8686
#' @importFrom purrr map_lgl
87-
#' @seealso [[fit()]
87+
#' @seealso [fit()]
8888
#' @examples
8989
#' mlp(mode = "classification", penalty = 0.01)
9090
#' # Parameters can be represented by a placeholder:

0 commit comments

Comments
 (0)