Metrics
Screening metrics: confusion counts, precision, recall, and F-beta.
The paper reports the F2-score, weighting recall, because a screening step is allowed to over-select but must not drop a truly active variable.
ScreeningScores
dataclass
Confusion counts and derived scores for one selected set.
as_dict()
Flat mapping, convenient for tables.
confusion(selected, active, p)
True/false positive and negative counts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selected
|
ArrayLike
|
Indices chosen by the screener. |
required |
active
|
ArrayLike
|
Indices of variables with nonzero true coefficients. |
required |
p
|
int
|
Total number of predictors. |
required |
fbeta_score(precision, recall, beta=2.0)
Weighted F-score of specification Section 7.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
precision
|
float
|
In |
required |
recall
|
float
|
In |
required |
beta
|
float
|
Recall weight. The paper uses |
2.0
|
precision_recall(tp, fp, fn)
Precision and recall, defined as 0 when the denominator is 0.
screening_scores(selected, active, p, *, beta=2.0)
End-to-end metric bundle used in the paper's tables.
Examples:
>>> from tppis.metrics import screening_scores
>>> s = screening_scores([0, 1, 4], [0, 1, 2], p=10, beta=2)
>>> round(s.fbeta, 3)
0.714
selection_indicators(selected, variables)
0/1 indicators for whether each listed variable was selected.