1.0 - 8.00 - Shapley Value Functions Example 2 Step 5 - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
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.036666669944922126
3 0.04499999781449636
4 0.11166666299104691
5 0.020000011722246813