pkg_pyknnclassifier.calculate_distance
Module Contents
Functions
|
This function calculates the Euclidean distance between two observations for the KNN model to find the similarity score. |
- pkg_pyknnclassifier.calculate_distance.calculate_distance(obs_1, obs_2, method='Euclidean')[source]
This function calculates the Euclidean distance between two observations for the KNN model to find the similarity score.
- Parameters:
obs_1 (array) – An array containing the features of the first observation.
obs_2 (array) – An array containing the features of the second observation.
method (str, optional) – The distance metric to use. Default is “Euclidean”. Possible values: “Euclidean”, “Manhattan”, “Chebyshev”.
- Returns:
Float representing a euclidean distance between two observations.
- Return type:
float
Examples
obs_1 = [0.81, 0.2, -0.86, 0.08] obs_2 = [-0.39, 0.24, -0.77, 0.17] dist = calculate_distance(obs_1, obs_2) print(f”Euclidean Distance between two observations is {dist}”)