giuseppec / giuseppec/iml

FeatureImp fails when using mlr PreprocWrapper using parallel processing

Open
#99 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
R
Stars
503
Forks
87
PR merge metrics
No merged PRs in 30d

Description

Hi,
First of all, iml is an awesome package and I want to say thank you for you effort on it.
I'm getting a weird problem when using a mlr model with preprocessing only when using parallel processing: no applicable method for 'predict' applied to an object of class "preProcess"
Reproducible example below:
```
library(mlr)
library(ranger)
library(iml)
data("iris")
tsk = mlr::makeClassifTask(data = iris, target = "Species")
lrn = mlr::makeLearner("classif.ranger", predict.type = "prob")
preproc_lrn = mlr::makePreprocWrapperCaret(lrn)
mod = mlr:::train(preproc_lrn, tsk)

X = iris[which(names(iris) != "Species")]
predictor = Predictor$new(mod, data = X, y = iris$Species)

library("doParallel")
cl = makePSOCKcluster(2)
registerDoParallel(cl)
imp = FeatureImp$new(predictor, loss = "ce", parallel = TRUE)
stopCluster(cl)
```

If I don't use a parallel backend it works perfectly:

`imp = FeatureImp$new(predictor, loss = "ce")`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.