For registered models, prediction function along with its requirements and resources can be logged to be used for further processes like evaluating and packaging.

Prediction Class

PureML expects the prediction function in a specific format:

from pureml import BasePredictor, Input, Output
import pureml

class Predictor(BasePredictor):
    label = "<model_name:model_branch:model_version>"
    input = Input(type="<Input data type>")
    output = Output(type="<Output data type>")

    def load_models(self):
        self.model = #Load the model to this variable

    def predict(self, data):
        predictions = # Code to obtain model predictions

        return predictions

This is a template for writing Predictor class. PureML expects this format for the class to use for evaluation, packaging of models etc.

Let’s look at the Structure of the Predictor class.

Predictor inherits the BasePredictor which contains variables and abstract methods that have to be overwritten by the user.

The class name should be Predictor.


label : Contains the label for the model version

input : Contains the input data type that is passed into predict function

output: Contains the data type of the output returned by the predict function


load_models: Contains the functionality to load the prediction model

predict: Contains the functionality to obtain the predictions on the data passed to the function.

Apart from the above-mentioned variables, and functions, user can add more functionality to the Predictor class

Logging Prediction

import pureml

                   paths={'predict': './'})

Logging Prediction function along with its requirements:

import pureml

                   paths={'predict': './', 'requirements': './requirements.txt', 'resources': './'})

Fetching the model

import pureml