BaseHandler
BaseHandler(self, model, prototype_data)
Base handler class for creating VetiverModel of different type.
Parameters
Name | Type | Description | Default |
---|---|---|---|
model |
a trained model | required | |
prototype_data |
An object with information (data) whose layout is to be determined. | required |
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
Name | Type | Description | Default |
---|---|---|---|
prototype_data |
pd.DataFrame, np.ndarray, or None | Training data to create prototype | required |
Returns
Type | Description |
---|---|
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
Name | Type | Description | Default |
---|---|---|---|
input_data |
Data used to generate prediction | required | |
check_prototype |
If type should be checked against prototype or not |
required |
Returns
Type | Description |
---|---|
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.