1.1 - 8.10 - Shapley Value Functions Example: ShapleyGenerateCombination, ShapleyAddOnePlayer; Step 3 - 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 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.0
 2            10000.0
 3             8000.0