sebp / scikit-survival

Survival analysis built on top of scikit-learn
GNU General Public License v3.0
1.14k stars 216 forks source link

Enhance _iter_comparable loop #465

Closed Vincent-Maladiere closed 4 months ago

Vincent-Maladiere commented 4 months ago

Checklist

What does this implement/fix? Explain your changes Hello @sebp!

The sksurv.metrics._iter_comparable function repeatedly creates a mask using np.zero, but this mask doesn't change for different elements j of the loop. Mallocs are computationally expensive, so this short PR proposes to reduce the number of calls to np.zero by creating the mask before the for-loop.

This will help make the c_index functions more efficient. WDYT?

cc @ogrisel

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.15%. Comparing base (03566f6) to head (2de9df5).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #465 +/- ## ======================================= Coverage 98.15% 98.15% ======================================= Files 37 37 Lines 3526 3526 Branches 539 539 ======================================= Hits 3461 3461 Misses 31 31 Partials 34 34 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codacy-production[bot] commented 4 months ago

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
:white_check_mark: +0.00% :white_check_mark:
Coverage variation details | | Coverable lines | Covered lines | Coverage | | ------------- | ------------- | ------------- | ------------- | | Common ancestor commit (03566f672b6075940a7d8722700c144412bf6d31) | 3526 | 3495 | 99.12% | | | Head commit (03566f672b6075940a7d8722700c144412bf6d31) | 3526 (+0) | 3495 (+0) | 99.12% (**+0.00%**) | **Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: ` - `
Diff coverage details | | Coverable lines | Covered lines | Diff coverage | | ------------- | ------------- | ------------- | ------------- | | Pull request (#465) | 0 | 0 | **∅ (not applicable)** | **Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `/ * 100%`

See your quality gate settings    Change summary preferences


:rocket: Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

sebp commented 4 months ago

Thanks a lot for the PR.

Sorry for initially messing up your commit, but it's merged with commit ecd6dadbbaf217cc1cf8974f5b904b71d727c67d now.

Vincent-Maladiere commented 4 months ago

Awesome, thanks!