CCoalitionAster
Product

Product features · Exact Shapley coalition values

01

CoalitionAster supports discussion of coalition tables and marginal contributions, with exact shares checked against player-order permutations.

01

Connection

Base URL, credentials and a reachable server.

02

Selection

A model available through the configured endpoint.

03

Capabilities

Context limits and tool support are determined by the model and server.

Exact Shapley coalition values

● ● ●CoalitionAster●
A concrete starting point · Exact Shapley coalition values ×
from fractions import Fraction
from math import comb

def shapley_values(values):
    if type(values) not in (list, tuple) or not 1 <= len(values) <= 256 or len(values) & (len(values)-1):
        raise ValueError("shapley.table")
    if any(type(v) is not int or abs(v) > 10**6 for v in values) or values[0] != 0:
        raise ValueError("shapley.value")
    players = len(values).bit_length()-1
    result = []
    for player in range(players):
        share = Fraction(0)
        for subset in range(len(values)):
            if not subset & (1 << player):
                size = subset.bit_count()
                weight = Fraction(1, players*comb(players-1, size))
                share += weight*(values[subset | (1 << player)]-values[subset])
        result.append(share)
    return result
✳Compute exact Shapley shares for up to eight players from an integer coalition-value table bounded by 1000000 in magnitude.
✓ ChangesReview before applying ↗
Illustrative workspace
AI coding workspace

Your next change starts here.

Get the Windows app ↗