Class Predictor (1.46.0)

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)))

Methods

load

load(artifacts_uri: str) -> None

Loads the model artifact.

Parameter
Name Description
artifacts_uri str

Required. The value of the environment variable AIP_STORAGE_URI.

postprocess

postprocess(prediction_results: typing.Any) -> typing.Any

Postprocesses the prediction results.

Parameter
Name Description
prediction_results Any

Required. The prediction results.

predict

predict(instances: typing.Any) -> typing.Any

Performs prediction.

Parameter
Name Description
instances Any

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

preprocess

preprocess(prediction_input: typing.Any) -> typing.Any

Preprocesses the prediction input before doing the prediction.

Parameter
Name Description
prediction_input Any

Required. The prediction input that needs to be preprocessed.