1.1 - 8.10 - Shapley Value Functions Example: nPath Creates ShapleyGenerateCombination; Step 5 - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.1
8.10
Release Date
October 2019
Content Type
Programming Reference
Publication ID
B700-4003-079K
Language
English (United States)

Step 5 computes the unnormalized Shapley values from the CVS and ACVS.

This query returns the following table:

SELECT player, SUM(partial_avg) / 5 AS shapley_value FROM (
  SELECT player, size, SUM(partial_value) AS partial_avg FROM (
    SELECT player,
    (attrib_cvs."value" - attrib_acvs."value") / divisor AS partial_value,
    attrib_acvs.size AS size
    FROM attrib_cvs INNER JOIN attrib_acvs
    ON (attrib_cvs.comb = attrib_acvs.comb2)
    ) AS stratum
  GROUP BY player, size) AS stratum_avg
GROUP BY player ORDER BY player;
 player shapley_value        
 ------ -------------------- 
 1       0.08666666944821676
 2       0.03666666994492214
 3       0.04499999781449635
 4       0.11166666299104691
 5      0.020000011722246813