Repository navigation
11/ Classifier fixes: naive Bayes crossovers, Fisher score, kNN exact matches, previousSelection, ensemble selection, tuning warning - #135
Merged
Conversation
This was referenced Oct 10, 2026
ellispatrick
force-pushed
the
review/11-classifier-fixes
branch
from
October 10, 2026 22:47
7ffbc4b to
8244564
Compare
…ches, previousSelection, ensemble selection, resubstitution warning - naiveBayesKernel: crossover points use the class densities scaled by class size, the same densities as the vertical distances (changes results with weighting = "crossover distance"). - fisherDiscriminant: the score is centred on the critical value, so its sign gives the predicted class and scores from different fold models are comparable (classes unchanged). - kNNinterface (weighted): training samples at distance zero alone vote, equally, instead of a weight of 999999. - previousSelection matches the original feature names; SelectParams passes .iteration to it automatically. prepareData makes safe feature names unique, so "a-b" and "a.b" no longer collide. - .doSelection: ensemble selection (a list of ranking functions) works, with tuning of the number of features. - runTests warns once when resubstitution tuning finds several numbers of features with a perfect training fit. Decided by Ellis Patrick (ProjectClassifyR DECISIONS.md, 2026-10-10, Q13, Q22-Q24, Q26). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4
ellispatrick
force-pushed
the
review/11-classifier-fixes
branch
from
October 14, 2026 00:20
8244564 to
0b31f41
Compare
DarioS
marked this pull request as ready for review
October 28, 2026 02:36
DarioS
approved these changes
Oct 28, 2026
DarioS
left a comment
Member
There was a problem hiding this comment.
A couple of rare edge cases handled.
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.
Summary
Changes results only for naive Bayes with
weighting = "crossover distance"(4.7% of predictions on the asthma data). Every other change either fixes something that errored or leaves predictions unchanged: Fisher discriminant scores move but its classes don't, and weighted kNN changes only when a test sample is identical to a training sample. All 18 regression scenarios are identical to #134.Why
Ellis Patrick decided these on 2026-10-10 (ProjectClassifyR
DECISIONS.md, questions Q13, Q22–Q24, Q26):-aᵀx, not centred on the critical value. Its sign didn't match the predicted class, and scores from models trained on different folds sat on different offsets.make.names(). Different names with the same safe name ("g-1"and"g.1") matched the wrong column; such data actually stopped with "duplicate row.names". It also needed the user to know to setintermediate = ".iteration"..doSelectionused undefined variables (featuresLists,measurementsSubset,aResult), so it always failed.nFeaturesvalues fit the training set perfectly, the first is chosen silently. This is documented; the warning makes it visible.What changes
naiveBayesKernel: densities are scaled by class size once, and both the vertical distances and the crossover points use them. Withweighting = "height difference"(the default) predictions are unchanged.fisherDiscriminant: score = critical value −aᵀx, positive for the second class. Predicted classes are unchanged.kNNinterface(mode = "weighted"): if any of the k neighbours is at distance zero, those neighbours alone vote, equally. Otherwise the weights are 1/distance as before.previousSelectionmatches on the original feature names (mcols(measurements)$feature, kept byprepareData), or on assay + feature for multi-assay data.SelectParams("previousSelection", ...)adds the.iterationintermediate itself.prepareData,runTestandpredictmake safe feature names unique (make.names(unique = TRUE)), so colliding names no longer stop the run. Names that were already unique are unchanged.minPresencerankings. With severalnFeaturesvalues, n is tuned by resubstitution or nested CV like the single-ranking path, and the tuning table is stored.otherParamscan be one list per ranking function or shared by all of them.runTestswarns once per cross-validation, giving the number of training sets in which resubstitution tuning tied at a perfect fit, and suggeststuneMode = "Nested CV".Evidence
The naive Bayes change lowers balanced accuracy here. Scaling by class size moves the crossover towards the smaller class, so more samples near the boundary vote for the larger one. That is the consistent behaviour, but it is not an improvement on this data. Scripts: ProjectClassifyR
scripts/classifier_fixes/.R CMD check was not rerun for this PR; no documentation files changed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TfsjwkbDbHkX4kJZNe4ER4