Data Helpers¶
kriterion.data
¶
Correction
¶
Bases: StrEnum
Method for correcting extreme proportions (0s and 1s) in ROC data.
Extreme proportions produce infinite \(z\)-scores and must be adjusted
before converting to \(z\)-space. See Stanislaw & Todorov (1999) for reference
on these methods. The default value is INCREMENTAL.
| ATTRIBUTE | DESCRIPTION |
|---|---|
NONE |
No correction applied.
|
INCREMENTAL |
Adds i/k to each cumulative frequency and 1 to the total, where i is the bin index and k is the number of bins. Default.
|
LOGLINEAR |
Adds 0.5 to all frequencies and 1 to the total (Hautus, 1995).
|
EXTREME |
Corrects only 0s and 1s: 0 is corrected to 0.5/n, 1 is corrected to (n - 0.5)/n (Macmillan & Kaplan, 1985).
|
ROCData
¶
ROCData(
signal: list[int],
noise: list[int],
condition: str | None = None,
correction: Correction = INCREMENTAL,
)
Observed frequency counts for a rating-scale ROC experiment.
| PARAMETER | DESCRIPTION |
|---|---|
signal
|
Frequency counts per rating bin for signal trials.
TYPE:
|
noise
|
Frequency counts per rating bin for noise trials.
TYPE:
|
condition
|
Label for the experimental condition, by default None.
TYPE:
|
correction
|
Correction method for extreme proportions (0s and 1s),
by default
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
signal |
Frequency counts per rating bin for signal trials.
TYPE:
|
noise |
Frequency counts per rating bin for noise trials.
TYPE:
|
condition |
Label for the experimental condition.
TYPE:
|
correction |
Correction method applied when computing proportions.
TYPE:
|
n_signal |
Total number of signal trials.
TYPE:
|
n_noise |
Total number of noise trials.
TYPE:
|
signal_proportions |
Cumulative proportions for signal trials at each rating threshold.
TYPE:
|
noise_proportions |
Cumulative proportions for noise trials at each rating threshold.
TYPE:
|
z_signal |
\(z\)-transformed cumulative signal proportions.
TYPE:
|
z_noise |
\(z\)-transformed cumulative noise proportions.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
Source code in src/kriterion/data.py
compute_proportions
¶
compute_proportions(
arr: ndarray, correction: Correction = INCREMENTAL
) -> ndarray
Compute cumulative proportions from frequency counts.
| PARAMETER | DESCRIPTION |
|---|---|
arr
|
Frequency counts per rating bin, ordered from strongest signal to strongest noise.
TYPE:
|
correction
|
Correction method to apply to avoid 0s and 1s in the output,
by default
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ndarray
|
Cumulative proportions with the final 1.0 omitted (n - 1 values). |