f1_score: F1 score

View source: R/metrics.R

f1_scoreR Documentation

F1 score

Description

Computes F1 score from two caugi::caugi objects. It converts the caugi::caugi objects to adjacency matrices and computes F1 score as 2 \cdot TP/(2 \cdot TP + FP + FN), where TP are true positives, FP are false positives, and FN are false negatives. If TP + FP + FN = 0, 1 is returned.

Only supports caugi::caugi objects whose edges are restricted to ⁠-->⁠, ⁠<->⁠, ⁠---⁠, or absence of an edge.

Usage

f1_score(truth, est, type = c("adj", "dir"))

Arguments

truth

A caugi::caugi object representing the truth graph.

est

A caugi::caugi object representing the estimated graph.

type

Character string specifying the comparison type:

  • "adj": adjacency comparison.

  • "dir": orientation comparison conditional on shared adjacencies.

Value

A numeric in [0,1].

See Also

Other metrics: confusion(), evaluate(), false_omission_rate(), fdr(), g1_score(), npv(), precision(), recall(), reexports, specificity()

Examples

cg1 <- caugi::caugi(A %-->% B + C)
cg2 <- caugi::caugi(B %-->% A + C)
f1_score(cg1, cg2, type = "adj")
f1_score(cg1, cg2, type = "dir")


causalDisco documentation built on April 13, 2026, 5:06 p.m.