libSV is a high-performance C++ library for Shapley value computations with Python bindings.
libSV provides efficient algorithms for computing Shapley values in cooperative game theory. The library features:
- Fast C++ Backend: Core computations implemented in optimized C++
- Python Interface: Easy-to-use Python bindings with inheritance support
- Multiple Algorithms: Exact computation and Monte Carlo approximation
- Extensible Design: Create custom games by inheriting the base Game class
- Built-in Games: Voting games, weighted voting games, and more
pip install -e .import libsv
# Create a weighted voting game
players = [0, 1, 2, 3]
weights = [40, 30, 20, 10]
quota = 60
game = libsv.WeightedVotingGame(players, weights, quota)
calculator = libsv.ShapleyCalculator()
# Compute Shapley values
shapley_values = calculator.compute_exact(game)
print(f"Shapley values: {shapley_values}")See docs/README.md for complete documentation, API reference, and examples.
libSV/
├── libSV/
│ ├── include/ # C++ headers
│ └── src/ # C++ implementation
├── examples/ # Python examples
├── tests/ # Unit tests
├── docs/ # Documentation
├── CMakeLists.txt # Build configuration
└── setup.py # Python package setup
# Build with CMake
mkdir build && cd build
cmake .. && make
# Run tests
cmake -DBUILD_TESTS=ON .. && make && ctest
# Install development version
pip install -e .MIT License - see LICENSE file for details.