fix(ml): add validation for matching dataSet and labels lengths in kNN - #2201
Open
loulanyue wants to merge 1 commit into
Open
fix(ml): add validation for matching dataSet and labels lengths in kNN#2201loulanyue wants to merge 1 commit into
loulanyue wants to merge 1 commit into
Conversation
lisagorewitdecker
approved these changes
Aug 24, 2026
|
that amzing great work gays pull request approved
…On Mon, 24 Aug 2026 at 20:18, lisagorewitdecker ***@***.***> wrote:
***@***.**** approved this pull request.
—
Reply to this email directly, view it on GitHub
<#2201?email_source=notifications&email_token=BQJZEWGJQKQUWCQ5JY3E6P35LRIUBA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTKMBQHEYDOOJXGQ32M4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#pullrequestreview-5009079747>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BQJZEWFH7UIVGGQ7GL3SKV35LRIUBAVCNFSNUABFKJSXA33TNF2G64TZHMYTENRVG43TENRQHNEXG43VMU5TKMRTGIZDOOJRHE3KC5QC>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***
com>
|
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
In
src/algorithms/ml/knn/kNN.js:dataSet.length !== labels.length, calculating distances and pickinglabels[i]can produceundefinedlabels which participate in voting and cause incorrect classification outputs.dataSet.length === labels.lengthupfront with a clear, descriptive error and adds corresponding unit tests.