Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ballot-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ballot-0.1.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

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

Hashes for ballot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aac83bfb53094c6c2b4f79a964e3318c1bec835cb5ca53d60b3975db7f69df08
MD5 fb91adc79780fb54be2192033b1046fc
BLAKE2b-256 d37e06a70fc0677a811fc9b21b658b1c60cb8bc849b068689900e3fab0e0ad37

See more details on using hashes here.

Provenance

The following attestation bundles were made for ballot-0.1.0.tar.gz:

Publisher: publish.yml on kuslavicek/ballot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ballot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca780ea76235a84181ebf0320060fc9bfb741868ec05d30884f8ff3ebe3eb88a
MD5 11d9d4ebd4969b74e149ef26106d123d
BLAKE2b-256 df9c906dc9b6c1674cc95354f248aa872a192106ebf8fa948bb4701afbbf2129

See more details on using hashes here.

Provenance

The following attestation bundles were made for ballot-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kuslavicek/ballot

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page