Skip to content

[TOP 10] Implement K-Nearest Neighbors (kNN) Classifier #23

@noahgift

Description

@noahgift

🔥 TOP 10 Priority - Most popular ML algorithm #6

Overview

Implement K-Nearest Neighbors (kNN) for classification, one of the most widely-used instance-based learning algorithms.

Implementation Details

  • Distance metrics: Euclidean, Manhattan, Minkowski
  • Weighted vs unweighted voting
  • Efficient neighbor search (brute force initially, KD-tree later)
  • Cross-validation for optimal k selection

References

  • Instance-based learning algorithm
  • Non-parametric method
  • Simple yet effective baseline

Acceptance Criteria

  • KNN struct with fit/predict
  • Distance metric selection
  • Weighted voting option
  • Comprehensive tests (EXTREME TDD)
  • Example: knn_iris.rs
  • Book chapter: ml-fundamentals/knn.md

Priority Justification

kNN is #6 in industry usage per Analytics Vidhya 2025 ranking

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions