scikit-learn / scikit-learn/scikit-learn

Pass the confusion matrix as a parameter

Open
#19,679 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module:metrics 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

Functions like sklearn.metrics.balanced_accuracy_score, f1_score, jaccard_score, matthews_corrcoef, etc. recalculate the confusion matrix every time, which is very time consuming. I would want to calculate it once and then pass it to these functions as a parameter to get the resulting quality metrics much faster. If you want to calculate more than one of these scores on the same big data set this will save a lot of time.

Describe your proposed solution

Check if the parameter "cm" is passed and then skip its recalculation if yes.

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 with the named sklearn.metrics functions: balanced_accuracy_score, f1_score, jaccard_score, and matthews_corrcoef, and inspect how each currently calculates its confusion matrix. Define the shared parameter behavior and verify that passing a precomputed matrix avoids recalculation while preserving the existing metric results.

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.