Enrichment factor, RIE and BEDROC from the ranks of the actives
score_early_recognition
Works out the enrichment factor at a stated cut, and RIE and BEDROC at a stated alpha, from actives' ranks.
- Runs
- On the server
- Level
- Checked against a reference: exact arithmetic (Python fractions; exponentials at 60 digits), checked against RDKit 2026.03.6 and the structural cases
What it is
Returns the enrichment factor at a stated cut, and RIE and BEDROC at a stated alpha, from the ranks of the actives. Use when a model or a virtual screen has ranked a list and early recovery of the actives is the question; give the cut, alpha or both. Not for the ROC curve or its area: use `stats_roc_curve`; not for counts at one threshold: use `score_binary_classification`. Ranks are distinct whole numbers from 1, the best; an alpha outside 1 to 500 is refused; BEDROC is withheld when every item is active.
Field: Statistics and design.
What it does
You give
total(required): The number of items in the ranked list, actives and inactives together. Must be at least 1 and at most 9007199254740991.activeRanks(required): The rank of each active: distinct whole numbers from 1, the best-scored item, to the total, in any order. You break ties before calling.topCount: The cut for the enrichment factor, as a count of top-ranked items (for the top 1 % of 1,000, give 10). Never assumed. Must be at least 1 and at most 9007199254740991. Optional.alpha: The early-recognition weight for RIE and BEDROC, from 1 to 500. Never assumed. Must be above 0. Optional.
No request is recorded for this tool.
Limits
- Research arithmetic scoring predictions against outcomes you supply; it does not judge a model, choose a threshold or know whether the cases were held out, and is not for diagnosis or treatment decisions.
- Scores from the ranks you supply, rank 1 the best-scored item; ties are yours to break, and the rule changes the result.
- Values compare only between lists with the same alpha, cut and a similar fraction of actives.
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.
It will not answer when
- alpha is outside the range the method was checked over.
- neither a top count nor alpha is given: there is nothing to compute, and neither is ever defaulted.
- a rank is above the number of items in the list.
- two actives are given the same rank: ties are the caller's to break; checked at each rank after the whole-number and RANK_ABOVE_TOTAL checks.
Every input, with its units4 inputs
total(required): The number of items in the ranked list, actives and inactives together. Must be at least 1 and at most 9007199254740991.activeRanks(required): The rank of each active: distinct whole numbers from 1, the best-scored item, to the total, in any order. You break ties before calling.topCount: The cut for the enrichment factor, as a count of top-ranked items (for the top 1 % of 1,000, give 10). Never assumed. Must be at least 1 and at most 9007199254740991. Optional.alpha: The early-recognition weight for RIE and BEDROC, from 1 to 500. Never assumed. Must be above 0. Optional.
Every refusal, with its code5 refusals
| Code | When |
|---|---|
ALPHA_OUTSIDE_RANGE | alpha is outside the range the method was checked over. |
TOP_COUNT_OR_ALPHA_REQUIRED | neither a top count nor alpha is given: there is nothing to compute, and neither is ever defaulted. |
RANK_ABOVE_TOTAL | a rank is above the number of items in the list. |
DUPLICATE_RANK | two actives are given the same rank: ties are the caller's to break; checked at each rank after the whole-number and RANK_ABOVE_TOTAL checks. |
TOP_COUNT_ABOVE_TOTAL | the top count is above the number of items in the list. |
The calculation
The method's equations, constants and worked example.
Equation 1
| Symbol | Meaning |
|---|---|
N | the number of items in the ranked list (argument total) |
n | the number of actives, the length of argument activeRanks |
r_i | the rank of the i-th active, a whole number from 1 (the best-scored item) to N (argument activeRanks) |
t | the cut, as a count of top-ranked items (argument topCount); the source writes it χ·N |
a | the number of actives whose rank is at most t, returned as activesInTop |
EF | enrichment factor, returned as enrichmentFactor |
Source 1.
Equation 2
| Symbol | Meaning |
|---|---|
N | the number of items in the ranked list (argument total) |
n | the number of actives, the length of argument activeRanks |
r_i | the rank of the i-th active, a whole number from 1 (the best-scored item) to N (argument activeRanks) |
α | the early-recognition weight: larger values weight the top of the list more (argument alpha) |
RIE | robust initial enhancement, returned as robustInitialEnhancement; 1 for actives placed at random |
Source 1.
Equation 3
| Symbol | Meaning |
|---|---|
N | the number of items in the ranked list (argument total) |
n | the number of actives, the length of argument activeRanks |
α | the early-recognition weight: larger values weight the top of the list more (argument alpha) |
RIE_min | RIE with every active at the bottom of the list |
RIE_max | RIE with every active at the top of the list |
Source 1.
Equation 4
BEDROC = (RIE − RIE_min)/(RIE_max − RIE_min)
| Symbol | Meaning |
|---|---|
RIE | robust initial enhancement at the same alpha |
RIE_min | its smallest possible value for this n and N |
RIE_max | its largest possible value for this n and N |
BEDROC | RIE rescaled to run from 0 to 1, returned as bedroc; undefined when n = N |
Source 1.
A definition, not a model: the equation states what the quantity means. A different convention gives a different number.
Worked example
Worked example: one case of score-early-recognition@2.0.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- total = 10
- activeRanks.values[0] = 1
- activeRanks.values[1] = 3
- activeRanks.values[2] = 8
- activeRanks.unit = 1
- topCount = 3
- alpha = 2
Steps
- activesInTop = 2, from activeRanks, topCount; by equation 1; gives activesInTop.
- activeFraction = 0.3, from activeRanks, total; by equation 1.
- ef = 2.2222222, from activesInTop, topCount, activeFraction; by equation 1; gives enrichmentFactor.
- weightSum = 1.5694389, from activeRanks, total, alpha; by equation 2.
- randomSum = 1.1716178, from activeFraction, alpha, total; by equation 2.
- rie = 1.3395485, from weightSum, randomSum; by equation 2; gives robustInitialEnhancement.
- rieMin = 0.42892032, from activeFraction, alpha; by equation 3.
- rieMax = 1.7393577, from activeFraction, alpha; by equation 3.
- bedroc = 0.69490403, from rie, rieMin, rieMax; by equation 4; gives bedroc.
The working, as the case writes it:
n = 3 actives among N = 10
2 of them rank in the top 3, so EF = (2/3)/(3/10) = 2.2222222
Σ e^(−α·r/N) = 0.81873075 + 0.54881164 + 0.20189652 = 1.5694389
the random sum (n/N)(1 − e^(−α))/(e^(α/N) − 1) = 1.1716178
RIE = 1.3395485
RIE_min = 0.42892032, RIE_max = 1.7393577
BEDROC = (1.3395485 − 0.42892032)/(1.7393577 − 0.42892032) = 0.69490403 (worked by hand by Drybench on 12 November 2026, the same author as this script)
Answer
activesInTop = 2
enrichmentFactor = 2.2222222
robustInitialEnhancement = 1.3395485
bedroc = 0.69490403
Where these values came from: our own exact-arithmetic script and a hand-worked case; stored reference values (fractions; 60-digit decimal exponentials).
At build the tool returned this answer within the tolerance the file states: the enrichment factor, RIE and BEDROC relative 1e-12, with a floor of 1e-15 below 1e-3; the count of actives in the top, statuses, codes, withholding rules and units exact.
Sources
Riniker S, Landrum GA, Open-source platform to benchmark fingerprints for ligand-based virtual screening, J Cheminform 5:26 (2013)
Used for: Enrichment factor, robust initial enhancement and BEDROC of a ranked list. At: equation 2, section Evaluation methods, Enrichment Factor (EF); equation 4, section Evaluation methods, Robust Initial Enhancement (RIE); equation 5 and 6, section Evaluation methods, Robust Initial Enhancement (RIE), at its end; equation 7, section Evaluation methods, Boltzmann-Enhanced Discrimination of ROC (BEDROC).
Read in full, 12 November 2026
How it is checked
- Level
Checked against a reference.
- Checked against
Our own exact-arithmetic script and a hand-worked case.
- Cases
No case set is linked to this version.
- Not checked
Truchon and Bayly (2007), the primary source of RIE's closed form and of BEDROC, unread; how the caller broke ties; alpha outside the range; the interpretation of BEDROC as a probability, which its authors tie to a condition on alpha and the fraction of actives; RDKit's scoring module is maintained by an author of the read source, so agreement with it does not test the reading of that source separately.
Changes to its methods1 change
- 14 November 2026, score-early-recognition@2.0.0: In 2.0.0 BEDROC is formed as A/(A + B), two compensated sums of non-negative terms equal to Eq. 7 (the identity held against Eq. 7 at 60 digits on every case), so it lies between 0 and 1, is exactly 0 with the actives in the last ranks and exactly 1 with them in the first; each exponential's argument is carried beyond double precision. BEDROC moved in its last bits in twelve of the 1.0.0 cases; stored reference values is retired and records what 1.0.0 computed.