Shapley Value Functions Example 1 Step 3 - Teradata Vantage

Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
8.00
1.0
Published
May 2019
Language
English (United States)
Last Update
2019-11-22
dita:mapPath
blj1506016597986.ditamap
dita:ditavalPath
blj1506016597986.ditaval
dita:id
B700-4003
lifecycle
previous
Product Category
Teradata Vantageā„¢

Step 3 computes the Shapley value for each player.

The Shapley number for each project(player) is computed as an average of the sum of incremental contributions of each project (in this example, three total), using the combined SQL query shown below. The results match with those described above.

SQL Calls

Compute Shapley value for each player:

SELECT player, SUM(partial_avg) / 3 AS shapley_value FROM (
  SELECT player, size, SUM(partial_value) AS partial_avg FROM (
    SELECT player,
      (project_comb_cost."value" - project_addone_cost."value") / divisor AS partial_value,
      project_addone_cost.size AS size
    FROM project_comb_cost
    INNER JOIN
	  project_addone_cost
	  ON (project_comb_cost.comb = project_addone_cost.comb2)
  ) AS stratum GROUP BY player, size
) AS stratum_avg GROUP BY player ORDER BY player;

Output

player shapley_value
1 2000
2 10000
3 8000