CellScope.cm.calculate_metrics

CellScope.cm. calculate_metrics (true_labels : np.ndarray, pred_labels : np.ndarray)

CellScope.cm.calculate_metrics is a function designed to evaluate the consistency between clustering results and true labels. By inputting true labels and predicted labels, the function computes a series of standard clustering evaluation metrics, including Accuracy, Normalized Mutual Information (NMI), Adjusted Rand Index (ARI), F1 Score, and Jaccard Index.

Parameters

  • true_labels (np.ndarray):

    A string-based label vector with a length of num_cell, representing the true labels for each cell.

  • pred_labels (np.ndarray):

    A string-based label vector with a length of num_cell, representing the predicted labels for each cell.

Return

  • metrics (dict):

    A dictionary containing the clustering accuracy metrics between the true_labels and the pred_labels:

    • “Accuracy” (float):

    The proportion of correctly predicted labels, calculated as the ratio of correct predictions to total samples.

    • “NMI” (float):

    Normalized Mutual Information, which measures the amount of information shared between true and predicted labels, normalized to the range [0, 1]. Higher values indicate better clustering performance.

    • “ARI” (float):

    Adjusted Rand Index, assessing the similarity between true and predicted clustering labels. It adjusts for chance, with values ranging from -1 to 1, where 1 indicates perfect agreement.

    • “F1 Score” (float):

    The weighted harmonic mean of precision and recall, considering the balance between the two metrics. It ranges from 0 to 1, where 1 indicates perfect precision and recall.

    • “Jaccard” (float):

    Jaccard Index, measuring the intersection-over-union of true and predicted labels, ranging from 0 to 1. Higher values indicate better overlap between the two sets of labels.