def METHOD_NAME(self) -> dict:
    """Serialize to a dict."""
    out = {
        'class_id': self.class_id,
        'class_name': self.class_name,
        'gt_count': self.gt_count,
        'pred_count': self.pred_count,
        'count_error': abs(self.gt_count - self.pred_count),
        'relative_frequency': self.gt_count / self.conf_mat.sum(),
        'metrics': {
            'recall': self.recall,
            'precision': self.precision,
            'f1': self.f1,
            'sensitivity': self.sensitivity,
            'specificity': self.specificity,
        }
    }
    if self.true_neg is None:
        del out['relative_frequency']
        out['true_pos'] = self.true_pos
        out['false_pos'] = self.false_pos
        out['false_neg'] = self.false_neg
    else:
        cm = self.conf_mat
        cm_frac = cm / cm.sum()
        out['conf_mat'] = cm.tolist()
        out['conf_mat_frac'] = cm_frac.tolist()
        [[TN, FP], [FN, TP]] = cm
        out['conf_mat_dict'] = dict(TN=TN, FP=FP, FN=FN, TP=TP)
        [[TN, FP], [FN, TP]] = cm_frac
        out['conf_mat_frac_dict'] = dict(TN=TN, FP=FP, FN=FN, TP=TP)
    out.update(self.extra_info)
    return out