Using lmr3verse
package here. Let's say I applied the following pre-processing to the training set used to train Learner
:
preprocess <- po("scale", param_vals = list(center = TRUE, scale = TRUE)) %>>%
po("encode",param_vals = list(method = "one-hot"))
And I would like to predict the label of new observations contained in a dataframe (with the original variables) pred
with the command predict(Learner, newdata = pred, predict_type="prob")
. This won't work since Learner
was trained with centered, scaled, and one-hot encoding variables.
How to apply the same pre-processing used on the training set to new data (only features, not response) in order to make predictions?
I am not 100% sure but it seems you can feed newdata to a new task and feed it to
predict
. This page shows an example of combiningmlr_pipeops
andlearner
objects.