f1_score#
- mobgap.utils.evaluation.f1_score( ) float[source]#
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. Currently supported are dataframes resulting either from the evaluation of gait sequence detection algorithms (results from
categorize_intervals_per_sample), or from the evaluation of initial contact detection algorithms (results fromcategorize_ic_list). To be handled like a gait sequence detection evaluation dataframe, thematches_dfmust have columns “start”, “end”, and “match_type”. To be handled like an initial contact detection evaluation dataframe, thematches_dfmust have columns “ic_id_detected”, “ic_id_reference”, “match_type”. Thematch_typecolumn indicates the type of match: “tp” (true positive), “fp” (false positives), or “fn” (false negative) or “tn” (true negative). Any “tn” matches are ignored in the initial contact match dataframe, since they are not meaningful and normally not reported in this application.- 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: float
Value between 0 and 1.