
Predict Method for kerasnip Model Fits
Source:R/kerasnip_spec_methods.R
predict.kerasnip_model_fit.RdS3 method for predict() dispatched on kerasnip_model_fit objects.
Before delegating to the standard parsnip predict machinery, it checks
whether the underlying model type is registered in the current parsnip
session. If not (e.g. after loading a saved workflow in a new R session),
it transparently replays the full parsnip registration using metadata stored
on the spec object — requiring no manual step from the user.
Usage
# S3 method for class 'kerasnip_model_fit'
predict(object, new_data, ...)Details
The metadata needed for re-registration (kerasnip_layer_blocks,
kerasnip_functional) is embedded on the spec object by the spec
constructor function at call time. This means it is preserved across
saveRDS()/readRDS() and bundle()/unbundle() round-trips.
For full model weight portability (i.e. to be able to predict() on new
data in a new R session), use bundle::bundle() before saving. Plain
saveRDS() preserves the spec structure and will auto-register, but the
underlying Keras model weights are not portable without bundling.