Add opt-in build_knn flag to skip the unused kNN graph#1
Open
IsabelThompson97 wants to merge 1 commit into
Open
Add opt-in build_knn flag to skip the unused kNN graph#1IsabelThompson97 wants to merge 1 commit into
IsabelThompson97 wants to merge 1 commit into
Conversation
rite_weight_model always builds a NearestNeighbors graph in __init__ (fit + full N-point kneighbors query, held for the object's lifetime). On the default smoothing_factor_nn = 0 path that graph is built and never read, which is the dominant construction cost at large N. Add build_knn (default True, so existing behavior is unchanged). Pass build_knn=False to skip the graph when kNN smoothing is off; smooth_weights_knn then raises a clear error if smoothing is later requested, so the build-time and run-time switches cannot silently disagree.
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.
What
rite_weight_model always builds a NearestNeighbors graph in
__init__(fit + full N-point kneighbors query, held for the object's lifetime). On the defaultsmoothing_factor_nn = 0path that graph is built and never read, which is the dominant construction cost at large N.Add build_knn (default True, so existing behavior is unchanged). Pass
build_knn=Falseto skip the graph when kNN smoothing is off; If smoothing is later requested on an instance built without the graph,smooth_weights_knnthen raises a clear error if smoothing is later requested, so the build-time and run-time switches cannot silently disagree.Behavior / compatibility
build_knn=True): identical to today — the graph is always built. No existing caller is affected.build_knn=False): the graph is skipped andknn_indicesisNone. Ifsmooth_weights_knnis then called withsmoothing_factor_nn > 0, it raisesRuntimeErrorwith a message pointing tobuild_knn=True.