Class Predictor (1.36.1)

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
NameDescription
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
NameDescription
prediction_results Any

Required. The prediction results.

predict

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

Performs prediction.

Parameter
NameDescription
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
NameDescription
prediction_input Any

Required. The prediction input that needs to be preprocessed.