add youdens j - #233
Open
lshpaner wants to merge 2 commits into
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.
Youden and F1 aren’t the same criterion. F1 ignores true negatives entirely, Youden weights sensitivity and specificity equally, and Youden is the conventional operating-point choice in clinical prediction papers.
New function in
threshold_optimization.py, exported from__init__.py. Returns(threshold, None)so the tuple shape matchesfind_optimal_threshold_betaand existing call sites don't need special-casing. Beta doesn't exist for Youden, hence theNone.Vectorized over the threshold grid, so it's a single boolean broadcast instead of a loop. Uses strict
>to matchthreshold_tune.Raises if either input is empty, and raises if
yhas only one class, since J is undefined there. ReturningNaNinstead would let a broken threshold leak downstream into whatever's consuming it.Nothing existing changes. It's additive.
Tests
19 in
test_threshold_optimization.py. The three that matter:test_youden_maximizes_jreimplements J independently and checks nothing in the grid beats what got returnedtest_youden_imbalanced_gives_usable_operating_pointruns a 10% prevalence fixture and asserts the thing actually flags positives, which is the regression guard for the case abovetest_youden_single_classchecks it raises instead of quietly handing back NaNAdd
threshold_testing_rf_youden.pytesting script: