How can I use packages (e.g. glmnet) within mlr in R?

196 Views Asked by At

I want to reduce features and wanted to use an elastic net regression. Therefore, I wanted to use the glmnet-package and its built-in functions like cv.glment and plot the results etc. The problem is that my data depend on time, so I used a nested time series cross-validation and the mlr-package. The glmnet-package used a k-fold-cross-validation. Is there a way to get plots as in the glmnet-package? My idea was to use the source-code and change some parts, but I in the end it did not work. What else can I try? Thanks in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

It is somewhat unclear what you want or what your problem is. Maybe the following helps:

  • glmnet is available in {mlr3learners}
  • Spatio-temporal CV is available in {mlr3spatiotempcv}

Note that {mlr} is deprecated. Nevertheless, it contains two glmnet learners that you can use.

With respect to the internal CV of the {glmnet} algorithm: You can turn it off and optimize the shrinkrage paramaters yourself.

But again, it is very unclear what you want because you ask for plots in the end. Focus on one question at a time.