tslearn-team / tslearn-team/tslearn

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

Open
#712 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Triage
Dominant language
Python
Stars
3.2k
Forks
384
Avg merge
3d 12h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at tslearn/clustering/utils.py:358 and trace how silhouette_samples handles NaN-padded series in the euclidean, dtw, and softdtw branches. Add tests covering ragged input for every metric, then verify that all branches follow one documented policy and produce clear, consistent behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.