gaitmap.evaluation_utils.f1_score#

gaitmap.evaluation_utils.f1_score(matches_df: dict[Union[collections.abc.Hashable, str], pandas.core.frame.DataFrame], *, zero_division: typing_extensions.Literal[warn, 0, 1] = 'warn') dict[Union[collections.abc.Hashable, str], float][source]#
gaitmap.evaluation_utils.f1_score(matches_df: DataFrame, *, zero_division: typing_extensions.Literal[warn, 0, 1] = 'warn') float

Compute the F1 score, also known as balanced F-score or F-measure.

The F1 score can be interpreted as the harmonic mean of precision and recall, where an F1 score reaches its best value at 1 and worst score at 0.

The formula for the F1 score is: F1 = 2 * (precision * recall) / (precision + recall)

Parameters:
matches_df

A 3 column dataframe with the column names s_id{stride_list_postfix}, s_id{ground_truth_postfix} and match_type or a dictionary of such dataframes. Each row is a match containing the index value of the left and the corresponding right one. The match_type column indicates the type of match: “tp” (true positive), “fp” (false positives) or “fn” (false negative) if no segmented counterpart exists.

zero_division“warn”, 0 or 1, default=”warn”

Sets the value to return when there is a zero division. If set to “warn”, this acts as 0, but warnings are also raised.

Returns:
f1_score

This is a float, if the input is just a single dataframe or a dictionary, if the input is a dictionary of dataframes.

See also

gaitmap.evaluation_utils.evaluate_segmented_stride_list

Generate matched_df from stride lists