Delower's picture
Upload validate.py with huggingface_hub
f389d38 verified
Raw History Blame Contribute Delete
1 kB
# validate.py — loads the shipped ExtraTrees deployment weights and
# reproduces the model's predictions on examples.json (8 DPP-4 leads
# screened with this exact model; expected probabilities stored
# alongside the SMILES). Exits non-zero if any reproduced probability
# deviates by > 1e-6 (the model is deterministic).
import json, os, sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
from infer import predict
examples = json.load(open(os.path.join(HERE, "examples.json")))
worst = 0.0
for ex in examples:
got = predict(ex["smiles"])
exp = ex["expected_Liver_ExtraTrees_deployment_prob"]
assert got is not None, f"unparseable example: {ex['lead_id']}"
dev = abs(got - exp)
worst = max(worst, dev)
print(f"{ex['lead_id']:>8} expected {exp:.6f} got {got:.6f} dev {dev:.2e}")
assert dev <= 1e-6, f"deviation too large for {ex['lead_id']}: {dev}"
print(f"VALIDATION PASSED — max deviation {worst:.2e} over {len(examples)} examples")