urbanlc.analyze.metrics.confusion_matrix#
- urbanlc.analyze.metrics.confusion_matrix(pred_path: str, gt_path: str, mapper_gt: List = {0: -1, 10: 0, 11: 0, 12: 0, 20: 0, 30: 0, 40: 0, 50: 0, 60: 0, 61: 0, 62: 0, 70: 0, 71: 0, 72: 0, 80: 0, 81: 0, 82: 0, 90: 0, 100: 0, 110: 0, 120: 0, 121: 0, 122: 0, 130: 0, 140: 0, 150: 3, 151: 3, 152: 3, 153: 3, 160: 0, 170: 0, 180: 0, 190: 1, 200: 3, 201: 3, 202: 3, 210: 2, 220: 4}, mapper_pred: List = {0: -1, 10: 0, 20: 0, 30: 0, 40: 0, 50: 1, 60: 3, 70: 4, 80: 2, 90: 0, 95: 0, 100: 0}, gt_downscale_factor: Optional[float] = None, use_pred_as_ref: Optional[bool] = False) ndarray #
Calculate the confusion matrix based on predicted and ground truth data.
This function takes paths to predicted and ground truth data, optionally downscales the ground truth data, and then calculates the confusion matrix. The super-class mappings are applied, and the result is returned as a numpy array.
- Parameters:
pred_path (str) – Path to the predicted data.
gt_path (str) – Path to the ground truth data.
mapper_gt (List, optional) – Super-class mapping dictionary for ground truth classes. Defaults to ESA1992_map.
mapper_pred (List, optional) – Super-class mapping dictionary for predicted classes. Defaults to ESA2021_map.
gt_downscale_factor (float, optional) – Downscale factor for ground truth data. Defaults to None.
use_pred_as_ref (bool, optional) – If True, use predicted data as reference; otherwise, use ground truth. Defaults to False.
- Returns:
Confusion matrix.
- Return type:
np.ndarray