Fix: Add missing sqrt to _euclidean_distance function #151
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The
_euclidean_distancefunction inpython/pathway/stdlib/ml/classifiers/_knn_lsh.pywas missing the square root operation, causing it to return squared Euclidean distances instead of actual Euclidean distances.Problem:
√((x₂-x₁)² + (y₂-y₁)²)np.sum((data_table - query_table) ** 2, axis=1)(missing sqrt)Impact:
knn_lsh_classifier_trainandknn_lsh_euclidean_classifier_trainHow has this been tested?
Created comprehensive test files:
test_old_buggy_code.py- Demonstrates the bug with multiple test casestest_new_fixed_code.py- Verifies the fix returns correct distancesTest cases validated:
Code review:
np.sqrt()wrapperTypes of changes
Related issue(s):
Checklist: