1.1 - 8.10 - Shapley Value Functions Example: ShapleyGenerateCombination, ShapleyAddOnePlayer; Step 3 - Teradata Vantage

Teradata Vantage™ - Machine Learning Engine Analytic Function Reference

Teradata Vantage
Release Number
Release Date
October 2019
Content Type
Programming Reference
Publication ID
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
		ON (project_comb_cost.comb = project_addone_cost.comb2)
	) AS stratum
	GROUP BY player, size
) AS stratum_avg
GROUP BY player
ORDER BY player;


 player shapley_value 
 ------ ------------- 
 1             2000.0
 2            10000.0
 3             8000.0