Skip to content

Conversation

ngtduc693
Copy link
Contributor

Summary

K-Nearest Neighbors (KNN) classifier is a commonly used algorithm in Machine Learning/AI

Changes

  • Implement KNN algorithm
  • Unit test covering all code paths above
  • Update README to document the new algorithm

Unit Test Passed Evidence

image

Build Passed Evidence

image
  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

@ngtduc693 ngtduc693 force-pushed the feature/k-nearest-neighbors branch from fa3199f to a486ee2 Compare October 5, 2025 06:27
Copy link

codecov bot commented Oct 5, 2025

Codecov Report

❌ Patch coverage is 97.82609% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.68%. Comparing base (a8af880) to head (76400bd).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
Algorithms/MachineLearning/KNearestNeighbors.cs 97.82% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #542   +/-   ##
=======================================
  Coverage   96.67%   96.68%           
=======================================
  Files         279      280    +1     
  Lines       11013    11059   +46     
  Branches     1568     1577    +9     
=======================================
+ Hits        10647    10692   +45     
  Misses        232      232           
- Partials      134      135    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ngtduc693 ngtduc693 marked this pull request as ready for review October 5, 2025 06:40
@ngtduc693 ngtduc693 requested a review from siriak as a code owner October 5, 2025 06:40
@siriak siriak requested a review from Copilot October 5, 2025 21:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a K-Nearest Neighbors (KNN) classifier implementation to the machine learning algorithms collection. The implementation includes a generic classifier that can work with any label type and uses Euclidean distance for neighbor calculations.

  • Added a complete KNN classifier with proper error handling and validation
  • Comprehensive unit tests covering all code paths including edge cases and error conditions
  • Updated README to document the new algorithm in the machine learning section

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
README.md Added KNN entry to the machine learning algorithms list
Algorithms/MachineLearning/KNearestNeighbors.cs Complete KNN implementation with generic label support and Euclidean distance calculation
Algorithms.Tests/MachineLearning/KNearestNeighborsTests.cs Comprehensive test suite covering all functionality and error cases

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@siriak
Copy link
Member

siriak commented Oct 5, 2025

Please resolve Codacy issues

@ngtduc693
Copy link
Contributor Author

Please resolve Codacy issues

I'm done, thanks @siriak

@siriak siriak requested a review from Copilot October 6, 2025 06:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit c6c3aa2 into TheAlgorithms:master Oct 6, 2025
4 checks passed
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