Create a variable - Amazon Fraud Detector

Create a variable

Variables represent data elements that you want to use in a fraud prediction, such as data from the event that is being evaluated or risk score outputs from Amazon Fraud Detector models or Amazon SageMaker models.

To create a variable using the AWS Console, navigate to Amazon Fraud Detector, choose Variables in the left navigation, then choose Create.

You can optionally assign variables a variable type. Variable types represent common data elements used during fraud predictions. Only variables with an associated variable type can be used for model training. Select from a number of pre-defined variable types or one of three custom variable types FREE_FORM_TEXT, CATEGORICAL, or NUMERIC.

Variables must have a data type for the data element that the variable represents. For variables that are mapped to a variable type, the data type is pre-selected. Possible data types include:

Data type Description Default value Example values
String Any combination of letters and/or whole numbers <empty>

abc, 123, 1D3B

Integer Positive or negative whole numbers 0 1, -1
Boolean True or False False True, False
Float Numbers with decimal points 0.0 4.01, 0.10

Variables must have a default value. During a GetEventPrediction API call, this value will be used to run a rule or model if Amazon Fraud Detector does not receive a value for a variable. Default values must match the selected data type. In the AWS Console, Amazon Fraud Detector will automatically assign the default value of 0 for integers, false for Booleans, 0.0 for floats, and (empty) for strings. You can optionally set a custom default value.

Variable types

Amazon Fraud Detector supports the following variable types:

Category Variable type Description Data type Example
Email EMAIL_ADDRESS Email address collected during the event String abc@domain.com
IP address IP_ADDRESS IP address collected during the event String 1.1.1.1
Phone number PHONE_NUMBER Phone number collected during the event String 1-123-456-7891
Browser/Device USERAGENT User agent collected during the event String Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101
FINGERPRINT Unique identifier for a device String sadfow987u234
Payment Instrument PAYMENT_TYPE Payment instrument type used for payment during the event String Credit Card
CARD_BIN First six digits of the credit card Integer 123456
AUTH_CODE Alphanumerical code sent by a credit card issuer or issuing bank String 00
AVS Address Verification System response code from card processor String Y
Billing Address BILLING_NAME Name associated with billing address String John Doe
BILLING_PHONE Phone associated with billing address String 1-123-456-7891
BILLING_ADDRESS_L1 Billing address line 1 String 123 4th St.
BILLING_ADDRESS_L2 Billing address line 2 String Unit 123
BILLING_CITY Billing address city String Seattle
BILLING_STATE Billing address state or providence String WA
BILLING_COUNTRY Billing address country String US
BILLING_ZIP Billing address postal code String 98109
Shipping Address SHIPPING_NAME Name associated with shipping address String John Doe
SHIPPING_PHONE Phone associated with shipping address String 1-123-456-7891
SHIPPING_ADDRESS_L1 Shipping address line 1 String 123 4th St.
SHIPPING_ADDRESS_L2 Shipping address line 2 String Unit 123
SHIPPING_CITY Shipping address city String Seattle
SHIPPING_STATE Shipping address state or providence String WA
SHIPPING_COUNTRY Billing address country String US
SHIPPING_ZIP Shipping address postal code String 98109
Order ORDER_ID Unique identifier for transaction String LUX60
PRODUCT_CATEGORY Product category of order item String kitchen
CURRENCY_CODE ISO 4217 currency code String USD
PRICE Total order price String 560.00
Custom NUMERIC Any variable that can be represented as a real number Float 1.224
CATEGORICAL Any variable that describes categories, segments, or groups String Large
FREE_FORM_TEXT Any free form text that is captured as part of the event. For example, a customer review or comment. String Example of a free form text input

Create a variable using the AWS SDK for Python (Boto3)

The following example shows requests for the CreateVariable API. The example creates two variables, email_address and ip_address, and assigns them to the corresponding variable types (EMAIL_ADDRESS and IP_ADDRESS). Specifying the variable type allows Amazon Fraud Detector to interpret the variable during model training and GetEventPrediction requests. Only variables with an associated variable type can be used for model training.

You must specify a variable source, which identifies where the variable value will be derived. If the variable source is EVENT, the variable value will be sent as part of the GetEventPrediction request. If the variable value is MODEL_SCORE, it will be populated by an Amazon Fraud Detector model. If EXTERNAL_MODEL_SCORE, the variable value will be populated by an imported SageMaker model.

import boto3 fraudDetector = boto3.client('frauddetector') #Create variable email_address fraudDetector.create_variable( name = 'email_address', variableType = 'EMAIL_ADDRESS', dataSource = 'EVENT', dataType = 'STRING', defaultValue = '<unknown>' ) #Create variable ip_address fraudDetector.create_variable( name = 'ip_address', variableType = 'IP_ADDRESS', dataSource = 'EVENT', dataType = 'STRING', defaultValue = '<unknown>' )