vetiver_create_ptype: Create a vetiver input data prototype

Description Usage Arguments Details Value Examples

View source: R/ptype.R

Description

Optionally find and return an input data prototype for a model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## S3 method for class 'train'
vetiver_ptype(model, ...)

## S3 method for class 'lm'
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_ptype, ...)

## S3 method for class 'workflow'
vetiver_ptype(model, ...)

## S3 method for class 'xgb.Booster'
vetiver_ptype(model, ...)

Arguments

model

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

...

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

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.

Details

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.

Value

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_ptype.

Examples

1
2
3
4
5
6
7
8
9
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 `ptype`
vetiver_create_ptype(cars_lm, FALSE)

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