Lookup Factor¶
The general structure of the Lookup Factor core operation in Graphene is:
{
"_schema": "LookupFactor_1.0",
"table_path": "s3://my-bucket/myfolder/lookup_table.parquet",
"match_on": ["MetaColumn1", "MetaColumn2"],
"factor": "FactorColumnA",
"default_value": "1"
}
Parameters¶
The parameters are defined as follows:
Parameter Name |
Required |
Type |
Description |
---|---|---|---|
|
Yes |
|
File path of lookup table file in parquet format in Amazon S3. |
|
Yes |
|
Metadata attribute name(s) to be used as a combined key to lookup the factor in the lookup table. |
|
Yes |
|
The column in the lookup table that provides the factor values which must be of a float64 data type. |
|
Yes |
|
Specifies the default factor value if a factor value for a specific key cannot be found in the lookup table. |
The match_on
columns names and their data types must match between the lookup table and the input ledger.
Behavior¶
The core function of the LookupFactor operation is that it is configured with a reference to a lookup table, which supplies factor values linked to specific keys. These factor values can be obtained from the table using keys derived from the metadata of each record in the input Ledger. The LookupFactor then applies the corresponding factor to the record’s value.
Example¶
Assuming we have the following input ledger with Losses:
Trial |
Time |
Type |
Value |
EventId |
LOB |
GID |
---|---|---|---|---|---|---|
1 |
1 |
Loss |
100 |
1 |
A |
1 |
1 |
2 |
Loss |
300 |
2 |
A |
2 |
1 |
2 |
Loss |
400 |
2 |
B |
3 |
1 |
2 |
Loss |
500 |
3 |
C |
4 |
and a lookup table with the following keys and factors:
EventId |
LOB |
GID |
FactorA |
---|---|---|---|
1 |
A |
1 |
1.1 |
2 |
A |
2 |
1.2 |
2 |
B |
3 |
1.3 |
2 |
B |
3 |
1.7 |
If we use the lookup factor template with the following attributes:
{
"_schema": "LookupFactor_1.0",
"match_on": ["EventID", "LOB"],
"factor": "FactorA",
"default_value": "1"
}
We will get the following output:
Trial |
Time |
Type |
Value |
EventId |
LOB |
GID |
---|---|---|---|---|---|---|
1 |
1 |
Loss |
110 |
1 |
A |
1 |
1 |
2 |
Loss |
360 |
2 |
A |
2 |
1 |
2 |
Loss |
1200 |
2 |
B |
3 |
1 |
2 |
Loss |
500 |
3 |
C |
4 |
Example notes:
Financial record with EventId 1 and LOB A has matching keys with an effective factor value of 1.1, therefore output value is 100 * 1.1.
Financial record with EventId 2 and LOB A has matching keys with an effective factor value of 1.2, therefore output value is 300 * 1.2.
Financial record with EventId 2 and LOB B has two records with matching keys with an effective factor values of 3.0 (the sum of 1.3 and 1.7). When the provided keys matches more than one factor, the factors are additive and their sum is applied as the factor to the record value, therefore output value is (400 * 3.0).
Financial record with EventId 3 and LOB C does not have any matching keys, thus will use the default factor of 1 from the default_value parameter, therefore output value is 500 * (default_value 1.0).