I am using R 3.6.1, RStudio 1.2.5019 and mlr 2.15.0. Mlr ist installed and loaded. Only mlr and the packages mlr is built on are loaded.
Now, I have trained a model using train and would like to test it on new data.
Therefore, I want to use the predict.WrappedModel function from mlr.
If I call
?predict.WrappedModel I get all the information in the help window.
However, if I want to run predict.WrappedModel R throws an error indicating that the function cannot be found:
my_test = predict.WrappedModel(object = my_model, task = my_task)
konnte Funktion "predict.WrappedModel" nicht finden
Even when specifying mlr as the package to look in for the function:
my_test = mlr::predict.WrappedModel(object = my_model, task = my_task)
Fehler: 'predict.WrappedModel' ist kein von 'namespace:mlr' exportiertes Objekt
I also tried using ?predict , but here I also got an error:
my_test = mlr::predict(object = my_model, task = my_task)
Fehler: 'predict' ist kein von 'namespace:mlr' exportiertes Objekt
I've already spent a lot of time trying to fix this issue and read all the related questions I had found here and on the mlr forum on github, but could not find a solution.
What am I missing here?
Thanks a lot in advance :)
You neither need predict.WrappedModel nor mlr::predict. Both are internal functions using the generic S3 approach in R to operate based on the class of the supplied R object.
So in this case, as long as you pass a object derived from a mlr::train() call everything will just work.
Speaking with code:
library("mlr")
my_model = train(learner, task)
predict(my_model, task)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With