Repository navigation
Conversation
This branch has not been deployed
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.
Problem
Constant or heavily repeated embeddings can have a zero median pairwise distance. The embedding MMD method then passes
gamma=1/0to its RBF kernel, producing NaN entries and a NaN drift score. The same failure occurs in the bootstrap reference kernel when the reference embeddings are constant, even when the current embeddings differ.Change
Use the zero-bandwidth limit of the RBF kernel when the estimated squared bandwidth is exactly zero: equal vectors have kernel value 1 and distinct vectors have value 0. Group equal vectors with
np.unique, then compare their group labels, avoiding a samples-by-samples-by-features intermediate. Positive bandwidths keep the existingpairwise_kernelscalculation.Both the observed embedding kernel and its bootstrap reference kernel use this helper. This change is confined to
legacy/metrics/data_drift/embedding_drift_methods.py; it does not change the separate univariatemmd_stattest.pydistance calculation addressed in #1966.Validation
2 * (1 - exp(-1)).git diff --check, pass.The full repository suite and mypy were not run. This resolves undefined kernel values for degenerate bandwidths; it does not establish a general detection-quality improvement or change bootstrap sample-size policy.