Classifier: keep feature values at the training minimum in the first bin - #1267
Open
cindykrafft wants to merge 1 commit into
Open
Classifier: keep feature values at the training minimum in the first bin#1267cindykrafft wants to merge 1 commit into
cindykrafft wants to merge 1 commit into
Conversation
_get_logp clamps feature values to the training range and then bins them with np.digitize(x, grid, right=True) - 1. For x equal to grid[0] (every value at or below the training minimum, and NaNs, which are set to grid[0]) digitize returns 0, so the bin index becomes -1 and the probability of the *last* bin is used. A ROI whose skew is at or below the training minimum was therefore scored with the highest-skew bin's probability (builtin classifier: P(cell) 0.986 instead of 0.535), and the analogous wrap applies to compact and npix_norm. Clip the bin index to the valid range. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7
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.
Classifier._get_logpclamps each feature to the training range and bins it withnp.digitize(x, grid, right=True) - 1. Forx == grid[0]— every value at or below the training minimum, and NaNs, which are set togrid[0]—digitizereturns 0, so the bin index is -1 and the probability of the last bin is used. With the builtin classifier, a ROI whose skew is below the training minimum is scored with the highest-skew bin (P(cell) 0.986 instead of 0.535);compactandnpix_normwrap the same way.This clips the bin index to the valid range. On the builtin classifier's own training set 0.4 % of ROIs are at a feature minimum and no 0.5-threshold verdict changes; user-trained classifiers, fit on far fewer ROIs, hit their minima more often. Reproduction: https://github.com/cindykrafft/research-software-audit/blob/main/audits/suite2p/verify/s1_classifier_bins.py
🤖 Generated with Claude Code
https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7