Skip to content

Commit cc39a45

Browse files
committed
remaining multi_predict changes
1 parent c6ec573 commit cc39a45

File tree

8 files changed

+23
-5
lines changed

8 files changed

+23
-5
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* `add_rowindex()` can create a column called `.row` to a data frame.
1212

1313
* If a computational engine is not explicitly set, a default will be used. Each default is documented on the corresponding model page. A warning is issued at fit time unless verbosity is zero.
14+
* `nearest_neighbor` gained a `multi_predict` method. The `multi_predict()` documentation is a little better organized.
1415

1516

1617
# parsnip 0.0.2

R/aaa.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ convert_stan_interval <- function(x, level = 0.95, lower = TRUE) {
2323
#' @importFrom utils globalVariables
2424
utils::globalVariables(
2525
c('.', '.label', '.pred', '.row', 'data', 'engine', 'engine2', 'group',
26-
'lab', 'original', 'predicted_label', 'prediction', 'value', 'type')
26+
'lab', 'original', 'predicted_label', 'prediction', 'value', 'type',
27+
"neighbors")
2728
)

R/aaa_multi_predict.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#'
55
#' For some models, predictions can be made on sub-models in the model object.
66
#' @param object A `model_fit` object.
7+
#' @param new_data A rectangular data object, such as a data frame.
8+
#' @param type A single character value or `NULL`. Possible values
9+
#' are "numeric", "class", "prob", "conf_int", "pred_int", "quantile",
10+
#' or "raw". When `NULL`, `predict()` will choose an appropriate value
11+
#' based on the model's mode.
712
#' @param ... Optional arguments to pass to `predict.model_fit(type = "raw")`
813
#' such as `type`.
914
#' @return A tibble with the same number of rows as the data being predicted.

R/linear_reg.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ predict_raw._elnet <- function(object, new_data, opts = list(), ...) {
302302
#' @importFrom dplyr full_join as_tibble arrange
303303
#' @importFrom tidyr gather
304304
#' @export
305+
#'@rdname multi_predict
306+
#' @param penalty An numeric vector of penalty values.
305307
multi_predict._elnet <-
306308
function(object, new_data, type = NULL, penalty = NULL, ...) {
307309
if (any(names(enquos(...)) == "newdata"))

R/logistic_reg.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ predict._lognet <- function (object, new_data, type = NULL, opts = list(), penal
276276
#' @importFrom dplyr full_join as_tibble arrange
277277
#' @importFrom tidyr gather
278278
#' @export
279+
#' @rdname multi_predict
279280
multi_predict._lognet <-
280281
function(object, new_data, type = NULL, penalty = NULL, ...) {
281282
if (any(names(enquos(...)) == "newdata"))

R/multinom_reg.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ predict._multnet <-
232232
#' @importFrom dplyr full_join as_tibble arrange
233233
#' @importFrom tidyr gather
234234
#' @export
235+
#' @rdname multi_predict
235236
multi_predict._multnet <-
236237
function(object, new_data, type = NULL, penalty = NULL, ...) {
237238
if (any(names(enquos(...)) == "newdata"))

R/nearest_neighbor.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ multi_predict._train.kknn <-
193193
stop("Did you mean to use `new_data` instead of `newdata`?", call. = FALSE)
194194

195195
if (is.null(neighbors))
196-
neighbors <- rlang::eval_tidy(tt$fit$call$ks)
196+
neighbors <- rlang::eval_tidy(object$fit$call$ks)
197197
neighbors <- sort(neighbors)
198198

199199
if (is.null(type)) {

man/multi_predict.Rd

Lines changed: 10 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)