count_extra#

er_evaluation.error_analysis.count_extra(prediction, sample)[source]#

Count the number of extraneous elements to sampled clusters.

Given a predicted disambiguation prediction and a sample of true clusters sample, both represented as membership vectors, this functions returns the count of extraneous elements for each true cluster. This is a pandas Series indexed by true cluster identifier and with values corresponding to the counts of extraneous elements.

Count of extraneous elements

For a given sampled cluster \(c\) with records \(r \in c\), let \(A_r\) be the set of records which are erroneously linked to \(r\) in the predicted clustering. That is, if \(\hat c(r)\) is the predicted cluster containing \(r\), then \(A_r = \hat c(r) \backslash c\) Then the count of extraneous elements for \(c\) is

\[E_{\text{count_extra}}(c) = \sum_{r\in c} \lvert A_r \rvert.\]
Parameters:
  • prediction (Series) – Membership vector representing a predicted disambiguation.

  • sample (Series) – Membership vector representing a set of true clusters.

Returns:

Pandas Series indexed by true cluster identifiers (unique values in sample) and with values corresponding to the count of extraneous elements.

Return type:

Series

Examples

>>> prediction = pd.Series(index=[1,2,3,4,5,6,7,8], data=[1,1,2,3,2,4,4,4])
>>> sample = pd.Series(index=[1,2,3,4,5,8], data=["c1", "c1", "c1", "c2", "c2", "c4"])
>>> count_extra(prediction, sample)
reference
c1    1
c2    1
c4    2
Name: count_extra, dtype: int64

Notes

The sample is restricted to the set of records which are present in the prediction.