Skip to content

Add ordered_complement helper, vectorize diff branch, and tweak vignette headers#138

Merged
OVVO-Financial merged 1 commit into
mainfrom
codex/profile-nns_boost-and-dy_d-functions
Jul 21, 2026
Merged

Add ordered_complement helper, vectorize diff branch, and tweak vignette headers#138
OVVO-Financial merged 1 commit into
mainfrom
codex/profile-nns_boost-and-dy_d-functions

Conversation

@OVVO-Financial

Copy link
Copy Markdown
Owner

Motivation

  • Avoid the cost and ordering effects of np.setdiff1d in resampling code while preserving the original index order for training/validation splits.
  • Improve performance and clarity of the vector-branch reduction in _dy_d_best_plan by removing looped index bookkeeping and using array reshaping and vectorized operations.
  • Clean up vignette headers to better reflect the source R markdown filenames.

Description

  • Add src/nns/_indices.py implementing ordered_complement(all_index, excluded) which returns the values of all_index not present in excluded while preserving input order.
  • Replace usages of np.setdiff1d(all_index, ...) with ordered_complement in src/nns/boost.py and src/nns/stack.py for training/validation index construction.
  • Refactor the vector branch in src/nns/diff.py::_dy_d_best_plan to compute per-group means by reshaping the prediction block and compute First and Second arrays with vectorized arithmetic, removing position/ids bookkeeping and looped element-wise aggregation.
  • Update vignette scripts (examples/vignettes/03_correlation_and_dependence.py and 04_normalization_and_rescaling.py) to adjust header comments and docstrings and tidy imports.
  • Add unit test tests/invariants/test_indices.py asserting that ordered_complement preserves the source index order.

Testing

  • Ran the new unit test pytest tests/invariants/test_indices.py and it passed.

Codex Task

@OVVO-Financial
OVVO-Financial merged commit 372c655 into main Jul 21, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant