Closed jyk closed 7 years ago
This is quite some function!
I didn't really go through it, but you should try to wrap a learner with the filter wrapper and then add the RemoveConstantFeaturesWrapper. Your code looks like it is trying to do that in the wrong order. The 'outermost' wrapper does its job first.
Also, on first glance it looks like you are doing
lrn <- mlr::makeRemoveConstantFeaturesWrapper(learner = lrn, dont.rm = Y)
but then never using that lrn
again and instead create a wrapper around a new learner (created from cl
)
lrn <- mlr::makeFilterWrapper(learner = cl, fw.method = "InfGain")
So not only is it the wrong order, the makeRemoveConstantFeaturesWrapper
really seems to have no effect on the code at all.
Hope I could help!
Thanks! I will try. Just one more comment about wrappers. Let us say that I have 3 different wrappers for preprocessing. Firstly, I would like to add some derivates into my training and validation data by predicting (wrapper # 1), then I would like to remove constant features (wrapper # 2) and then do feature selection(wrapper #3). Then do I have to execute them in the next order: wrapper 3, then wrapper 2 and then wrapper 1 before training/hyperparameters tuning ?
Precisely spoken, you do not execute the wrapper, you just apply them to a learner, layer per layer. Inside is the learner. Before the final learner is called you want mlr to execute wrapper # 3 so you have to wrap wrapper # 3 around the learner. Then you wrap that with wrapper # 2 and so on. So yes you are right with the mentioned order.
Thanks!
By the way, i did not found this explanation in mlr online documentation (I mean the order of setting layers of wrappers). Sorry, if I am wrong...
I opened an issue there. I will close here. If something is unclear you can reopen.
Ok, many thanks!
Hi! I have next issue with mlr: I am using feature selection using filtering method. The problem is that feature selection will fail if there are at least one feature with constant value. I tried to add wrapper "makeRemoveConstantFeaturesWrapper" to learner, but the problem is that it will not be used each time JUST BEFORE feature selection (which has to be used several times - during finding optimal number / percent of features to be retained after feature selection + final feature selection before hyperparameter optimization and final training). Briefly my question is. What can be changed in next function in order to have removal of constant features just before each execution of feature selection ?
My function: