Skip to content

Add opt-in build_knn flag to skip the unused kNN graph#1

Open
IsabelThompson97 wants to merge 1 commit into
ZuckermanLab:mainfrom
IsabelThompson97:guards-for-upstream
Open

Add opt-in build_knn flag to skip the unused kNN graph#1
IsabelThompson97 wants to merge 1 commit into
ZuckermanLab:mainfrom
IsabelThompson97:guards-for-upstream

Conversation

@IsabelThompson97

Copy link
Copy Markdown

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 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; If smoothing is later requested on an instance built without the graph, smooth_weights_knn then raises a clear error if smoothing is later requested, so the build-time and run-time switches cannot silently disagree.

Behavior / compatibility

  • Default (build_knn=True): identical to today — the graph is always built. No existing caller is affected.
  • Opt-in (build_knn=False): the graph is skipped and knn_indices is None. If smooth_weights_knn is then called with smoothing_factor_nn > 0, it raises RuntimeError with a message pointing to build_knn=True.
  • No change to reweighting results, output files, or any other part of the API.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant