Implementation:Online ml River Metrics FowlkesMallows
| Knowledge Sources | |
|---|---|
| Domains | Online_Learning, Evaluation_Metrics, Clustering |
| Last Updated | 2026-02-08 16:00 GMT |
Overview
Fowlkes-Mallows Index for measuring similarity between two clusterings or classifications.
Description
FowlkesMallows computes the geometric mean of precision (PPV) and recall (TPR) to measure similarity between two clusterings. The formula is FM = sqrt(PPV × TPR) = sqrt((TP/(TP+FP)) × (TP/(TP+FN))). Higher values indicate greater similarity between the clusterings, with 1.0 representing perfect agreement and 0.0 representing no agreement.
Usage
Use FowlkesMallows Index to evaluate clustering algorithms by comparing predicted clusters with ground truth labels, or to measure agreement between two different clustering solutions. It's particularly useful as an external clustering evaluation metric that considers both precision and recall aspects of cluster assignments.
Code Reference
Source Location
- Repository: Online_ml_River
- File: river/metrics/fowlkes_mallows.py
Signature
class FowlkesMallows(metrics.base.MultiClassMetric):
def __init__(self, cm=None):
pass
Import
from river import metrics
I/O Contract
| Method | Parameters | Returns | Description |
|---|---|---|---|
| update | y_true, y_pred | None | Updates metric with true and predicted cluster labels |
| get | - | float | Returns Fowlkes-Mallows Index (0.0 to 1.0) |
Note: This metric does not support sample weights (works_with_weights returns False).
Usage Examples
from river import metrics
y_true = [0, 0, 0, 1, 1, 1]
y_pred = [0, 0, 1, 1, 2, 2]
metric = metrics.FowlkesMallows()
for yt, yp in zip(y_true, y_pred):
metric.update(yt, yp)
print(metric)
# FowlkesMallows: 0.00%
# FowlkesMallows: 100.00%
# FowlkesMallows: 57.74%
# FowlkesMallows: 40.82%
# FowlkesMallows: 35.36%
# FowlkesMallows: 47.14%
# The final score of 47.14% indicates moderate agreement
# between the true and predicted clusterings