giuseppec / iml

iml: interpretable machine learning R package
https://giuseppec.github.io/iml/
Other
489 stars 88 forks source link

Uninformative/messy predict output for mlr3 LearnerRegr #213

Closed dandls closed 2 months ago

dandls commented 2 months ago

Problem: Unfortunately, the column name of the output of the default predict-function for mlr3 LearnerRegr is rather messy.

Example:

> library("mlr3")
> library("rpart")
> library("iml")
> 
> task = tsk("mtcars")
> task$target_names
[1] "mpg"
> 
> mod = lrn("regr.rpart")$train(task)
> 
> pred = Predictor$new(mod, data = task$data(), y = "mpg")
> head(pred$predict(task$data()))
  predict.model..newdata...newdata.
1                          18.26429
2                          18.26429
3                          26.66364
4                          18.26429
5                          18.26429
6                          18.26429

Solution: This line of code should be replaced, e.g., by data.frame(pred = predict(model, newdata = newdata)).

mb706 commented 2 months ago

maybe call it 'response' to be consistent with mlr3?