Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch:lib] Fix major kNN label scoring bug #187

Merged
merged 8 commits into from
Jun 7, 2022
Merged

[patch:lib] Fix major kNN label scoring bug #187

merged 8 commits into from
Jun 7, 2022

Conversation

eonu
Copy link
Owner

@eonu eonu commented Jun 7, 2022

Fixes #186 and generally improves the code in the KNNClassifier.

  • Split _find_nearest into two functions:

    • _find_k_nearest: Finds the label and weighting/score of the k nearest neighbors with numpy.argpartition.
    • _find_max_labels: Finds the labels out of the nearest k which had the highest total score.

    A major bug in finding the labels with the highest total score was spotted by @manisci (thanks!). This has now been fixed, and splitting the function into the two described above made it easier to write unit tests for kNN.

    Release notes for older versions will also be updated to include a warning about this bug.

  • Disabled progress bars for multi-processed kNN predictions due to rendering issues.

  • Added a _predict function for the logic of making a single prediction, and updated _chunk_predict to call _predict for each example.

  • Renamed _argmax to _multi_argmax for clarity.

@eonu eonu merged commit 7ad060a into dev Jun 7, 2022
@eonu eonu deleted the patch/knn-labels branch June 7, 2022 21:47
@eonu eonu mentioned this pull request Jun 26, 2022
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.

1 participant