caelum0x 174222bcaa feat: Builder-Track named-user tools, bio + evidence-intelligence platform, Apache-2.0
Builds PaperTrail from the base skeleton into a full evidence-verification platform
for the "Built with Claude: Life Sciences" hackathon (Builder Track).

New named-user features (Build Beyond the Bench):
- Lab Notebook Companion — rough bench notes -> structured, searchable, grounded
  experiment records (lib/labNotebook, /console/lab-notebook, migration 0059)
- Clinical Trial Matcher — de-identified patient notes -> ranked eligible
  ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning
  (lib/trialMatcher, /console/trial-matcher, migrations 0060)

Platform:
- Deterministic verification moat (biostats recompute, exact-span grounding)
- 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar,
  PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier)
- Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise
  governance (RBAC, /api/v1 gateway, metering, audit chain, retention)
- 17 OSS projects assimilated into native TypeScript on our stack (backend/engines
  retained + credited in NOTICE)
- Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site
- Next.js 16 upgrade, benchmark harness (honest smoke-test caveat)

Licensing: Apache-2.0 (LICENSE + NOTICE).
2026-07-10 16:23:13 +03:00

53 lines
1.8 KiB
Python

import numpy as np
import pytest
from sklearn.utils import compute_sample_weight
from sklearn.utils.estimator_checks import check_estimator
from asreview.extensions import extensions
from asreview.extensions import load_extension
from asreview.models.balancers import Balanced
def test_balancers():
assert len(extensions("models.balancers")) >= 1
@pytest.mark.parametrize("balancer", extensions("models.balancers"))
def test_balance_model_name(balancer):
model = load_extension("models.balancers", balancer.name)()
assert model.name == balancer.name
@pytest.mark.parametrize("balancer", extensions("models.balancers"))
def test_balance_model_param(balancer):
model = load_extension("models.balancers", balancer.name)()
assert isinstance(model.get_params(), dict)
@pytest.mark.parametrize("balancer", extensions("models.balancers"))
@pytest.mark.skip(reason="Check estimator is not working for balance models.")
def test_balance_check_estimator(balancer):
model = load_extension("models.balancers", balancer.name)()
assert check_estimator(model)
def test_balanced():
y = np.random.randint(0, 2, 100)
balancer = Balanced()
# Check that ratio=1.0 gives the same as the 'balanced' setting of
# `compute_sample_weight`.
assert np.allclose(
compute_sample_weight("balanced", y), balancer.compute_sample_weight(y)
)
for ratio in [0.25, 1, 5, 10]:
balancer = Balanced(ratio=ratio)
sample_weight = balancer.compute_sample_weight(y)
# Check that the sample weight is normalized to the length of y.
assert round(sum(sample_weight)) == len(y)
# Check that (total weight 1's) / (total weight 0's) is equal to the ratio.
assert sum(sample_weight[y == 1]) / sum(sample_weight[y == 0]) - ratio < 10 ** (
-5
)