tumourkit.classification.evaluate.compute_metrics

tumourkit.classification.evaluate.compute_metrics(nodes_df: DataFrame, draw_on: str | None = None, method_name: str | None = 'Method') Dict[str, float]

Computes various evaluation metrics based on the provided predictions and ground truth labels.

This function computes the following metrics:
  • Accuracy

  • F1-score

  • ROC AUC

  • Expected Calibration Error (ECE)

  • Percentage error

The input DataFrame must contain the following columns:
  • ‘class’: The ground truth labels (1 for negative, 2 for positive).

  • ‘prob1’: The predicted probabilities for the positive class.

Optionally, a reliability diagram can be generated and saved to a file specified by ‘draw_on’. The ‘method_name’ parameter is used for the legend in the reliability diagram.

Parameters:
  • nodes_df (pd.DataFrame) – The DataFrame containing the predictions and ground truth labels.

  • draw_on (Optional[str]) – The file path to save the reliability diagram (without extension), defaults to None.

  • method_name (Optional[str]) – The name of the method for the reliability diagram legend, defaults to ‘Method’.

Returns:

A dictionary containing the computed metrics.

Return type:

Dict[str, float]