[R] Warning “Unknown or uninitialised column: `ntree`.” when trying to pass hyperparameters to a learner with package mlr
Agnes g2g
@gne@g2g @end|ng |rom hotm@||@com
Tue May 4 22:23:41 CEST 2021
Dear all,
I posted this question on stats exchange and got the message that it was off-topic.https://stats.stackexchange.com/questions/522745/warning-unknown-or-uninitialised-column-ntree-when-trying-to-pass-hyperpar
They suggested to use this email list instead.
So that's why I am posting it here. I have read the instructions, but if I have overlooked something that said this question does not belong on this mailing list, I apologise.
Thanks in advance for reading this message!
Kind regards,
Agnes Wattel
problem
I want to do a grid search with different hyperparameters that are provided by a self-made grid. But when I am running the code I get a warning: "Unknown or uninitialised column: ntree."
create grid
gs <- list(ntree = c(50,100,150,200,300,500,550),mtry = c(1,2,3,4,5)) %>% cross_df()
select hyperparameters
for (h in 1:nrow(gs)) {
ntree_entry <- gs$ntree[h]
mtry_entry <- gs$mtry[h]
(...)
lrn <- makeMultilabelClassifierChainsWrapper(lrn, order = NULL)
lrn <- setPredictType(lrn,"prob")
task <- makeMultilabelTask(data = data[train_lines,], target = label_bact)
mod <- mlr::train(lrn,task)
}
On the place of (...) I have tried two different ways to get the hyperparameters into the learner:
option 1: pass hyperparameters to the learner
lrn <- makeLearner("classif.randomForest",ntree = ntree_entry,mtry = mtry_entry)
option 2: pass hyperparameters to the learner
lrn <- makeLearner("classif.randomForest")
lrn <- setHyperPars(lrn,par.vals = list(ntree = ntree_entry,mtry = mtry_entry))
check
The console tells me that the hyperparameters are in the learner:
>lrn
Learner classif.randomForest from package randomForest
Type: classif
Name: Random Forest; Short name: rf
Class: classif.randomForest
Properties: twoclass,multiclass,numerics,factors,ordered,prob,class.weights,oobpreds,featimp
Predict-Type: response
Hyperparameters: ntree=50,mtry=1
ntree and mtry are hyperparameters that are known to the makeLearner, because they are both in getParamSet:
> getParamSet("classif.randomForest")
Type len Def Constr Req Tunable Trafo
ntree integer - 500 1 to Inf - TRUE -
mtry integer - - 1 to Inf - TRUE -
replace logical - TRUE - - TRUE -
classwt numericvector <NA> - 0 to Inf - TRUE -
cutoff numericvector <NA> - 0 to 1 - TRUE -
strata untyped - - - - FALSE -
sampsize integervector <NA> - 1 to Inf - TRUE -
nodesize integer - 1 1 to Inf - TRUE -
maxnodes integer - - 1 to Inf - TRUE -
importance logical - FALSE - - TRUE -
localImp logical - FALSE - - TRUE -
proximity logical - FALSE - - FALSE -
oob.prox logical - - - Y FALSE -
norm.votes logical - TRUE - - FALSE -
do.trace logical - FALSE - - FALSE -
keep.forest logical - TRUE - - FALSE -
keep.inbag logical - FALSE - - FALSE -
Question
Why do I get the message "Unknown or uninitialised column: ntree"? Although it is only a warning, not an error, I am afraid that it will only use the first line of the grid that I created. The sizes of the models seem to confirm that. They all have the same size. I hope that someone can help me with this problem. Thanks in advance!
[[alternative HTML version deleted]]
More information about the R-help
mailing list