Skip to content

get_event_prediction

get_event_prediction(
    detector_id: string,
    event_id: string,
    event_type_name: string,
    entities: listOfEntities,
    event_timestamp: utcTimestampISO8601,
    event_variables: EventVariableMap,
    *,
    config_overrides: Optional[FraudDetectorClientConfig] = None,
    detector_version_id: Optional[wholeNumberVersionString] = None,
    external_model_endpoint_data_blobs: Optional[
        ExternalModelEndpointDataBlobMap
    ] = None,
) -> GetEventPredictionResult

Evaluates an event against a detector version. If a version ID is not provided, the detector’s (ACTIVE) version is used.

Parameters:

  • detector_id (string) –

    The detector ID.

  • detector_version_id (Optional[wholeNumberVersionString], default: None ) –

    The detector version ID.

  • event_id (string) –

    The unique ID used to identify the event.

  • event_type_name (string) –

    The event type associated with the detector specified for the prediction.

  • entities (listOfEntities) –

    The entity type (associated with the detector's event type) and specific entity ID representing who performed the event. If an entity id is not available, use "UNKNOWN."

  • event_timestamp (utcTimestampISO8601) –

    Timestamp that defines when the event under evaluation occurred. The timestamp must be specified using ISO 8601 standard in UTC.

  • event_variables (EventVariableMap) –

    Names of the event type's variables you defined in Amazon Fraud Detector to represent data elements and their corresponding values for the event you are sending for evaluation.

    You must provide at least one eventVariable

    To ensure most accurate fraud prediction and to simplify your data preparation, Amazon Fraud Detector will replace all missing variables or values as follows:

    For Amazon Fraud Detector trained models:

    If a null value is provided explicitly for a variable or if a variable is missing, model will replace the null value or the missing variable (no variable name in the eventVariables map) with calculated default mean/medians for numeric variables and with special values for categorical variables.

    For imported SageMaker models:

    If a null value is provided explicitly for a variable, the model and rules will use “null” as the value. If a variable is not provided (no variable name in the eventVariables map), model and rules will use the default value that is provided for the variable.

  • external_model_endpoint_data_blobs (Optional[ExternalModelEndpointDataBlobMap], default: None ) –

    The Amazon SageMaker model endpoint input data blobs.

Raises:

  • AccessDeniedException –

    An exception indicating Amazon Fraud Detector does not have the needed permissions. This can occur if you submit a request, such as PutExternalModel, that specifies a role that is not in your account.

  • ConflictException –

    An exception indicating there was a conflict during a delete operation.

  • InternalServerException –

    An exception indicating an internal server error.

  • ResourceNotFoundException –

    An exception indicating the specified resource was not found.

  • ResourceUnavailableException –

    An exception indicating that the attached customer-owned (external) model threw an exception when Amazon Fraud Detector invoked the model.

  • ThrottlingException –

    An exception indicating a throttling error.

  • ValidationException –

    An exception indicating a specified value is not allowed.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_frauddetector/_services/fraud_detector.py
def get_event_prediction(
    self,
    detector_id: "capo_frauddetector.types.string.string",
    event_id: "capo_frauddetector.types.string.string",
    event_type_name: "capo_frauddetector.types.string.string",
    entities: "capo_frauddetector.types.list_of_entities.listOfEntities",
    event_timestamp: "capo_frauddetector.types.utc_timestamp_iso8601.utcTimestampISO8601",
    event_variables: "capo_frauddetector.types.event_variable_map.EventVariableMap",
    *,
    config_overrides: Optional[FraudDetectorClientConfig] = None,
    detector_version_id: Optional[
        "capo_frauddetector.types.whole_number_version_string.wholeNumberVersionString"
    ] = None,
    external_model_endpoint_data_blobs: Optional[
        "capo_frauddetector.types.external_model_endpoint_data_blob_map.ExternalModelEndpointDataBlobMap"
    ] = None,
) -> (
    "capo_frauddetector.types.get_event_prediction_result.GetEventPredictionResult"
):
    """<p>Evaluates an event against a detector version. If a version ID is not provided, the detector’s (<code>ACTIVE</code>) version is used.</p>

    Args:
        detector_id: <p>The detector ID.</p>
        detector_version_id: <p>The detector version ID.</p>
        event_id: <p>The unique ID used to identify the event.</p>
        event_type_name: <p>The event type associated with the detector specified for the prediction.</p>
        entities: <p>The entity type (associated with the detector's event type) and specific entity ID representing who performed the event. If an entity id is not available, use "UNKNOWN."</p>
        event_timestamp: <p>Timestamp that defines when the event under evaluation occurred. The timestamp must be specified using ISO 8601 standard in UTC.</p>
        event_variables: <p>Names of the event type's variables you defined in Amazon Fraud Detector to represent data elements and their corresponding values for the event you are sending for evaluation.</p> <important> <p>You must provide at least one eventVariable</p> </important> <p>To ensure most accurate fraud prediction and to simplify your data preparation, Amazon Fraud Detector will replace all missing variables or values as follows:</p> <p> <b>For Amazon Fraud Detector trained models:</b> </p> <p>If a null value is provided explicitly for a variable or if a variable is missing, model will replace the null value or the missing variable (no variable name in the eventVariables map) with calculated default mean/medians for numeric variables and with special values for categorical variables.</p> <p> <b>For imported SageMaker models:</b> </p> <p>If a null value is provided explicitly for a variable, the model and rules will use “null” as the value. If a variable is not provided (no variable name in the eventVariables map), model and rules will use the default value that is provided for the variable. </p>
        external_model_endpoint_data_blobs: <p>The Amazon SageMaker model endpoint input data blobs.</p>

    Raises:
        capo_frauddetector.errors.access_denied_exception.AccessDeniedException: <p>An exception indicating Amazon Fraud Detector does not have the needed permissions. This can occur if you submit a request, such as <code>PutExternalModel</code>, that specifies a role that is not in your account.</p>
        capo_frauddetector.errors.conflict_exception.ConflictException: <p>An exception indicating there was a conflict during a delete operation.</p>
        capo_frauddetector.errors.internal_server_exception.InternalServerException: <p>An exception indicating an internal server error.</p>
        capo_frauddetector.errors.resource_not_found_exception.ResourceNotFoundException: <p>An exception indicating the specified resource was not found.</p>
        capo_frauddetector.errors.resource_unavailable_exception.ResourceUnavailableException: <p>An exception indicating that the attached customer-owned (external) model threw an exception when Amazon Fraud Detector invoked the model.</p>
        capo_frauddetector.errors.throttling_exception.ThrottlingException: <p>An exception indicating a throttling error.</p>
        capo_frauddetector.errors.validation_exception.ValidationException: <p>An exception indicating a specified value is not allowed.</p>
        capo_frauddetector.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_frauddetector.types.get_event_prediction_request.GetEventPredictionRequest]",
    ) -> OperationResponse[
        "capo_frauddetector.types.get_event_prediction_result.GetEventPredictionResult"
    ]:
        import capo_frauddetector._operations.aws_hawks_nest_service_facade.get_event_prediction

        output, http_response = (
            capo_frauddetector._operations.aws_hawks_nest_service_facade.get_event_prediction.get_event_prediction(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_frauddetector.types.get_event_prediction_request.GetEventPredictionRequest",
    ) -> dict[str, Any]:
        import capo_frauddetector.types.get_event_prediction_request

        return (
            capo_frauddetector.types.get_event_prediction_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("GetEventPrediction", redact_input=_redact_input),
    )
    input_: capo_frauddetector.types.get_event_prediction_request.GetEventPredictionRequest = {
        "detector_id": detector_id,
        "event_id": event_id,
        "event_type_name": event_type_name,
        "entities": entities,
        "event_timestamp": event_timestamp,
        "event_variables": event_variables,
    }
    if detector_version_id is not None:
        input_["detector_version_id"] = detector_version_id
    if external_model_endpoint_data_blobs is not None:
        input_["external_model_endpoint_data_blobs"] = (
            external_model_endpoint_data_blobs
        )

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