mobgap.laterality.evaluation.lrc_per_datapoint_score#

mobgap.laterality.evaluation.lrc_per_datapoint_score(
pipeline: LrcEmulationPipeline,
datapoint: BaseGaitDatasetWithReference,
) dict[source]#

Calculate the accuracy of the LRC pipeline for a single datapoint.

Warning

This function is not meant to be called directly, but as a scoring function in a tpcp.validate.Scorer. If you are writing custom scoring functions, you can use this function as a template or wrap it in a new function.

This function is used to evaluate the performance of an LRC algorithm. It calculates the performance by comparing the assigned left right label for each IC in the data. We assume, that the algorithm has assigned either “left” or “right” to each IC. Two metrics are calculated:

  • “accuracy”: The accuracy of the binary classification of the left right labels.

  • “accuracy_pairwise”: This accuracy is calculated, by comparing the left right labels of consecutive ICs. This

    means, we check in the reference and the predictions, if the left right label of the current IC is the same as the left right label of the previous IC. We then calculate the accuracy of these True False labels. This is a better metric to understand, if steps and strides would be correctly defined based on the provided L/R labels. Algorithms that completely switch left and right labels, but still get the order of the labels correct, would still get a high accuracy.

Parameters:
pipeline

An instance of LRC emulation pipeline that wraps the algorithm that should be evaluated.

datapoint

The datapoint to be evaluated.

Returns:
dict

A dictionary containing the performance metrics. Note, that some results are wrapped in a no_agg object or other aggregators. The results of this function are not expected to be parsed manually, but rather the function is expected to be used in the context of the validate/cross_validate functions or similar as scorer. This functions will aggregate the results and provide a summary of the performance metrics.