Skip to content

fix(models): validate count, tweedie and beta LSS targets up front - #488

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/lss-target-support
Open

ChrisW09 wants to merge 1 commit into
mainfrom
fix/lss-target-support

Conversation

@ChrisW09

@ChrisW09 ChrisW09 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #487

Problem

LSS fit() validated target support only for poisson/negativebinom (non-negative) and gamma/inversegamma/lognormal (strictly positive). For the other families:

  • Fractional targets for the count families crashed mid-training with raw torch support errors, after preprocessing and model construction. So did negative zip targets and beta targets outside (0, 1). The previously fitted estimator was discarded on the way.
  • Negative tweedie targets trained silently.

Fix

_validate_target_array (deeptab/models/base.py) now also checks the count families, tweedie and beta:

Family Valid targets
poisson, negativebinom, zip non-negative integers (integer-valued floats are fine)
tweedie non-negative values
gamma, inversegamma, lognormal strictly positive (unchanged)
beta strictly inside (0, 1)

Violations raise DataError (family='…' requires … target values) during input validation, before any estimator state changes. This is the same path the positive-support families already used, so a failed call keeps the previous fitted model. y_val goes through the same check. Targets that were valid before are still accepted. The only behaviour change is that inputs which used to crash mid-training or train on invalid targets are now rejected up front.

Tests

  • tests/core/test_exceptions.py:
    • count families reject negative and fractional targets and accept integer-valued ints and floats;
    • tweedie rejects negatives and accepts zeros;
    • beta rejects 0, 1 and values outside the interval, and accepts values inside it.
  • tests/integration/test_estimator_input_validation.py: MLPLSS.fit raises DataError for each new case without building a data module or model.

19 of the 26 new cases fail on main; the 7 that pass are acceptance cases (valid targets that must keep working). All pass with this change.

dirichlet, whose targets must be positive proportions summing to one per row, is not checked here; it still fails during training on invalid targets.

Docs

docs/core_concepts/training_and_evaluation.md replaces the sentence that covered only the positive-support families with a table of the valid targets per family.

Checks

  • just test: 3262 passed, 46 skipped, 28 xfailed; coverage 91.29%
  • just docs: build succeeded (warnings treated as errors)
  • just check: all hooks passed (ruff, prettier, pyright)

_validate_target_array only checked poisson/negativebinom for
non-negative and gamma/inversegamma/lognormal for positive targets.
Fractional counts, negative zip targets and beta targets outside (0, 1)
crashed mid-training with raw torch support errors after the previous
model was discarded, and negative tweedie targets trained silently.
Count families now require non-negative integers, tweedie non-negative
values and beta values strictly between 0 and 1, all rejected with a
DataError before any estimator state changes.

Fixes #487
@ChrisW09
ChrisW09 force-pushed the fix/lss-target-support branch from 619ba6c to c791935 Compare October 21, 2026 23:01
@ChrisW09 ChrisW09 changed the title fix(models): validate LSS targets against every family's support fix(models): validate count, tweedie and beta LSS targets up front Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] LSS fit does not validate targets for zip, beta and tweedie, or integer counts, so invalid targets crash mid-training or train silently

1 participant