feat: add mahalanobis_distance.py#14795
Closed
kasc0206 wants to merge 1 commit into
Closed
Conversation
Implement Mahalanobis distance metric with two functions: - mahalanobis_distance(point, mean, covariance): distance from a point to a distribution given a covariance matrix - mahalanobis_distance_from_sample(point, sample): estimate covariance from sample data and compute distance Includes comprehensive doctests, type hints, and error handling for dimension mismatch, singular matrices, and insufficient data.
Closing this pull request as invalid@kasc0206, this pull request is being closed as none of the checkboxes have been marked. It is important that you go through the checklist and mark the ones relevant to this pull request. Please read the Contributing guidelines. If you're facing any problem on how to mark a checkbox, please read the following instructions:
NOTE: Only |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add the Mahalanobis distance metric implementation to the
maths/directory.The Mahalanobis distance measures how many standard deviations away a point is from the mean of a distribution, taking into account the correlations between variables.
60114D_M(x) = \sqrt{(x - \mu)^T \Sigma^{-1} (x - \mu)}60114
Functions added
mahalanobis_distance(point, mean, covariance)— computes distance from a point to a distribution given a known covariance matrixmahalanobis_distance_from_sample(point, sample)— estimates the covariance matrix from sample data and computes the distanceFeatures
References