Fix Edge Case Crashes in Clustering Metrics
During early training epochs, models often output cluster distributions that are degenerate (e.g., assigning all samples to a single cluster, or assigning every single sample to its own unique cluster).
Currently, metrics within the ignite.metrics.clustering module rely on underlying scikit-learn implementations that do not support these edge cases. They throw a ValueError (such as Number of labels is 1. Valid values are 2 to n_samples - 1), which causes the entire Ignite Engine to crash during an evaluation run.
Identified Cases
- SilhouetteScore (#3641)
- DaviesBouldinScore (#3642)
- CalinskiHarabaszScore (#3641)
Credits to @Prathamesh8989 for pointing these issues out!
This issue serves to track these issues under one consolidated issue. PRs can be submitted for any new metrics (if added in the future) that suffer from the same problem.
Hi, I'd like to work on the CalinskiHarabaszScore edge case (the remaining metric from this tracking issue not yet covered by #3654). I'll submit a PR shortly.
Hey! I believe that this issue is probably happening due to scikit learn raising a value error, I am able to recreate the issue, and I am close to fixing it. If possible, can I work on this issue as well?
@ChandraguptSharma07 Hi, you can help reviewing the existing PRs once they are up for review.
@TahaZahid05 that's great, but I have actually started working on DaviesBouldinScore (sorry I am new to open sourcing, so I started working on it before discussing it here). I was about to run the tests, and if they pass, can I make a PR?
@ChandraguptSharma07 Hi! No worries at all, and welcome to the project! To keep things organized and avoid duplicate work, we usually stick to one PR per issue. Since someone has already started on this one, it is best to proceed with it.
You can still contribute by reviewing the PR once it’s live. In the meantime, you can checkout other 'help wanted' issues,
@TahaZahid05 sure that sounds great, actually my tests passed, and @nightcityblade mentioned that they were working on CalinskiHarabaszScore edge case, so if they are okay, I can make PRs for the other two :D
@ChandraguptSharma07 As mentioned in @nightcityblade comment, the other two are covered in #3654
@TahaZahid05 Thank you for pointing that out. I missed it completely.
Hey 👋, I've just created a thread for this issue on PyTorch-Ignite Discord where you can quickly talk to the community on the topic.
🤖 This comment was automatically posted by Discuss on Discord
All done