[BUG] Fix probability mass loss and temporal alignment in _SksurvAdapter predict_proba function#990
Open
MurtuzaShaikh26 wants to merge 2 commits intosktime:mainfrom
Open
Conversation
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.
Reference Issues/PRs
Fixes #958
What does this implement/fix? Explain your changes.
The predict_proba method in _SksurvAdapter (used by estimators like
CoxPHSkSurv) calculated distribution weights via rawnp.diffignoring boundaries, resulting in massive probability drops and time regressions:[:-1], stripping context and effectively dragging all probability masses backwards in time to previous disconnected timesteps.**Proposed Solution:
This PR replaces
np.diffwith _clip_surv from _common.py which leverages _surv_diff (applyingprepend=1.0, append=0.0) handling both margin boundaries. This efficiently validates that every mass is conserved, monotonically scaled, and sums exactly to1.0. We also preserve the full unmodifiedunique_times_for perfectly matched event distribution timestamps.Verification Script
When tracking an estimator with survival probabilities[0.8, 0.5, 0.5]descending over timestamps[10.0, 20.0, 30.0]:Does your contribution introduce a new dependency? If yes, which one?
No.
What should a reviewer concentrate their feedback on?
np.diff/[:-1]replacement logic using _clip_surv to preserve the probability boundaries.dist.weights, timeline boundary assignments, and asserting total mass strictly evaluates to1.0.Did you add any tests for the change?
Any other comments?
N/A
PR checklist
For all contributions
For new estimators
python_dependenciestag