Skip to content

Use vetiver_pin_write() to pin a trained model to a board of models, along with an input prototype for new data and other model metadata. Use vetiver_pin_read() to retrieve that pinned object.

Usage

vetiver_pin_write(board, vetiver_model, ...)

vetiver_pin_read(board, name, version = NULL)

Arguments

board

A pin board, created by board_folder(), board_rsconnect(), board_url() or another board_ function.

vetiver_model

A deployable vetiver_model() object

...

Additional arguments passed on to methods for a specific board.

name

Pin name.

version

Retrieve a specific version of a pin. Use pin_versions() to find out which versions are available and when they were created.

Value

vetiver_pin_read() returns a vetiver_model(); vetiver_pin_write()

returns the name of the new pin, invisibly.

Details

These functions read and write a vetiver_model() pin on the specified board containing the model object itself and other elements needed for prediction, such as the model's input data prototype or which packages are needed at prediction time. You may use pins::pin_read() or pins::pin_meta() to handle the pin, but vetiver_pin_read() returns a vetiver_model() object ready for deployment.

Examples

library(pins)
model_board <- board_temp()

cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(model_board, v)
#> Creating new version '20220929T181228Z-2bb55'
#> Writing to pin 'cars_linear'
model_board
#> Pin board <pins_board_folder>
#> Path: '/tmp/RtmpsuWAgn/pins-2d5e5fa37864'
#> Cache size: 0
#> Pins [1]: 'cars_linear'

vetiver_pin_read(model_board, "cars_linear")
#> 
#> ── cars_linear<butchered_lm> model for deployment 
#> An OLS linear regression model using 10 features

# can use `version` argument to read a specific version:
pin_versions(model_board, "cars_linear")
#> # A tibble: 1 × 3
#>   version                created             hash 
#>   <chr>                  <dttm>              <chr>
#> 1 20220929T181228Z-2bb55 2022-09-29 18:12:28 2bb55