feat: exponential-scale and Weibull survival losses (v0.1.2) - #22
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NegloglikExponentialScaleandNegloglikWeibull(pypsps/keras/neglogliks.py), parameterized bylog_scale(mean survival time, andlog_shapefor Weibull) instead oflog_rate/log_hazard, for more numerically stable gradients. Both NLL formulas verified againsttfp.distributions.Exponential/Weibull(log_prob/log_survival_function).NegloglikExponential/NegloglikExponentialScale/NegloglikWeibullas Keras-serializable; fix a latent bug whereNegloglikExponentialhad noget_config(), so itslog_rateflag would silently reset toFalseon save/load.inference._state_conditional_outcome_meansopredict_ute_binary/predict_ute_continuous/predict_ate_binary/predict_ate_continuouswork with them instead of raisingNotImplementedError.0.1.2, addCHANGELOG.mdentry.Test plan
pytest pypsps/tests— 84 passed, 3 skipped_negloglik_exponential_scale/_negloglik_weibulland theNegloglikExponentialScale/NegloglikWeibullloss classes (event/censored terms, reduction modes, cross-checks againsttfp.distributions, Weibull-reduces-to-exponential-at-shape-1 sanity check)_state_conditional_outcome_mean's exponential-scale/Weibull casesget_config/from_config) across all three registered losses