mobgap.initial_contacts.evaluation.calculate_matched_icd_performance_metrics#

mobgap.initial_contacts.evaluation.calculate_matched_icd_performance_metrics(
matches: DataFrame,
*,
zero_division: Literal['warn', 0, 1] = 'warn',
) dict[str, float | int][source]#

Calculate performance metrics for initial contact detection results.

This function assumes that you already classified the detected initial contacts as true positive (tp), false positive (fp), or false negative (fn) matches using the categorize_ic_list function. The dataframe returned by categorize function can then be used as input to this function.

The following metrics are calculated:

  • tp_samples: Number of samples that are correctly detected as initial contacts.

  • fp_samples: Number of samples that are falsely detected as initial contacts.

  • fn_samples: Number of samples that are not detected as initial contacts.

  • precision: Precision of the detected initial contacts.

  • recall: Recall of the detected initial contacts.

  • f1_score: F1 score of the detected initial contacts.

See the documentation of precision_recall_f1_score for more details about recall, precision, and F1 score.

Parameters:
matches: pd.DataFrame

A dataframe containing the matches between detected and reference initial contacts as output by evaluate_initial_contact_list.

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:
icd_metrics: dict

See also

categorize_ic_list

Function to create the input dataframe for this function from the detected and reference initial contacts.