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

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.10
1.1
Published
October 2019
Language
English (United States)
Last Update
2019-12-31
dita:mapPath
ima1540829771750.ditamap
dita:ditavalPath
jsj1481748799576.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

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