# Consensus Score

> Compute the consensus_score metric — provided by scikit-learn. Use when the user has predictions and ground-truth and needs to compute consensus_score, or asks how to score with consensus_score.

- Skill: `qhjqhj00/consensus-score` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/consensus-score`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/consensus-score/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/consensus-score

---


# consensus-score

> Metric `consensus_score` from `scikit-learn` (sklearn.metrics.consensus_score)

## When to invoke this skill

The user has predictions + ground truth and asks to evaluate with consensus_score, or
mentions `sklearn.metrics.consensus_score` directly, or wants the standard scikit-learn implementation.

## Reference signature

```python
from sklearn.metrics import consensus_score

# consensus_score(a, b, *, similarity='jaccard')
```

## Library docstring

```
The similarity of two sets of biclusters.

Similarity between individual biclusters is computed. Then the best
matching between sets is found by solving a linear sum assignment problem,
using a modified Jonker-Volgenant algorithm.
The final score is the sum of similarities divided by the size of
the larger set.

Read more in the :ref:`User Guide <biclustering>`.

Parameters
----------
a : tuple (rows, columns)
    Tuple of row and column indicators for a set of biclusters.

b : tuple (rows, columns)
    Another set of biclusters like ``a``.

similarity : 'jaccard' or callable, default='jaccard'
    May be the string "jaccard" to use the Jaccard coefficient, or
    any function that takes four arguments, each of which is a 1d
    indicator vector: (a_rows, a_columns, b_rows, b_columns).

Returns
-------
consensus_score : float
   Consensus score, a non-negative value, sum of similarities
   divided by size of larger set.

See Also
--------
scipy.optimize.linear_sum_assignment : Solve the linear sum assignment problem.

References
----------
* Hochreiter, Bodenhofer, et. al., 2010. `FABIA: factor analysis
  for bicluster acquisition
  <https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2881408/>`__.

Examples
--------
>>> from sklearn.metrics import consensus_score
>>> a = ([[True, False], [False, True]], [[False, True], [True, False]])
>>> b = ([[False, True], [True, False]], [[True, False], [False, True]])
>>> consensus_score(a, b, similarity='jaccard')
1.0
```

## Quick recipe

```python
import sklearn.metrics as _m
score = _m.consensus_score(y_true, y_pred)
```

## Don'ts

- Don't reimplement when the library version handles edge cases (NaN, ties, empty inputs) better than a hand-rolled formula.
- Always check the library version's argument order — sklearn is `(y_true, y_pred)` while torchmetrics is `(preds, target)`.

