Best practices for custom variables

Updated at:

A custom variable is a risk control feature that you create by processing and deriving data from existing fields. For example, in a loan application scenario, you may need to process hundreds of different fields. You can use calculation logic to derive new variables from these fields to define features more precisely. This topic describes how to use the custom variable feature to process multiple fields and derive more variables, also known as features.

Create a custom variable

  1. Assume that an event already contains the "annual income" and "annual debt" fields.

image

  1. Go to Variable Center > Custom Variables to create a variable named "debt-to-income ratio". Note the following four parameters:

    1. Associated event: The fields used in the variable expression are from the associated event. Therefore, this event must contain all the fields that the expression requires.

    2. Variable type: Select the correct variable type. For example, the "debt-to-income ratio" is a decimal number that is less than or equal to 1. Therefore, select "Float".

    3. Abnormal value: This is the value that the custom variable returns if a field in the calculation has an abnormal value. The default value is -1, but you can customize it.

    4. Calculation expression: Supports basic operations and various functions. Use the at sign (@) to reference a field or variable. Use the number sign (#) to reference a function. In this example, the simple division formula "@debt/@income" is used.

image

  1. Test: To ensure that the custom variable provides the expected output, run a test before you submit and save it. During the test, check the following items:

  2. Check if the calculation expression has any syntax errors. The system performs this check automatically.

  3. Check if all fields used in the calculation are displayed under Variable Parameters.

  4. Check if the Calculation Result, which is derived from the Variable Parameters values, is as expected.

image

  1. After the variable passes the test, submit it to create the variable.

image

Use a custom variable

  1. When you create a policy, you can find and select the created variable under Custom Variables to use as the left or right variable in a rule.

image

  1. In this example, if the debt-to-income ratio is greater than or equal to 0.8, the policy returns a "reject" decision and the value of the variable.

image

Verification

  1. You can validate the configured event in the Fraud Detection OpenAPI. The following examples are for reference.

  2. Sample code for input parameters

{
  "eventCode":"de_acldkg1439",
  "mobileMd5":"****",
  "ip":"*.*.*.*",
  "deviceToken":"***"
}
  1. Sample response parameters

{
  "Message": "OK",
  "RequestId": "70C40825-F449-5670-BA74-CA8286C6A8ED",
  "Data": {
    "extend": "{\"dti\":0.8}",
    "finalDecision": "REJECT",
    "tags": ""
  },
  "Code": 200
}

image