Skip to contents

Whether the Y is a "classification", "regression" or ill-defined problem. Returns a character: "classification", "regression", or an error for strange classes. Minor redundancy with is_discrete, though explicit. Could be useful for DALEX::explain(type) as it also expects "classification" or "regression".

Usage

problem_type(y)

Arguments

y

Response variable to be modeled

Value

Character either c("classification", "regression") specifying the assumed model task based on the discreteness of y.

Examples

library(cheem)

problem_type(mtcars$mpg) ## Numeric, many values
#> [1] "regression"
problem_type(mtcars$cyl) ## Numeric column, labeled as discrete, because less than 25 unique values
#> [1] "classification"
problem_type(letters) ## Character to classification
#> [1] "classification"
problem_type(factor(letters)) ## Factor to classification
#> [1] "classification"