Attribute: combination - evolv-ai/metrics GitHub Wiki
Using the combination
key within a metric allows a metric to be computed from 2 sources of data. The first source is the normal mechanism and the second source is embedded inside of the combination data.
A couple of examples of this is as follows:
{
"source": "expression",
"key": "window.cart.productCost",
"type": "number",
"combination":{
"operator": "product",
"key": window.cart.productCount
}
}
{
"source": "expression",
"key": "window.cart.productIds",
"type": "boolean",
"combination":{
"operator": "subset",
"metric":{
"key": "window.user.ownedProductIds"
}
}
}
The current operators require the evaluation of both metric values to either be both numbers or both arrays. The options for the operator are:
Operator | Type | Description |
---|---|---|
min | Number | produces a number that is the min of main and combination metric |
max | Number | produces a number that is the max of main and combination metric |
product | Number | produces a number that is the product of main and combination metric |
sum | Number | produces a number that is the sume of main and combination metric |
superset | Array | produces a boolean where it checks to see if the main metric is a superset of the combination metric |
subset | Array | produces a boolean where it checks to see if the main metric is a subset of the combination metric |
proper-superset | Array | produces a boolean where it checks to see if the main metric is a proper subset of the combination metric |
proper-subset | Array | produces a boolean where it checks to see if the main metric is a proper superset of the combination metric |
Proper vs Normal Subset and Superset
The difference between proper subset vs subset (and proper superset vs superset), is that both subset and superset will return true if both arrays are equivalent. Where as the proper subset and proper superset will return false if the arrays are equivalent.
For example, [1,2,3] is both a subset and proper subset of [1,2,3,4]. However, [1,2,3] is a subset of [1,2,3], but is not a proper subset.