Skip to content

predict

predict(
    ml_model_id: EntityId,
    record: Record,
    predict_endpoint: VipURL,
    *,
    config_overrides: Optional[MachineLearningClientConfig] = None,
) -> PredictOutput

Generates a prediction for the observation using the specified ML Model.

Note: Not all response parameters will be populated. Whether a response parameter is populated depends on the type of model requested.

Parameters:

  • ml_model_id (EntityId) –

    A unique identifier of the MLModel.

Raises:

Source code in docs_src/capo_machine_learning/_services/machine_learning.py
def predict(
    self,
    ml_model_id: "capo_machine_learning.types.entity_id.EntityId",
    record: "capo_machine_learning.types.record.Record",
    predict_endpoint: "capo_machine_learning.types.vip_url.VipURL",
    *,
    config_overrides: Optional[MachineLearningClientConfig] = None,
) -> "capo_machine_learning.types.predict_output.PredictOutput":
    """<p>Generates a prediction for the observation using the specified <code>ML Model</code>.</p> <p> <b>Note:</b> Not all response parameters will be populated. Whether a response parameter is populated depends on the type of model requested.</p>

    Args:
        ml_model_id: <p>A unique identifier of the <code>MLModel</code>.</p>

    Raises:
        capo_machine_learning.errors.internal_server_exception.InternalServerException: <p>An error on the server occurred when trying to process a request.</p>
        capo_machine_learning.errors.invalid_input_exception.InvalidInputException: <p>An error on the client occurred. Typically, the cause is an invalid input value.</p>
        capo_machine_learning.errors.limit_exceeded_exception.LimitExceededException: <p>The subscriber exceeded the maximum number of operations. This exception can occur when listing objects such as <code>DataSource</code>.</p>
        capo_machine_learning.errors.predictor_not_mounted_exception.PredictorNotMountedException: <p>The exception is thrown when a predict request is made to an unmounted <code>MLModel</code>.</p>
        capo_machine_learning.errors.resource_not_found_exception.ResourceNotFoundException: <p>A specified resource cannot be located.</p>
        capo_machine_learning.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_machine_learning.types.predict_input.PredictInput]",
    ) -> OperationResponse[
        "capo_machine_learning.types.predict_output.PredictOutput"
    ]:
        import capo_machine_learning._operations.amazon_ml_20141212.predict

        output, http_response = (
            capo_machine_learning._operations.amazon_ml_20141212.predict.predict(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("Predict")
    )
    input_: capo_machine_learning.types.predict_input.PredictInput = {
        "ml_model_id": ml_model_id,
        "record": record,
        "predict_endpoint": predict_endpoint,
    }

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output