Creating registered models from data transformations

As defined, in Concepts, the model class for a Verta Standard Model must extend VertaModelBase. So long as the model class implements that interface, the class logic itself may include only ML logic or it can also include data transformation logic.

This guide shows an example of how to define an RMV that consists only of a data transformation.

Suppose the function we seek to deploy is a simple cubic function as follows. (Note: this can be absolutely any function including one that queries a database or one with artifact dependencies like this guide.)

def cubic_transform(x):
    return 3*x*x*x + 2*x + 5

Next step is to wrap this function within a class that extends VertaModelBase.

from verta.registry import VertaModelBase
class CubicFunction(VertaModelBase):
    def __init__(self, artifacts=None):
        pass

    def predict(self, input_data):
        output_data = []
        for input_data_point in input_data:
            output_data_point = cubic_transform(input_data_point)
            output_data.append(output_data_point)
        return output_data

That's it. Register this RMV for deployment and further use.

from verta.environment import Python

model_version = registered_model.create_standard_model(
    CubicFunction,
    environment=Python(requirements=[]),
    name="v1",
)

Find the full code for this Guide here.

Last updated