DoubleML / doubleml-for-r

DoubleML - Double Machine Learning in R
https://docs.doubleml.org
Other
123 stars 25 forks source link

Support for ensemble multiple learners for ml_g and ml_m #140

Closed ellenxtan closed 2 years ago

ellenxtan commented 2 years ago

Thanks for developing this great package.

I was wondering if you support estimating E[Y|X] or E[D|X] with super learners, i.e. we can use multiple learners to cross-fit E[Y|X] and E[D|X] as below? The weights of each learner are estimated based on their cross-fitting performance. Or I was wondering how could the double ML framework work together with the SuperLearner package?

learner = lrns(c("regr.glm","regr.gam","regr.bart"), k=2)
ml_g = learner$clone()

Many thanks!!!

MalteKurz commented 2 years ago

The implementation of such an ensemble learner should be possible with the package mlr3piplines. According to the documentation it is not the same as SuperLearner but similar (https://mlr3pipelines.mlr-org.com/reference/mlr_learners_avg.html). See also https://mlr3book.mlr-org.com/pipelines.html.

I didn't yet check whether it works out of the box, but the API of mlr3piplines should be compatible with ours. If you get things working and in case you have a nice example demonstrating it, a contribution to our example gallery (https://docs.doubleml.org/stable/examples/index.html) would be welcome.

PhilippBach commented 2 years ago

Hi @ellenxtan ,

thanks again for your interest. As @MalteKurz said, it's basically possible to construct ensembles with mlr3pipelines and pass the final learners to DoubleML . We had to make some minor changes in our code, see #141. Hence, you may have to reinstall the development version again via remotes::install_github("DoubleML/doubleml-for-r"). We'll update the stable version in the next CRAN release.

We created a short notebook illustrating what's possible with mlr3pipelines: https://docs.doubleml.org/dev/examples/R_double_ml_pipeline.html . There will be also a short section in the user guide in the future.

For a more detailed introduction to mlr3pipelines you may want to read the corresponding section in the mlr3book: https://mlr3book.mlr-org.com/pipelines.html

I hope this helps. I close this issue now.

All the best,

Philipp