shapley

Crates.ioshapley
lib.rsshapley
version0.1.1
created_at2025-07-05 07:42:40.847079+00
updated_at2025-07-06 04:25:00.651748+00
descriptionA fast shapley score calculator
homepage
repositoryhttps://github.com/shenxiangzhuang/shapley
max_upload_size
id1738810
size19,166
Mathew Shen (shenxiangzhuang)

documentation

https://docs.rs/crate/shapley

README

Shapley

Crates.io docs.rs MIT licensed

shapley is a fast shapley value calculator written in rust.

Quick Start

Install

cargo add shapley

Usage

use std::collections::HashMap;

use shapley::{Coalition, Shapley};

fn main() {
    let players = vec![1, 2];
    let coalition_worth = HashMap::from([
        (Coalition::new(vec![]), 0.0),
        (Coalition::new(vec![1]), 10.0),
        (Coalition::new(vec![2]), 20.0),
        (Coalition::new(vec![1, 2]), 30.0),
    ]);
    let shapley = Shapley::new(players, coalition_worth);
    println!("player1: {}", shapley.shapley_value(1).unwrap());  // 10
    println!("player2: {}", shapley.shapley_value(2).unwrap());  // 20
}
Commit count: 0

cargo fmt