spine.utils.metrics
Various metrics used to evaluate clustering.
Functions
|
Computes the Adjusted Mutual Information (AMI) between two sets of labels. |
|
Computes the Adjusted Rand Index (ARI) between two sets of labels. |
|
Computes the Best Dice (BD) between two sets of labels. |
|
Assignment efficiency, evaluated per true cluster and averaged. |
|
Assignment purity. |
|
Assignment purity and efficiency. |
|
Compute the Symmetric Best Dice (SBD) score between two sets of labels. |
|
Transforms labels to range from 0 to C-1 labels (with C the number of unique values in the label array. |
- spine.utils.metrics.pur(truth, pred, batch_ids=None, per_cluster=True)[source]
Assignment purity.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
per_cluster (bool, default True) – If True, computes the purity per predicted cluster, than averages it
- Returns:
Assignment purity
- Return type:
float
- spine.utils.metrics.eff(truth, pred, batch_ids=None, per_cluster=True)[source]
Assignment efficiency, evaluated per true cluster and averaged.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
per_cluster (bool, default True) – If True, computes the efficiency per truth cluster, than averages it
- Returns:
Assignment efficiency
- Return type:
float
- spine.utils.metrics.pur_eff(truth, pred, batch_ids=None, per_cluster=True)[source]
Assignment purity and efficiency.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
per_cluster (bool, default True) – If True, computes the metrics per predicted cluster, than averages them
- Returns:
float – Assignment purity
float – Assignment efficiency
- spine.utils.metrics.ari(truth, pred, batch_ids=None)[source]
Computes the Adjusted Rand Index (ARI) between two sets of labels.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
- Returns:
Adjusted Rand Index (ARI) value
- Return type:
float
- spine.utils.metrics.ami(truth, pred, batch_ids=None)[source]
Computes the Adjusted Mutual Information (AMI) between two sets of labels.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
- Returns:
Adjusted Mutual Information (AMI) value
- Return type:
float
- spine.utils.metrics.sbd(truth, pred, batch_ids=None)[source]
Compute the Symmetric Best Dice (SBD) score between two sets of labels.
- Parameters:
truth (np.ndarray) –
Set of true labels
pred (np.ndarray) –
Set of predicted labels
batch_ids (np.ndarray, optional) –
Batch IDs
- Returns:
Symmetric best dice value
- Return type:
float