Skip to main content

K-means clustering on quantum graphs and metric spaces using simulated annealing

Project description

kmeanssa-ng

License: MIT Python 3.9+ Pipeline Status Coverage Report Code style: Ruff

K-means clustering on quantum graphs and metric spaces using simulated annealing.

kmeanssa-ng provides tools for clustering data points that exist on complex network structures (quantum graphs) or other metric spaces where standard Euclidean distance does not apply. It uses a simulated annealing approach for robust convergence.

Installation

Install the latest version directly from GitLab:

pip install git+https://plmlab.math.cnrs.fr/nicolas.klutchnikoff/kmeanssa-ng.git

Quickstart

Here is a minimal example of clustering points on a quantum graph:

from kmeanssa_ng import generate_sbm, QGSimulatedAnnealing, SimulatedAnnealing

# Generate a graph with two distinct communities
graph = generate_sbm(
    sizes=[40, 40],       # Two communities of 40 nodes each
    p=[[0.8, 0.1],        # High intra-community connectivity  
       [0.1, 0.8]],       # Low inter-community connectivity
)

# Essential: precompute shortest paths
graph.precomputing()

# Sample points uniformly across the graph
points = graph.sample_points(150)

# Run quantum graph specialized simulated annealing
qg_sa = QGSimulatedAnnealing(
    observations=points,
    k=2,                  # We know there are 2 clusters
    lambda_param=1.0,     # Standard temperature
    beta=1.0,            # Standard drift strength
    step_size=0.1        # Standard step size
)

# Get cluster centers as node IDs (more interpretable)
node_centers = qg_sa.run_for_kmeans(robust_prop=0.1)
print(f"Cluster centers near nodes: {node_centers}")

Documentation

The full documentation, including API reference and tutorials, is under construction and will be available soon.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

kmeanssa_ng-0.2.2.tar.gz (113.6 kB view details)

Uploaded Source

Built Distribution

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

kmeanssa_ng-0.2.2-py3-none-any.whl (109.9 kB view details)

Uploaded Python 3

File details

Details for the file kmeanssa_ng-0.2.2.tar.gz.

File metadata

  • Download URL: kmeanssa_ng-0.2.2.tar.gz
  • Upload date:
  • Size: 113.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.12.2 Darwin/25.0.0

File hashes

Hashes for kmeanssa_ng-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8716421b2053f3f363f114d2c57a9491b4f79f3778b3674e96eb4b32aa759ef6
MD5 6f54c87268cde92af2b45479e7cc9d4a
BLAKE2b-256 c824f607d16bbb635219b3c825c4941c5f7b262c81a377ef19d486e5838008aa

See more details on using hashes here.

File details

Details for the file kmeanssa_ng-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: kmeanssa_ng-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 109.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.0 CPython/3.12.2 Darwin/25.0.0

File hashes

Hashes for kmeanssa_ng-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a6c85ef17bbfe63f2a85ce2ccc1ace31b57e3c19ec956391d6e33c88389ff6bc
MD5 2caa2530eeca99b99a28e2509ffc7a43
BLAKE2b-256 ee37082fdf0ab69a4851e2e9506eb339cc3333a7ff94019bcf68e0f8d58b515b

See more details on using hashes here.

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