Skip to contents

Calculates comprehensive performance metrics for evaluating predicted network structures, including classification performance, precision-recall metrics, and network topology metrics.

Usage

calculate_metrics(
  network_table,
  ground_truth,
  metric_type = c("all", "auc", "auroc", "auprc", "precision", "recall", "f1",
    "accuracy", "si", "ji"),
  return_plot = FALSE,
  line_color = "#1563cc",
  line_width = 1
)

Arguments

network_table

A data frame.

ground_truth

A data frame of ground truth network with the same format as network_table.

metric_type

The type of metric to return. Default is "all". This can take any of the following choices:

  • all Returns all available metrics with Performance Metrics plot.

  • auc Returns both AUROC and AUPRC with their plots.

  • auroc Area Under ROC Curve with plot.

  • auprc Area Under Precision-Recall Curve with plot.

  • precision Proportion of correct predictions among positive predictions.

  • recall Proportion of actual positives correctly identified.

  • f1 Harmonic mean of precision and recall.

  • accuracy Overall classification accuracy.

  • si Set Intersection, counting correctly predicted edges.

  • ji Jaccard Index, measuring overlap between predicted and true networks.

return_plot

Whether to generate visualization plots. Default is FALSE.

line_color

Color for plot lines. Default is #1563cc.

line_width

Width for plot lines. Default is 1.

Value

A list containing:

  • metrics A data frame with requested metrics.

  • plot A plot object if return_plot = TRUE (optional).

Examples

data(example_matrix)
data("example_ground_truth")
network_table <- inferCSN(example_matrix)
#>  [2025-10-16 02:36:38] Running for <dense matrix>.
#>  [2025-10-16 02:36:38] Checking input parameters...
#>  [2025-10-16 02:36:38] Using `L0` sparse regression model
#>  [2025-10-16 02:36:38] Using 1 core
#>  [2025-10-16 02:36:38] Building results
#>  [2025-10-16 02:36:38] Run done.
calculate_metrics(
  network_table,
  example_ground_truth,
  return_plot = TRUE
)
#> $metrics
#>      Metric  Value
#> 1     AUROC  0.952
#> 2     AUPRC  0.437
#> 3 Precision  0.529
#> 4    Recall  1.000
#> 5        F1  0.692
#> 6       ACC  0.948
#> 7        JI  0.514
#> 8        SI 18.000
#> 
#> $plot

#> 
calculate_metrics(
  network_table,
  example_ground_truth,
  metric_type = "auroc"
)
#> $metrics
#>   Metric Value
#> 1  AUROC 0.952
#>