Lightning-AI / Lightning-AI/torchmetrics
V-measure returns 1 for independent nontrivial clusterings
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 526
- Avg merge
- 6d 11h
- Merged PRs (30d)
- 5
Description
For two independent, nontrivial clusterings, both homogeneity and completeness are zero, but `v_measure_score` currently returns `1.0`.
```python
import torch
from torchmetrics.functional.clustering import v_measure_score
preds = torch.tensor([0, 1, 0, 1])
target = torch.tensor([0, 0, 1, 1])
print(v_measure_score(preds, target)) # tensor(1.)
```
scikit-learn returns `0.0` for the same labels. That also matches the weighted harmonic mean definition: when both component scores are zero, V-measure should be zero.
This reproduces on current `master` (`8d008de1`) with Python 3.12.13 and PyTorch 2.13.0. I have a small fix and regression test ready. I also checked the edge case with a small Lean formalization and can attach it if useful :)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the torchmetrics.functional.clustering.v_measure_score entry point and run the supplied tensor example to reproduce the incorrect tensor(1.) result. Add the regression test described in the issue and verify that independent nontrivial clusterings return 0.0, while existing V-measure behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 76/100