vetiver_model: Create a vetiver object for deployment of a trained model

Description Usage Arguments Details Value Examples

View source: R/vetiver-model.R

Description

A vetiver_model() object collects the information needed to store, version, and deploy a trained model. Once your vetiver_model() object has been created, you can:

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
vetiver_model(
  model,
  model_name,
  ...,
  description = NULL,
  metadata = list(),
  save_ptype = TRUE,
  versioned = NULL
)

new_vetiver_model(model, model_name, description, metadata, ptype, versioned)

Arguments

model

A trained model, such as an lm() model or a tidymodels workflows::workflow().

model_name

Model name or ID.

...

Other method-specific arguments passed to vetiver_ptype() to compute an input data prototype.

description

A detailed description of the model. If omitted, a brief description of the model will be generated.

metadata

A list containing additional metadata to store with the pin. When retrieving the pin, this will be stored in the user key, to avoid potential clashes with the metadata that pins itself uses.

save_ptype

Should an input data prototype be stored with the model? The options are TRUE (the default, which stores a zero-row slice of the training data), FALSE (no input data prototype for checking), or a dataframe to be used for both checking at prediction time and examples in API visual documentation.

versioned

Should the model object be versioned when stored with vetiver_pin_write()? The default, NULL, will use the default for the board where you store the model.

ptype

An input data prototype. If NULL, there is no checking of new data at prediction time.

Details

You can provide your own data to save_ptype to use as examples in the visual documentation created by vetiver_pr_predict(). If you do this, consider checking that your input data prototype has the same structure as your training data (perhaps with hardhat::scream()) and/or simulating data to avoid leaking PII via your deployed model.

Value

A new vetiver_model object.

Examples

1
2
cars_lm <- lm(mpg ~ ., data = mtcars)
vetiver_model(cars_lm, "cars_linear", pins::board_temp())

tidymodels/vetiver documentation built on Jan. 14, 2022, 7:32 p.m.