Skip to content

Classifier: keep feature values at the training minimum in the first bin - #1267

Open
cindykrafft wants to merge 1 commit into
MouseLand:mainfrom
cindykrafft:fix/classifier-bin-clip
Open

Classifier: keep feature values at the training minimum in the first bin#1267
cindykrafft wants to merge 1 commit into
MouseLand:mainfrom
cindykrafft:fix/classifier-bin-clip

Conversation

@cindykrafft

Copy link
Copy Markdown

Classifier._get_logp clamps each feature to the training range and bins it with np.digitize(x, grid, right=True) - 1. For x == 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 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); compact and npix_norm wrap 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

_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants