scikit-learn / scikit-learn/scikit-learn

Add sample weighting to V Measure Score

Open
#26,880 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

New Feature
Dominant language
Python
Stars
67.3k
Forks
27.4k
Avg merge
1d 15h
Merged PRs (30d)
58

Description

Describe the workflow you want to enable

Many evaluation metrics in sklearn have the ability to weight samples by some measure of importance (usually included as a sample_weight). This is also important to do when evaluating clustering. In particular, the v_measure_score (and the metrics and functions it relies on), should have this ability.

Describe your proposed solution

The proposed solution is to amend the v_measure_score function, as well as the entropy, the contingency_matrix and the mutual_info_score functions, to include a sample_weight input parameter.

This has been implemented and tested already in this repository, for this Kaggle challenge scoring metric.

Making the changes requires very little substantive changes to each function, and handling the edge cases is straightforward. This would make the v_measure_score much more useful for cases such as those in the Kaggle challenge (clustering of energy deposits of different intensities).

Describe alternatives you've considered, if relevant

A possible alternative is to keep the current functions, and handle weighting by repeating entries according to their weight. However, this is expensive and clunky, and doesn't work for fractional weights.

Additional context

No response

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 by locating the v_measure_score, entropy, contingency_matrix, and mutual_info_score entry points and their existing tests, then compare the linked implementation for sample weighting. Done means these functions accept sample_weight consistently, handle the stated edge cases, and have coverage for weighted clustering metrics.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.