precision_score#

mobgap.utils.evaluation.precision_score(
matches_df: DataFrame,
*,
zero_division: Literal['warn', 0, 1] = 'warn',
) float[source]#

Compute the precision.

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

The best value is 1 and the worst value is 0. Precision can be also referred to as positive predictive value (PPV).

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 from categorize_ic_list). To be handled like a gait sequence detection evaluation dataframe, the matches_df must have columns “start”, “end”, and “match_type”. To be handled like an initial contact detection evaluation dataframe, the matches_df must have columns “ic_id_detected”, “ic_id_reference”, “match_type”. The match_type column 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:
precision_score: float

Value between 0 and 1.