Document that silhouette_samples ignores kwargs for metric="precomputed" - #719
Open
ApparentlyTejas wants to merge 1 commit into
Open
Conversation
metric_params, n_jobs, verbose and **kwds have no effect when metric="precomputed" since no distance function is called in that branch, mirroring sklearn's own silhouette_samples. This was already true and already covered implicitly by test comments, but undocumented on the function itself. Add explicit docstring notes, an inline comment at the early-return, and a regression test locking in that these arguments are a no-op and don't change the result. Closes tslearn-team#714
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #719 +/- ##
=======================================
Coverage 95.21% 95.21%
=======================================
Files 83 83
Lines 7902 7905 +3
=======================================
+ Hits 7524 7527 +3
Misses 378 378 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
silhouette_samples(..., metric="precomputed")returns beforemetric_params,n_jobs,verbose, or**kwdsare ever consulted, so they're silently ignored — no distance function is called on a precomputed matrix, matching sklearn's ownsilhouette_samples. That behavior wasn't documented anywhere on the function itself.This PR documents it rather than raising, for parity with sklearn and with
silhouette_score's existing precomputed handling (see discussion on #713).metric_params,n_jobs,verbose, and**kwdsstating they're ignored whenmetric="precomputed".metric_params/n_jobs/verbosepassed alongsidemetric="precomputed"don't change the result.Closes #714.
Test plan
tests/test_clustering.py:335-337, which already assumed this behavior.test_silhouette_samplesassertion comparing a baseline precomputed call against one withmetric_params/n_jobs/verboseset, asserting equal output.