Skip to content

Commit 32b4aff

Browse files
committed
code for future checking of mode and outcome class
1 parent e8ee117 commit 32b4aff

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

R/misc.R

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,22 @@ new_model_spec <- function(cls, args, eng_args, mode, method, engine) {
216216
class(out) <- make_classes(cls)
217217
out
218218
}
219+
220+
# ------------------------------------------------------------------------------
221+
222+
check_outcome <- function(y, spec) {
223+
if (spec$mode == "unknown") {
224+
return(invisible(NULL))
225+
} else if (spec$mode == "regression") {
226+
if (!is.numeric(y))
227+
stop("The model outcome should be numeric for regression models.",
228+
call. = FALSE)
229+
} else if (spec$mode == "classification") {
230+
if (!is.factor(y)) {
231+
stop("The model outcome should be a factor for regression models.",
232+
call. = FALSE)
233+
}
234+
}
235+
invisible(NULL)
236+
}
237+

0 commit comments

Comments
 (0)