Thanks to visit codestin.com
Credit goes to github.com

Skip to content

"Error: Missing data in columns" due to fix.factors.prediction=TRUE #2611

@feinmann

Description

@feinmann
library(mlr)

train_data <- data.frame(
  A = runif(100), B = factor(sample(c("A", "B"), 100, replace = T)))

test_data <- data.frame(
  A = runif(100), B = factor(sample(c("A", "B", "C"), 100, replace = T)))

lrn <- makeLearner("regr.ranger", fix.factors.prediction = TRUE)

train_task <- makeRegrTask(
  data = train_data,
  target = "A"
)

model <- train(lrn, train_task)

predictions <- predict(model, newdata = test_data)

Gives Error: Missing data in columns: B., although there is no missing data. Same for classification.

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions