gaitmap.evaluation_utils.precision_recall_f1_score#

gaitmap.evaluation_utils.precision_recall_f1_score(matches_df: dict[str, pandas.core.frame.DataFrame], *, zero_division: typing_extensions.Literal[warn, 0, 1] = 'warn') dict[str, gaitmap.evaluation_utils.scores._ScoresDict][source]#
gaitmap.evaluation_utils.precision_recall_f1_score(matches_df: DataFrame, *, zero_division: typing_extensions.Literal[warn, 0, 1] = 'warn') _ScoresDict

Compute precision, recall and F1-score.

The precision is the ratio tp / (tp + fp) where tp is the number of true positives and fp the number of false positives. The precision is intuitively the ability of the classifier not to label as positive a sample that is negative.

The recall is the ratio tp / (tp + fn) where tp is the number of true positives and fn the number of false negatives. The recall is intuitively the ability of the classifier to find all the positive samples.

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.

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:
score_metrics{“precision”: precision, “recall”: recall, “f1_score”: f1_score} or
{“s_1”: {“precision”: precision, … }, “s_2”: {“recall”: recall, … }, “s_3”: {“f1_score”: f1_score, … }}

Dictionary of precision scores or a dictionary with the keys as the sensor names and the values as dictionaries with the scores.

See also

gaitmap.evaluation_utils.evaluate_segmented_stride_list

Generate matched_df from stride lists

Examples using gaitmap.evaluation_utils.precision_recall_f1_score#

Grid Search optimal Algorithm Parameter

Grid Search optimal Algorithm Parameter

Grid Search optimal Algorithm Parameter
Cross Validation

Cross Validation

Cross Validation
GridSearchCV

GridSearchCV

GridSearchCV