Skip to content

silhouette_samples: ragged/NaN-padded input handled inconsistently across metric branches #712

Description

@SomSamantray

Problem

tslearn.clustering.silhouette_samples handles ragged (NaN-padded) time-series input inconsistently across metric branches:

  • metric="euclidean" raises a raw ValueError: Input X contains NaN.
  • metric="dtw" silently truncates NaNs and returns results.
  • metric="softdtw" silently miscalculates over the NaN padding (mean shifts from 0.1795 to 0.1518 on ragged data) with no warning.

Suggested fix

Add a documented policy: either validate that all series are full-length (and raise a clear error for ragged input in every branch), or strip NaN padding consistently before all branches (including euclidean), and add tests covering ragged/NaN-padded input for every metric.

Metadata

Severity: P1
Confidence: 75
Reviewer(s): adversarial (ce-code-review run 20260821-221628-4e205155 on PR #703)
Finding ID: tslearn/clustering/utils.py:358 ragged and NaN-padded time-series input

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions