sleap.info.metrics#
Module for producing prediction metrics for SLEAP datasets.
- sleap.info.metrics.calculate_pairwise_cost(instances_a: List[Instance | PredictedInstance], instances_b: List[Instance | PredictedInstance], cost_function: Callable) ndarray [source]#
Calculate (a * b) matrix of pairwise costs using cost function.
- sleap.info.metrics.compare_instance_lists(instances_a: List[Instance | PredictedInstance], instances_b: List[Instance | PredictedInstance]) ndarray [source]#
Given two lists of corresponding Instances, returns (instances * nodes) matrix of distances between corresponding nodes.
- sleap.info.metrics.list_points_array(instances: List[Instance | PredictedInstance]) ndarray [source]#
Given list of Instances, returns (instances * nodes * 2) matrix.
- sleap.info.metrics.match_instance_lists(instances_a: List[Instance | PredictedInstance], instances_b: List[Instance | PredictedInstance], cost_function: Callable) Tuple[List[Instance | PredictedInstance], List[Instance | PredictedInstance]] [source]#
Sorts two lists of Instances to find best overall correspondence for a given cost function (e.g., total distance between points).
- sleap.info.metrics.match_instance_lists_nodewise(instances_a: List[Instance | PredictedInstance], instances_b: List[Instance | PredictedInstance], thresh: float = 5) Tuple[List[Instance | PredictedInstance], List[Instance | PredictedInstance]] [source]#
For each node for each instance in the first list, pairs it with the closest corresponding node from any instance in the second list.
- sleap.info.metrics.matched_instance_distances(labels_gt: ~sleap.io.dataset.Labels, labels_pr: ~sleap.io.dataset.Labels, match_lists_function: ~typing.Callable = <function match_instance_lists_nodewise>, frame_range: range | None = None) Tuple[List[int], ndarray, ndarray, ndarray] [source]#
Distances between ground truth and predicted nodes over a set of frames.
- Parameters:
labels_gt – the
Labels
object with ground truth datalabels_pr – the
Labels
object with predicted datamatch_lists_function – function for determining corresponding instances Takes two lists of instances and returns “sorted” lists.
frame_range (optional) – range of frames for which to compare data If None, we compare every frame in labels_gt with corresponding frame in labels_pr.
- Returns:
frame indices map: instance idx (for other matrices) -> frame idx
distance matrix: (instances * nodes)
ground truth points matrix: (instances * nodes * 2)
predicted points matrix: (instances * nodes * 2)
- Return type:
Tuple
- sleap.info.metrics.nodeless_point_dist(inst_a: Instance | PredictedInstance, inst_b: Instance | PredictedInstance) ndarray [source]#
Given two instances, returns array of distances for closest points ignoring node identities.
- sleap.info.metrics.point_dist(inst_a: Instance | PredictedInstance, inst_b: Instance | PredictedInstance) ndarray [source]#
Given two instances, returns array of distances for corresponding nodes.