Skip to content

Verify STUDY k-means canonicalization does not shift cluster numberingΒ #389

Closed

Description

@arnodelorme

πŸ€– Filed by an agent at @adelorme's request, as post-merge follow-up for the EEGLAB test-port stack (#329–#372).

studyfunc/_cluster_kmeans.py (+10 / βˆ’39) replaced its local multi-restart k-means with a call to miscfunc.kmeans_st._kmeans_labels. The two share RNG (np.random.default_rng(random_state)), rng.choice initialization, iteration structure, KMEANS_TOLERANCE, and inertia-based restart selection, so most behavior should be identical. Two differences remain:

  1. _kmeans_labels recomputes labels after the final center update; the removed code returned labels matched to the pre-update centers. Points near a cluster boundary can change assignment.
  2. _kmeans_labels returns _canonicalize_clusters(best_labels, best_centers), imposing a canonical cluster ordering where the removed code returned RNG-dependent ordering. Cluster numbering may therefore change.

STUDY cluster numbers are user-visible and are referenced in saved designs, so a renumbering is a user-facing change even when membership is unchanged.

This path is not covered by the parity_repo pipeline (no STUDY stage), so the parity run does not speak to it.

Ask: confirm both changes are intended, and check cluster numbering + membership stability on sample_data/ before and after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions