Class Predictor (1.18.2)

Predictor()

Interface of the Predictor class for Custom Prediction Routines.

The Predictor is responsible for the ML logic for processing a prediction request. Specifically, the Predictor must define: (1) How to load all model artifacts used during prediction into memory. (2) The logic that should be executed at predict time.

When using the default PredictionHandler, the Predictor will be invoked as follows:

predictor.postprocess(predictor.predict(predictor.preprocess(prediction_input)))

Inheritance

builtins.object > abc.ABC > Predictor

Methods

load

load(artifacts_uri: str)

Loads the model artifact.

Parameter
NameDescription
artifacts_uri str

Required. The value of the environment variable AIP_STORAGE_URI.

postprocess

postprocess(prediction_results: Any)

Postprocesses the prediction results.

Parameter
NameDescription
prediction_results Any

Required. The prediction results.

predict

predict(instances: Any)

Performs prediction.

Parameter
NameDescription
instances Any

Required. The instance(s) used for performing prediction.

preprocess

preprocess(prediction_input: Any)

Preprocesses the prediction input before doing the prediction.

Parameter
NameDescription
prediction_input Any

Required. The prediction input that needs to be preprocessed.