Skip to content

feat: exponential-scale and Weibull survival losses (v0.1.2) - #22

Merged
gmgeorg merged 1 commit into
mainfrom
feat/exp-scale-weibull-losses
Aug 23, 2026
Merged

gmgeorg merged 1 commit into
mainfrom
feat/exp-scale-weibull-losses

Conversation

@gmgeorg

@gmgeorg gmgeorg commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add NegloglikExponentialScale and NegloglikWeibull (pypsps/keras/neglogliks.py), parameterized by log_scale (mean survival time, and log_shape for Weibull) instead of log_rate/log_hazard, for more numerically stable gradients. Both NLL formulas verified against tfp.distributions.Exponential/Weibull (log_prob/log_survival_function).
  • Register NegloglikExponential/NegloglikExponentialScale/NegloglikWeibull as Keras-serializable; fix a latent bug where NegloglikExponential had no get_config(), so its log_rate flag would silently reset to False on save/load.
  • Wire both new losses into inference._state_conditional_outcome_mean so predict_ute_binary/predict_ute_continuous/predict_ate_binary/predict_ate_continuous work with them instead of raising NotImplementedError.
  • Bump version to 0.1.2, add CHANGELOG.md entry.

Test plan

  • pytest pypsps/tests — 84 passed, 3 skipped
  • New unit tests for _negloglik_exponential_scale/_negloglik_weibull and the NegloglikExponentialScale/NegloglikWeibull loss classes (event/censored terms, reduction modes, cross-checks against tfp.distributions, Weibull-reduces-to-exponential-at-shape-1 sanity check)
  • New unit tests for _state_conditional_outcome_mean's exponential-scale/Weibull cases
  • Serialization round-trip test (get_config/from_config) across all three registered losses

Adds NegloglikExponentialScale and NegloglikWeibull, parameterized by
log_scale (mean survival time) instead of log_rate/log_hazard for more
stable gradients; both verified against tfp.distributions.Exponential/
Weibull. Registers all three exponential/Weibull losses as
Keras-serializable and fixes a latent NegloglikExponential.get_config()
gap (log_rate flag would silently reset on save/load). Wires the two
new losses into inference._state_conditional_outcome_mean so
predict_ute_binary/predict_ute_continuous/predict_ate_* work with them.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WdB9JANd8VtZ8vGrpyUDpx
@gmgeorg
gmgeorg merged commit e567ead into main Aug 23, 2026
1 check 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.

1 participant