Conversation
…samples is 0 A sample alone in its cluster got a(x) = 0, so it scored 1 instead of 0 (Rousseeuw's definition, same as scikit-learn). When a(x) = b(x) = 0 the score was 0 / 0 = NaN; scikit-learn gives 0.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #481 +/- ##
==========================================
+ Coverage 76.95% 76.98% +0.02%
==========================================
Files 105 105
Lines 7612 7617 +5
==========================================
+ Hits 5858 5864 +6
+ Misses 1754 1753 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
silhouette_scoregives wrong values in two cases.A sample alone in its cluster. Its
a(x)is 0, so it scores(b - 0) / b = 1. Rousseeuw's definition (and scikit-learn) gives such a samples(x) = 0. So a clustering scores higher just by having one-point clusters.Example: points
[0], [1], [10]with labels0, 0, 1:[0]scores 0.9,[1]scores 8/9,[10]is alone → 0Identical samples. When
a(x) = b(x) = 0, the score is0 / 0 = NaN, and the whole mean becomes NaN. scikit-learn gives 0 there (nan_to_num).Example: four equal points
[1, 1]with labels0, 0, 1, 1→ linfa gave NaN, expected 0.Change
max(a, b)only when it is not 0, else the sample scores 0Tests
Two new tests in
metrics_clustering.rs, both fail before the change (0.9296 vs 0.5963, NaN vs 0).cargo test --libinlinfa: 78 pass.The single-label case still returns 1, as before (scikit-learn raises an error there); I did not change it.