Skip to content

Classification tasks are sometimes not recognized #216

Description

@dandls

Sometimes, iml:::inferTaskFromPrediction() function identifies tasks falsely as a regression task and then `pred$task = "regression" is falsely set.

Here is an example:

library(iml)
library(tidymodels)

data(german, package = "rchallenge")
credit = german[, c("duration", "amount", "purpose", "age",
  "employment_duration", "housing", "number_credits", "credit_risk")]

# tidymodels
rf = rand_forest(mode = "classification", engine = "randomForest") %>%
  fit(credit_risk ~ ., data = credit)

pred = Predictor$new(model = rf, data = credit, y = "credit_risk")
pred$task
#> [1] "unknown"
pred$task = NULL
pred$predict(credit[c(1, 2),])
pred$task
#> [1] "regression"

iml:::inferTaskFromPrediction(prediction = pred$predict(credit[c(1, 2),]))
#> [1] "regression"

(This issue was originally raised for the counterfactuals package, see dandls/counterfactuals#29)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions