[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enrichment factor returns empty list #7981

Open
j-adamczyk opened this issue Nov 3, 2024 · 0 comments
Open

Enrichment factor returns empty list #7981

j-adamczyk opened this issue Nov 3, 2024 · 0 comments
Labels

Comments

@j-adamczyk
Copy link

Describe the bug
Enrichment factor function CalcEnrichment returns empty list, when it should return something, e.g. raise error, or return 0.

To Reproduce

Note: of course those values and fraction 0.9 make no particular sense. This was discovered when writing tests for edge cases.

import numpy as np
from rdkit.ML.Scoring.Scoring import CalcEnrichment

y_score = np.array([0.0, 0.0, 0.0, 0.0, 1.0])
y_test = np.array([0, 0, 0, 1, 1])
fraction = 0.9

scores = sorted(zip(y_score, y_test), reverse=True)
e = CalcEnrichment(scores, col=1, fractions=[fraction])
print(e)

The code returns an empty list, i.e. e = [].

I suspect this part here

if i > (numPerFrac[0] - 1) and i > 0:
:

  for i in range(numMol):
    if i > (numPerFrac[0] - 1) and i > 0:
      enrich.append(1.0 * numActives * numMol / i)
      numPerFrac.pop(0)
    active = scores[i][col]
    if active:
      numActives += 1

  if numActives > 0:  # check that there are actives
    enrich = [e / numActives for e in enrich]

For code above, numActives is 2, but enrich list is empty. This results in empty list comprehension, and returning an empty list.

Expected behavior
Maybe an error? Or zero value. However, even for those weird values there should be some enrichment, since a single active was found.

Configuration (please complete the following information):

  • RDKit version: 2024.3.3
  • OS: Ubuntu 24.04
  • Python version (if relevant): 3.9.20
  • Are you using conda? no
  • If you are not using conda: how did you install the RDKit? pip
@j-adamczyk j-adamczyk added the bug label Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant