Skip to content

[BUG] Correct probability mass and temporal alignment in _SksurvAdapter #958#970

Open
vishalsnghkush wants to merge 1 commit intosktime:mainfrom
vishalsnghkush:main
Open

[BUG] Correct probability mass and temporal alignment in _SksurvAdapter #958#970
vishalsnghkush wants to merge 1 commit intosktime:mainfrom
vishalsnghkush:main

Conversation

@vishalsnghkush
Copy link
Copy Markdown

@vishalsnghkush vishalsnghkush commented Mar 18, 2026

Fixes #958

This PR fixes mathematical errors in the predict_proba method of _SksurvAdapter. Previously, the resulting Empirical distributions were improper (weights summed to less than 1.0) and temporally shifted.

Changes:

  1. Initial Mass Preservation: Prepends a survival value of 1.0 to the survival function to capture the first drop from t=0.
  2. Tail Mass Preservation: Appended the remaining survival probability at the last time point to np.inf. This ensures the total mass always sums to 1.0.
  3. Alignment Correction: Fixed the logic where np.diff results were shifted. Probability drops are now correctly mapped to the timestamps where they occur.

Testing & Verification:
Verified using the reproduction script in Issue 958.

  • Before Fix: Total weight was less than 1.0.
  • After Fix: Total weight equals 1.0 and includes np.inf for censored mass.

…ter - Added boundary handling by prepending S(0)=1.0 to survival curves. - Appended remaining survival probability (tail mass) to np.inf. - Corrected temporal alignment of mass drops to match event times. - Resolves Issue sktime#958: weights now sum to 1.0.
@fkiraly fkiraly added bug module:survival&time-to-event module for time-to-event prediction aka survival prediction labels Mar 26, 2026
Copy link
Copy Markdown
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Can you comment why you did not use the _surf_diff function?

@fkiraly fkiraly changed the title [FIX] Correct probability mass and temporal alignment in _SksurvAdapter #958 [BUG] Correct probability mass and temporal alignment in _SksurvAdapter #958 Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug module:survival&time-to-event module for time-to-event prediction aka survival prediction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] _SksurvAdapter fails to preserve total probability mass and shifts distributions

2 participants