Implementation:Scikit learn Scikit learn ConsensusScore
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Clustering Evaluation |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for computing the consensus score between two sets of biclusters, provided by scikit-learn.
Description
The consensus_score function computes the similarity between two sets of biclusters. It uses a pairwise similarity metric (default Jaccard coefficient) to compare biclusters, then applies the Hungarian algorithm (linear sum assignment) to find the optimal one-to-one matching between the two sets. The final score is the mean similarity over the best matching pairs.
Usage
Use this function to evaluate biclustering results by comparing predicted biclusters against ground truth or comparing two different biclustering solutions.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/metrics/cluster/_bicluster.py
Signature
@validate_params(
{
"a": [tuple],
"b": [tuple],
"similarity": [callable, StrOptions({"jaccard"})],
},
prefer_skip_nested_validation=True,
)
def consensus_score(a, b, *, similarity="jaccard"):
Import
from sklearn.metrics import consensus_score
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| a | tuple of (rows, columns) | Yes | First set of biclusters as (row_indicators, column_indicators) |
| b | tuple of (rows, columns) | Yes | Second set of biclusters as (row_indicators, column_indicators) |
| similarity | str or callable | No | Similarity metric to use (default 'jaccard') |
Outputs
| Name | Type | Description |
|---|---|---|
| score | float | Consensus score: mean similarity over the best matching bicluster pairs |
Usage Examples
Basic Usage
import numpy as np
from sklearn.metrics import consensus_score
# Two sets of biclusters represented as (rows, columns)
a_rows = np.array([[True, True, False], [False, True, True]])
a_cols = np.array([[True, False], [False, True]])
b_rows = np.array([[True, True, False], [False, False, True]])
b_cols = np.array([[True, False], [False, True]])
score = consensus_score((a_rows, a_cols), (b_rows, b_cols))
print(score)