From 6876bb3471a0173a07a245bb1d4e90c18ca00188 Mon Sep 17 00:00:00 2001 From: Max Kuhn Date: Thu, 13 Apr 2017 17:19:05 -0400 Subject: [PATCH] Error check related to issue #419 was added --- pkg/caret/R/trainControl.R | 8 +++++++- pkg/caret/man/trainControl.Rd | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/caret/R/trainControl.R b/pkg/caret/R/trainControl.R index f5b1cd8b2..6cf96d5bd 100644 --- a/pkg/caret/R/trainControl.R +++ b/pkg/caret/R/trainControl.R @@ -80,7 +80,8 @@ #' classification models (along with predicted values) in each resample? #' @param summaryFunction a function to compute performance metrics across #' resamples. The arguments to the function should be the same as those in -#' \code{\link{defaultSummary}}. +#' \code{\link{defaultSummary}}. Note that it \code{method = "oob"} is used, +#' this option is ignored and a warning is issued. #' @param selectionFunction the function used to select the optimal tuning #' parameter. This can be a name of the function or the function itself. See #' \code{\link{best}} for details and other options. @@ -236,6 +237,11 @@ trainControl <- function(method = "boot", } if(!(search %in% c("grid", "random"))) stop("`search` should be either 'grid' or 'random'") + if(method == "oob" & any(names(match.call()) == "summaryFunction")) { + warning("Custom summary measures cannot be computed for out-of-baf resampling. ", + "This value of `summaryFunction` will be ignored.", + call. = FALSE) + } list(method = method, number = number, diff --git a/pkg/caret/man/trainControl.Rd b/pkg/caret/man/trainControl.Rd index 28006ee2b..6db5c8cc6 100644 --- a/pkg/caret/man/trainControl.Rd +++ b/pkg/caret/man/trainControl.Rd @@ -59,7 +59,8 @@ classification models (along with predicted values) in each resample?} \item{summaryFunction}{a function to compute performance metrics across resamples. The arguments to the function should be the same as those in -\code{\link{defaultSummary}}.} +\code{\link{defaultSummary}}. Note that it \code{method = "oob"} is used, +this option is ignored and a warning is issued.} \item{selectionFunction}{the function used to select the optimal tuning parameter. This can be a name of the function or the function itself. See