vetiver_create_description: Model constructor methods

View source: R/prepare.R

vetiver_create_description.trainR Documentation

Model constructor methods

Description

These are developer-facing functions, useful for supporting new model types. Each model supported by vetiver_model() uses up to four methods when the deployable object is created:

  • The vetiver_create_description() function generates a helpful description of the model based on its characteristics. This method is required.

  • The vetiver_create_meta() function creates the correct vetiver_meta() for the model. This is especially helpful for specifying which packages are needed for prediction. A model can use the default method here, which is to have no special metadata.

  • The vetiver_ptype() function finds an input data prototype from the training data (a zero-row slice) to use for checking at prediction time. This method is required.

  • The vetiver_prepare_model() function executes last. Use this function for tasks like checking if the model is trained and reducing the size of the model via butcher::butcher(). A model can use the default method here, which is to return the model without changes.

Usage

## S3 method for class 'train'
vetiver_create_description(model)

## S3 method for class 'train'
vetiver_prepare_model(model)

## S3 method for class 'gam'
vetiver_create_description(model)

## S3 method for class 'gam'
vetiver_prepare_model(model)

## S3 method for class 'glm'
vetiver_create_description(model)

## S3 method for class 'glm'
vetiver_prepare_model(model)

## S3 method for class 'keras.engine.training.Model'
vetiver_create_description(model)

## S3 method for class 'keras.engine.training.Model'
vetiver_prepare_model(model)

## S3 method for class 'kproto'
vetiver_create_description(model)

## S3 method for class 'kproto'
vetiver_prepare_model(model)

## S3 method for class 'lm'
vetiver_create_description(model)

## S3 method for class 'lm'
vetiver_prepare_model(model)

## S3 method for class 'luz_module_fitted'
vetiver_create_description(model)

## S3 method for class 'luz_module_fitted'
vetiver_prepare_model(model)

## S3 method for class 'Learner'
vetiver_create_description(model)

## S3 method for class 'Learner'
vetiver_prepare_model(model)

vetiver_create_description(model)

## Default S3 method:
vetiver_create_description(model)

vetiver_prepare_model(model)

## Default S3 method:
vetiver_prepare_model(model)

## S3 method for class 'ranger'
vetiver_create_description(model)

## S3 method for class 'ranger'
vetiver_prepare_model(model)

## S3 method for class 'recipe'
vetiver_create_description(model)

## S3 method for class 'recipe'
vetiver_prepare_model(model)

## S3 method for class 'model_stack'
vetiver_create_description(model)

## S3 method for class 'model_stack'
vetiver_prepare_model(model)

## S3 method for class 'workflow'
vetiver_create_description(model)

## S3 method for class 'workflow'
vetiver_prepare_model(model)

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

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

Arguments

model

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

Details

These are four generics that use the class of model for dispatch.

Examples


cars_lm <- lm(mpg ~ ., data = mtcars)
vetiver_create_description(cars_lm)
vetiver_prepare_model(cars_lm)


tidymodels/vetiver documentation built on Oct. 15, 2024, 4:16 p.m.