kmedoids
Source: src/kmedoids.rs
K-Medoids (PAM) clustering with precomputed distance matrix.
Accepts a flat distance matrix and runs the Partitioning Around Medoids swap algorithm in Rust, returning cluster assignments.
Python API
kmedoids_pam
Rust-accelerated k-medoids PAM algorithm.
Accepts a flat distance matrix (list of n*n floats, row-major), the number of series n, clusters k, max iterations, and seed. Returns a list of cluster assignments (0-indexed) for each series.
Internal Functions
These are internal Rust functions not directly callable from Python.
pam_swap
Run the PAM swap algorithm on a precomputed distance matrix.
Arguments
| Parameter | Description |
|---|---|
dist_flat |
Flattened n×n distance matrix (row-major) |
n |
Number of series |
k |
Number of clusters |
max_iter |
Maximum swap iterations |
seed |
Random seed for initial medoid selection |
Returns (medoid_indices, cluster_assignments) as Vec