BaseHandler

BaseHandler(self, model, prototype_data)

Base handler class for creating VetiverModel of different types of model.

Handlers are used in Vetiver to as a unified interface for different types of models. They are used to generate predictions and create metadata about a trained model.

Parameters

model :

a trained model

prototype_data :

An object with information (data) whose layout is to be determined.

Methods

Name Description
construct_prototype Create data prototype for a model
create_meta Create metadata for a model
describe Create description for model
handler_predict Generates method for /predict endpoint in VetiverAPI
handler_startup Include required packages for prediction

construct_prototype

BaseHandler.construct_prototype()

Create data prototype for a model

Parameters

prototype_data : pd.DataFrame, np.ndarray, or None

Training data to create prototype

Returns

prototype : pd.DataFrame or None

Zero-row DataFrame for storing data types

create_meta

BaseHandler.create_meta(metadata)

Create metadata for a model

describe

BaseHandler.describe()

Create description for model

handler_predict

BaseHandler.handler_predict(input_data, check_prototype)

Generates method for /predict endpoint in VetiverAPI

The handler_predict function executes at each API call. Use this function for calling predict() and any other tasks that must be executed at each API call.

Parameters

input_data :

Data used to generate prediction

check_prototype :

If type should be checked against prototype or not

Returns

: prediction

Prediction from model

handler_startup

BaseHandler.handler_startup()

Include required packages for prediction

The handler_startup function executes when the API starts. Use this function for tasks like loading packages.