-
-
Notifications
You must be signed in to change notification settings - Fork 48.9k
Open
Labels
enhancementThis PR modified some existing filesThis PR modified some existing files
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:
- Manhattan Distance (L1 norm)
- Minkowski Distance (Lp norm), which is a generalized form that includes both Euclidean (p=2) and Manhattan (p=1) as special cases.
Proposed changes
- Modify the KNN implementation (
k_nearest_neighbors.pyor similar file) to include a new parameter, perhapsdistance_metric(e.g., set to 'euclidean' by default), that accepts 'manhattan' and 'minkowski' as values. - Implement the calculation for the Manhattan Distance.
- Implement the calculation for the Minkowski Distance, using an additional parameter
pfor the power (e.g., defaulting top=2ifdistance_metricis 'minkowski'). - Add comprehensive unit tests to ensure that the algorithm performs correctly when using these new distance metrics.
Metadata
Metadata
Assignees
Labels
enhancementThis PR modified some existing filesThis PR modified some existing files