Getting fraud predictions - Amazon Fraud Detector

Getting fraud predictions

To get fraud predictions, call the GetEventPrediction API. Supply information about the event you want to evaluate and synchronously receive a model score and outcome based on the designated detector.

As part of the request you must specify the detectorId that Amazon Fraud Detector will use to evaluate the event. You can optionally specify a detectorVersionId. If a detectorVersionId is not specified, Amazon Fraud Detector will use the ACTIVE version of the detector.

You are required to provide the following metadata regarding the evaluated event:

  • EventId: A unique identifier for the event.

  • Entities: The entityType and entityId to specify who is performing the event. If the entityId is not available at the time of evaluation, pass the string unknown.

  • Timestamp: The timestamp when the event occurred. The timestamp must be in ISO 8601 standard in UTC.

  • Event variables: Names of the event type's variables and their corresponding values for the evaluated event. If you do not send a value for a variable, Amazon Fraud Detector will use the default value.

You can optionally send data to invoke an SageMaker model by passing the data in the field externalModelEndpointBlobs.

During the evaluation, Amazon Fraud Detector will first generate model scores for any models added to the detector version, then pass the results to the rules for evaluation. The rules will be executed as specified by the rule execution mode (see Create a detector version for details). As part of the response, Amazon Fraud Detector will provide model scores as well as any outcomes associated to the matched rules.

To generate a test prediction using the AWS Console, see Step 6: Test and get predictions

Get a fraud prediction using the AWS SDK for Python (Boto3)

To generate a fraud prediction, call the GetEventPrediction API. The example below assumes you have completed Part B: Generate real-time fraud predictions. As part of the response, you will receive a model score as well as any matched rules and corresponding outcomes. You can find additional examples of GetEventPrediction requests on the aws-fraud-detector-samples GitHub repository.

import boto3 fraudDetector = boto3.client('frauddetector') fraudDetector.get_event_prediction( detectorId = 'sample_detector', eventId = '802454d3-f7d8-482d-97e8-c4b6db9a0428', eventTypeName = 'sample_registration', eventTimestamp = '2020-07-13T23:18:21Z', entities = [{'entityType':'sample_customer', 'entityId':'12345'}], eventVariables = { 'email_address' : '', 'ip_address' : '' } )