Skip to content

fix: preserve unobserved causes in accuracy_in_time - #51

Merged
rich-iannone merged 1 commit into
rich-iannone:mainfrom
ability-spec:fix/accuracy-unobserved-causes
Oct 9, 2026
Merged

rich-iannone merged 1 commit into
rich-iannone:mainfrom
ability-spec:fix/accuracy-unobserved-causes

Conversation

@ability-spec

@ability-spec ability-spec commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

accuracy_in_time() counts only observed event causes when validating prediction arrays, although the cause axis must follow the response's declared states. With states ("relapse", "death") and only death events (code 2), it rejects valid two-cause predictions. A compressed one-cause array is instead accepted and can return an incorrect accuracy.

Use Surv.states when available to preserve cause codes across subsets, retain the existing single-event fallback, and clarify the docstring. Add five regression cases for missing first/middle/last causes, all-censored data, and rejection of compressed cause axes.

Validation

  • All five new cases fail on the original implementation.
  • Metrics and Outcome suites: 146 passed.
  • Full Python suite: 2,367 passed, 16 skipped, 5 warnings.
  • Ruff lint/format and Pyright passed.

The full suite ran with two workers and coverage from python/. Existing skips include optional great-tables visualizations and dependency-specific forest paths. No estimator formulas or R-generated fixtures changed.

Checklist

  • Python checks passed: Ruff, Pyright, and pytest.
  • Regression tests added.
  • Docstring updated.

R-parity fixture changes are not applicable: this fixes cause-axis validation without changing estimator formulas.

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement, thanks!

@rich-iannone
rich-iannone merged commit d567b75 into rich-iannone:main Oct 9, 2026
16 checks passed
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.

2 participants