This documentation is for scikit-learn version 0.10Other versions

Citing

If you use the software, please consider citing scikit-learn.

This page

8.16.3.6. sklearn.metrics.v_measure_score

sklearn.metrics.v_measure_score(labels_true, labels_pred)

V-Measure cluster labeling given a ground truth

The V-Measure is the hormonic mean between homogeneity and completeness:

v = 2 * (homogeneity * completeness) / (homogeneity + completeness)

This metric is independent of the absolute values of the labels: a permutation of the class or cluster label values won’t change the score value in any way.

This metric is furthermore symmetric: switching label_true with label_pred will return the same score value. This can be useful to measure the agreement of two independent label assignments strategies on the same dataset when the real ground truth is not known.

Parameters :

labels_true : int array, shape = [n_samples]

ground truth class labels to be used as a reference

labels_pred : array, shape = [n_samples]

cluster labels to evaluate

Returns :

completeness: float :

score between 0.0 and 1.0. 1.0 stands for perfectly complete labeling

See also

-, -

Notes

References:

[Rosenberg2007]V-Measure: A conditional entropy-based external cluster evaluation measure Andrew Rosenberg and Julia Hirschberg, 2007 http://acl.ldc.upenn.edu/D/D07/D07-1043.pdf

Examples

Perfect labelings are both homogeneous and complete, hence have score 1.0:

>>> from sklearn.metrics.cluster import v_measure_score
>>> v_measure_score([0, 0, 1, 1], [0, 0, 1, 1])
1.0
>>> v_measure_score([0, 0, 1, 1], [1, 1, 0, 0])
1.0

Labelings that assign all classes members to the same clusters are complete be not homogeneous, hence penalized:

>>> v_measure_score([0, 0, 1, 2], [0, 0, 1, 1])     
0.8...
>>> v_measure_score([0, 1, 2, 3], [0, 0, 1, 1])     
0.66...

Labelings that have pure clusters with members coming from the same classes are homogeneous but un-necessary splits harms completeness and thus penalize V-measure as well:

>>> v_measure_score([0, 0, 1, 1], [0, 0, 1, 2])     
0.8...
>>> v_measure_score([0, 0, 1, 1], [0, 1, 2, 3])     
0.66...

If classes members are completly splitted across different clusters, the assignment is totally in-complete, hence the v-measure is null:

>>> v_measure_score([0, 0, 0, 0], [0, 1, 2, 3])
0.0

Clusters that include samples from totally different classes totally destroy the homogeneity of the labeling, hence:

>>> v_measure_score([0, 0, 1, 1], [0, 0, 0, 0])
0.0