Attribution - Path Based Solution
Overview
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
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]])
Try it!
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)
Try it!