K nearest neighbors Algorithm
This commit adds K-nearest neighbors Algorithm.
Important points regarding Commit:
- Euclidean distance is used to compute the distance between 2 points.
- Only classification has been implemented by using majority vote amongst k nearest neighbors for an input point
- An Enum has been created for distance computation so that it can be extended to other distance computation techniques/formulae like Manhattan Distance, etc.
- Classification Label is of type 'String'.
Pull Request Template
Description
Please include a summary of the change and which issue (if any) is fixed. A brief description of the algorithm and your implementation method can be helpful too. If the implemented method/algorithm is not so well-known, it would be helpful to add a link to an article explaining it with more details.
Type of change
Please delete options that are not relevant.
- [ Y] New feature (non-breaking change which adds functionality)
Checklist:
- [ Y] I ran bellow commands using the latest version of rust nightly.
- [ Y] I ran
cargo clippy --all -- -D warningsjust before my last commit and fixed any issue that was found. - [ Y] I ran
cargo fmtjust before my last commit. - [Y ] I ran
cargo testjust before my last commit and all tests passed. - [ Y] I added my algorithm to the corresponding
mod.rsfile within its own folder, and in any parent folder(s). - [ Y] I added my algorithm to
DIRECTORY.mdwith the correct link. - [ Y] I checked
COUNTRIBUTING.mdand my code follows its guidelines.
Please make sure that if there is a test that takes too long to run ( > 300ms), you #[ignore] that or
try to optimize your code or make the test easier to run. We have this rule because we have hundreds of
tests to run; If each one of them took 300ms, we would have to wait for a long time.
Codecov Report
Attention: Patch coverage is 99.56897% with 1 line in your changes missing coverage. Please review.
Project coverage is 95.07%. Comparing base (
0b8ba06) to head (56bd101).
| Files | Patch % | Lines |
|---|---|---|
| ...chine_learning/optimization/k_nearest_neighbors.rs | 99.56% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #723 +/- ##
==========================================
+ Coverage 95.02% 95.07% +0.04%
==========================================
Files 303 304 +1
Lines 22577 22809 +232
==========================================
+ Hits 21454 21685 +231
- Misses 1123 1124 +1
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hi , i made the changes suggested. Let me know if there is anything else that's needed :)
This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our Gitter channel. Thank you for your contributions!