Distance-Based Methods in Supervised Learning :
Distance-based methods are a class of algorithms in supervised learning that use the
distance between data points to make predictions. These methods are often used for
classification and regression tasks. The four primary distance measures
[Link] Distance
2. Euclidean distance
3. Manhattan distance
4. Minkowski distance
Hamming Distance
● Measures the number of positions where two strings of equal length differ.
● Ideal for comparing binary data, such as strings with 0s and 1s.
● Counts the positions where two strings have different values and divides by the total
number of positions.
● Commonly used in classification tasks where binary features are involved.
● Only works for strings or data of the same length, limiting its usage to specific types
of problems.
Euclidean Distance
● The straight-line distance between two points in space.
● Suitable for continuous data, commonly used in clustering and nearest neighbor
algorithms.
● Works well in situations where you want to measure direct physical distance.
● Sensitive to scale—if one feature has a larger range than others, it can dominate the
calculation.
Manhattan Distance
● Measures the distance between two points by only moving along horizontal and
vertical lines.
● Suitable for grid-like structures, such as when navigating through a city or in 2D
matrix-based systems.
● Often used in cases where straight-line movement is restricted.
● Less precise for diagonal movements—it can be misleading in situations where
diagonal movement is allowed.
Minkowski Distance
● A generalized distance metric that includes both Euclidean and Manhattan distances
as special cases.
● Offers flexibility depending on the value of p—when p = 1, it’s Manhattan distance;
when p = 2, it’s Euclidean distance.
● Useful when you need to experiment with different distance measures.
● Computational complexity increases with higher values of p, which can make it
slower for large datasets.
● three types of Minkowski Distance are