Balanced k-means clustering with optimal transport (BalLOT)
Project description
Ballot: Balanced k-means clustering with optimal transport
Ballot (Balanced Lloyd with Optimal Transport) is a high-performance Python package for balanced clustering. It solves the problem of creating equal-sized clusters (or clusters with specific capacity constraints) by leveraging Optimal Transport theory and Entropic Regularization (Sinkhorn algorithm).
Features
- Speed: Uses Sinkhorn iterations (E-BalLOT) for near-linear time complexity $O(n \log n)$, making it usable for large datasets ($n > 100,000$).
- Simplicity: precise, math-driven implementation without complex C++ dependencies.
- Scikit-learn Compatible: Designed to fit seamlessly into existing ML pipelines.
Installation
Install via pip:
pip install ballot
Usage
import numpy as np
from ballot.core import solve_entropic_kantorovich
# Example usage (API subject to change in v0.1)
# Create random data and centroids...
# Run balanced clustering...
Development
To install in editable mode for development:
git clone https://github.com/username/ballot.git
cd ballot
pip install -e .
Run tests:
pytest
References
This project incorporates research from the following paper:
- BalLOT: Balanced k-means clustering with optimal transport Wenyan Luo, Dustin G. Mixon arXiv:2512.05926
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ballot-0.1.0.tar.gz.
File metadata
- Download URL: ballot-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aac83bfb53094c6c2b4f79a964e3318c1bec835cb5ca53d60b3975db7f69df08
|
|
| MD5 |
fb91adc79780fb54be2192033b1046fc
|
|
| BLAKE2b-256 |
d37e06a70fc0677a811fc9b21b658b1c60cb8bc849b068689900e3fab0e0ad37
|
Provenance
The following attestation bundles were made for ballot-0.1.0.tar.gz:
Publisher:
publish.yml on kuslavicek/ballot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ballot-0.1.0.tar.gz -
Subject digest:
aac83bfb53094c6c2b4f79a964e3318c1bec835cb5ca53d60b3975db7f69df08 - Sigstore transparency entry: 868320831
- Sigstore integration time:
-
Permalink:
kuslavicek/ballot@f644ee6d35cfd13fb6907805145b9e3ebd3afb3b -
Branch / Tag:
refs/tags/v0.1.0a - Owner: https://github.com/kuslavicek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f644ee6d35cfd13fb6907805145b9e3ebd3afb3b -
Trigger Event:
release
-
Statement type:
File details
Details for the file ballot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ballot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca780ea76235a84181ebf0320060fc9bfb741868ec05d30884f8ff3ebe3eb88a
|
|
| MD5 |
11d9d4ebd4969b74e149ef26106d123d
|
|
| BLAKE2b-256 |
df9c906dc9b6c1674cc95354f248aa872a192106ebf8fa948bb4701afbbf2129
|
Provenance
The following attestation bundles were made for ballot-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kuslavicek/ballot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ballot-0.1.0-py3-none-any.whl -
Subject digest:
ca780ea76235a84181ebf0320060fc9bfb741868ec05d30884f8ff3ebe3eb88a - Sigstore transparency entry: 868320836
- Sigstore integration time:
-
Permalink:
kuslavicek/ballot@f644ee6d35cfd13fb6907805145b9e3ebd3afb3b -
Branch / Tag:
refs/tags/v0.1.0a - Owner: https://github.com/kuslavicek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f644ee6d35cfd13fb6907805145b9e3ebd3afb3b -
Trigger Event:
release
-
Statement type: