Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhancement : Manhattan Distance and Minkowski Distance for K Nearest Neighbours #13546

Open
Labels
enhancementThis PR modified some existing files
@Nachi2006

Description

Feature description

Description

The current implementation of the K-Nearest Neighbors (KNN) algorithm in machine_learning/k_nearest_neighbors/ uses the Euclidean Distance by default.

To enhance the algorithm's functionality and completeness, this issue proposes adding two additional distance metrics that are commonly used in the KNN algorithm:

  1. Manhattan Distance (L1 norm)
  2. Minkowski Distance (Lp norm), which is a generalized form that includes both Euclidean (p=2) and Manhattan (p=1) as special cases.

Proposed changes

  1. Modify the KNN implementation (k_nearest_neighbors.py or similar file) to include a new parameter, perhaps distance_metric (e.g., set to 'euclidean' by default), that accepts 'manhattan' and 'minkowski' as values.
  2. Implement the calculation for the Manhattan Distance.
  3. Implement the calculation for the Minkowski Distance, using an additional parameter p for the power (e.g., defaulting to p=2 if distance_metric is 'minkowski').
  4. Add comprehensive unit tests to ensure that the algorithm performs correctly when using these new distance metrics.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementThis PR modified some existing files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /