vetiver_ptype.train | R Documentation |
Optionally find and return an input data prototype for a model.
## S3 method for class 'train'
vetiver_ptype(model, ...)
## S3 method for class 'gam'
vetiver_ptype(model, ...)
## S3 method for class 'glm'
vetiver_ptype(model, ...)
## S3 method for class 'keras.engine.training.Model'
vetiver_ptype(model, ...)
## S3 method for class 'kproto'
vetiver_ptype(model, ...)
## S3 method for class 'lm'
vetiver_ptype(model, ...)
## S3 method for class 'luz_module_fitted'
vetiver_ptype(model, ...)
## S3 method for class 'Learner'
vetiver_ptype(model, ...)
vetiver_ptype(model, ...)
## Default S3 method:
vetiver_ptype(model, ...)
vetiver_create_ptype(model, save_prototype, ...)
## S3 method for class 'ranger'
vetiver_ptype(model, ...)
## S3 method for class 'recipe'
vetiver_ptype(model, ...)
## S3 method for class 'model_stack'
vetiver_ptype(model, ...)
## S3 method for class 'workflow'
vetiver_ptype(model, ...)
## S3 method for class 'xgb.Booster'
vetiver_ptype(model, ...)
model |
A trained model, such as an |
... |
Other method-specific arguments passed to |
save_prototype |
Should an input data prototype be stored with the model?
The options are |
These are developer-facing functions, useful for supporting new model types.
A vetiver_model()
object optionally stores an input data prototype for
checking at prediction time.
The default for save_prototype
, TRUE
, finds an input data prototype (a
zero-row slice of the training data) via vetiver_ptype()
.
save_prototype = FALSE
opts out of storing any input data prototype.
You may pass your own data to save_prototype
, but be sure to check that it
has the same structure as your training data, perhaps with
hardhat::scream()
.
A vetiver_ptype
method returns a zero-row dataframe, and
vetiver_create_ptype()
returns either such a zero-row dataframe, NULL
,
or the dataframe passed to save_prototype
.
cars_lm <- lm(mpg ~ cyl + disp, data = mtcars)
vetiver_create_ptype(cars_lm, TRUE)
## calls the right method for `model` via:
vetiver_ptype(cars_lm)
## can also turn off prototype
vetiver_create_ptype(cars_lm, FALSE)
## some models require that you pass in training features
cars_rf <- ranger::ranger(mpg ~ ., data = mtcars)
vetiver_ptype(cars_rf, prototype_data = mtcars[,-1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.