Closed slecee closed 10 months ago
You call partition()
after setting the seed. This function already uses your seed to sample random splits. The importance values are equal when you move the partition()
call.
library(mlr3extralearners)
tasks = as_task_classif(iris, target = 'Species')
learners = lrn("classif.randomForest" ,predict_type = "prob",importance= c('gini'))
split = partition(tasks)
split
set.seed(123, kind = "Mersenne-Twister")
a = learners$train(tasks,row_ids = split$train)
a$model$importance
library(randomForest)
set.seed(123, kind = "Mersenne-Twister")
tmp <- randomForest(iris[split$train,1:4],
iris$Species[split$train],
importance = TRUE)
tmp[["importance"]]
the results also differ...
Description I think the two methods get the same importance, but the results are not the same...
Reproducible example