AltScore
Guides

Migrating Borrower Field Values

Before November 2024, lenders did not have the option to provide allowed values for borrower fields, which could lead to inconsistencies in the format of some values.

The AltScore SDK offers a simple solution to standardize and convert the values of borrower fields, which were previously recorded as free text, into structured data.

Example

Pineapple Inc. recorded the nationalities of its clients in free-text fields through a form filled out by different staff members. AltScore introduced the ability to add a list of allowed values to fields, and Pineapple Inc. wants to standardize the values to generate statistics and graphs.

This company has clients in Chile, Mexico, Ecuador, Bolivia, and the United States, and they want to limit nationality values to CHL, MEX, ECU, BOL, and EUA.

Retrieving Unique Values

First, let's analyze all the unique values present in the nationality field using the get_unique_borrower_field_values method.

from altscore import Altscore
 
altscore = Altscore(**config)
actual_values = altscore.macros.get_unique_borrower_field_values(field_key="nationality")
 
'''
actual_values = ["CHL", "bol", "eeuu", "mexicano", "chile", "Mexico", "ecuador"]
'''

We can see that the format of the values are quite inconsistent. Let's fix this.

Evaluating Value Migration

Now that we have the current values in the system and the target values, we can use the evaluate_value_migration method. This method takes two lists —one with the current values and another with the target values— and a threshold (85 by default). It matches each current value to the most similar value from the target list if their similarity is equal to or greater than the threshold. The result consists of: a list of pairs, where each pair contains a current value and its most similar corresponding target value; and another list with values that could not be matched.

Note that values already present in the target list will not appear. This is expected, as there is nothing to migrate for these values.

from altscore import Altscore
 
altscore = Altscore(**config)
actual_values = altscore.macros.get_unique_borrower_field_values(field_key="nationality")
 
target_values = ["CHL", "MEX", "ECU", "BOL", "EUA"]
 
suggestion, not_paired = altscore.macros.evaluate_value_migration(target_values, actual_values)
 
'''
suggestion = [
    ("bol", "BOL"),
    ("mexicano", "MEX"),
    ("Mexico", "MEX"),
    ("ecuador", "ECU")
]
 
not_paired = ["eeuu", "chile"]
'''

Assigning target values to unmatched entries is the responsibility of the implementer.

suggestion.append(("eeuu", "EUA"))
suggestion.append(("chile", "CHL"))

And with that, we're ready to migrate.

The evaluate_value_migration method provides suggestions based on Levenshtein distance. The implementer can generate the list of (current_value, target_value) pairs using any method they deem appropriate.

Migrating the Values

Once the list is prepared in the correct format, we can call the migrate_borrower_field_allowed_values method. This method handles migrating the field values.

altscore.macros.migrate_borrower_field_allowed_values("nationality", suggestion, target_values)

And that's it! Now the nationality field contains only the target values, and users can select exclusively from the allowed values list.

On this page