Overview
The path based (scalloping) algorithm is a method of attributing a change in a function to its its underlying factors. The method attributes the full change of the function, hwoever, it requires a choice of factor order, which will generally change the result, making it non-unique.
Solution by Paths
It is generally agreed that if only one variable changes, then the entire change in the value of the function is due to the single variable. For example, if only the value of {% x_1 %} changes, then the change in f is
{% \Delta f = f(x_1', x_2) - f(x_1,x_2) %}
and the entire change is attributable to {% x_1 %}
This observation leads to a method of solution to the attribution problem. To calculate the change attributable to each
variable, you change each variable one at a time and measure the difference in f, then attribute that difference to the changed
variable.
As an example, consider attributing the change in f between the points (1,1) and (2,2)
{% value1 = f(1,1) %}
{% value2 = f(2,1) %}
{% value3 = f(2,2) %}
then
{% \Delta x_1 = value2 - value1 %}
{% \Delta x_2 = value3 - value2 %}
The challenge with this approach is that the answer will depend on the order which one chooses to scale
the inputted variables.
Attribution API
The attribution api provides a library of methods for accomplishing a path based attribution.
let att = await import('/lib/attribution/v1.0.0/attribution.mjs');
let method = function(x, y){
return x*y*y;
}
let results = att.path(method, [[1,1], [2,2]])
let att = await import('/lib/attribution/v1.0.0/attribution.mjs');
let method = function(x, y){
return x*y*y;
}
let xs = $from(1,2,10);
let ys = $from(1,2,10);
let args = [];
for(let i=0;i<xs.length;i++){
args.push([xs[i], ys[i]]);
}
let results = att.path(method, args)
Corrections
The path based solution is known to attribute the full change of the target function, however, the result will depend on the order of the scalloping. (that is, the chosen path). There are overlays to the path based solution that aim to fix the path based nature of the algorithm.
- Averaging - the averaging method will run a path based attribution over every possible ordering of factors, and the average the results.
- Staircase - the staircase method will break the change in the function to a large number of little changes, which it then computes the attribution along each little change, and then sums the result.