0

I look for a way to present/publish a mlr3 model (an ensemble) online so that other researcher could apply the model with their data. I think shiny would be decent for that.

I found mlr3shiny, however, as I understand it correctly, this package offers a graphical interface for model developement and there is no fuction for model publication.

DynNom, for example, allows to generate dynamic nomograms and supports model objects created by the lm, glm and coxph functions: enter image description here

I am actually looking for a solution like DynNom, but for mlr3

Minimal reproducible example:

library(mlr3)

# create learning task
task_penguins <- TaskClassif$new(id = "penguins", backend = palmerpenguins::penguins, target = "species")

# load learner and set hyperparameter
learner <- lrn("classif.rpart", cp = .01)

# train the model
learner$train(task_penguins)
ava
  • 840
  • 5
  • 19
  • There is no way to do such a thing. mlr3shiny has a different scope and was created by an external person. The whole idea is not within the scope of mlr3 and you need to find your own way. But I am not sure if this is possible in the way you think of it, I have never seen such offerings for other ML frameworks in R/Python. – pat-s Aug 04 '21 at 10:24
  • Thank you for your comment. I understand that this is not possible within mlr3 / not within the scope of mlr3. However I think it could be possible (e.g. https://www.r-bloggers.com/2021/01/how-to-share-your-machine-learning-models-with-shiny/) or do you see any specific reason why it should not work with mlr3 models? – ava Aug 04 '21 at 10:46
  • 1
    you can definitely manually create a shiny app that uses a pretrained model to predict on new data. Here is one I made https://ragp.shinyapps.io/Rapp/ - see second tab. It does not use mlr3 but an xgboost model directly, but using mlr3 ensembles is certainly possible. You can see an older version of the source code here https://github.com/missuse/predict_hyp. The actual prediction is performed in line 116 of `server.R`. I have the model in a package, but one can load it from an `.rds` file and use it. – missuse Aug 04 '21 at 14:37
  • @missuse Thank you! Your example inspired me to give it a try. The `shiny` app works well with `mlr3` models and it was actually not as tricky as I expected it. I might add some code for my reprex here soon. – ava Aug 04 '21 at 23:47

0 Answers0