Skip to content

feat(model_selection): PACF lag selection + search-space boundary helpers#214

Merged
bartzbeielstein merged 2 commits into
developfrom
feat/pacf-boundary
Jun 12, 2026
Merged

feat(model_selection): PACF lag selection + search-space boundary helpers#214
bartzbeielstein merged 2 commits into
developfrom
feat/pacf-boundary

Conversation

@bartzbeielstein

Copy link
Copy Markdown
Collaborator

Upstreams the team4 operational helpers (KB follow-up 2026-06-08-hyperparameter-boundary-management):

  • stats.autocorrelation.select_pacf_lags — significance-band top-k PACF lag pick (caller-supplied fallback or ValueError)
  • model_selection.boundaryreport_boundary_positions (get_params-style keys, log/return-only), boundary_report + suggest_bounds (promoted from the ch14 qmd prototypes; SpotOptim-result-style keys). Dual key convention documented at module level + runtime mismatch warning.
    Reviewed (2 blockers + 3 importants + 3 nits resolved). Full pipeline green incl. quarto render.

🤖 Generated with Claude Code

bartzbeielstein and others added 2 commits June 12, 2026 02:50
- stats/autocorrelation.py: add select_pacf_lags(), ported from
  bart26k-lecture/scripts/team4_4zones_submit.py (select_key_lags).
  Computes PACF up to n_lags, returns top_k significant lags sorted
  ascending; falls back to caller-supplied list or raises ValueError
  on degenerate series.

- model_selection/boundary.py (new): three search-space boundary helpers
  promoted from bart26k-lecture/14_team_4_submission.qmd and
  team4_4zones_submit.py (KB entry 2026-06-08-hyperparameter-boundary-
  management). report_boundary_positions() logs and returns flagged dims;
  boundary_report() returns a DataFrame; suggest_bounds() returns a widened
  search space ready for a round-2 run_task_spotoptim() call.

- tests/test_stats_select_pacf_lags.py: 15 tests (AR(1), AR(24),
  degenerate/constant, fallback, determinism, top_k bounds).

- tests/test_model_selection_boundary.py: 27 tests (linear/log10 dims,
  prefix stripping, bool skip, categorical skip, missing key, logger
  injection, suggest_bounds widening for float/log/int).

- _quarto.yml: register stats.select_pacf_lags and
  model_selection.boundary in sidebar and quartodoc sections.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…and boundary helpers

FIX 1 (_quarto.yml): remove invalid `stats.select_pacf_lags` quartodoc contents
entry and matching sidebar item; select_pacf_lags is a function inside
stats/autocorrelation, already rendered as a section of stats.autocorrelation.qmd.
Delete stale docs/reference/stats.select_pacf_lags.qmd.

FIX 2 (boundary.py): expand module docstring with a prominent paragraph
contrasting the two key-prefix conventions (report_boundary_positions strips
"estimator__", boundary_report/suggest_bounds use full keys). Add
logger.warning in boundary_report when result is empty but search_space
contains numeric tuple dims, suggesting a key-convention mismatch.

FIX 3 (uv.lock): restore uv.lock to develop's version; branch-specific lock
hunk dropped.

FIX 4 (test_model_selection_boundary.py): change test_all_keys_preserved to
use "estimator__"-prefixed best_params so the flagged/widened code path is
actually exercised; add asserts that the near-upper-boundary integer dim was
widened and the interior log dim is unchanged.

FIX 5 (test_stats_select_pacf_lags.py): remove dead `except ValueError: pass`
arm from test_very_short_series_fallback (never raises with fallback given);
add separate test_very_short_series_no_fallback_raises asserting ValueError on
constant series without fallback.

FIX 6 (boundary.py): add `if isinstance(val, bool): continue` guard in
boundary_report mirroring report_boundary_positions; note boolean skip in
docstring.

FIX 7 (autocorrelation.py): coerce fallback elements to int via
`[int(x) for x in fallback]`; note the coercion in the fallback param
docstring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
flag = (
"> upper"
if pos > 1 - warn_frac
else ("< lower" if pos < warn_frac else "")
@bartzbeielstein bartzbeielstein merged commit 48a74f4 into develop Jun 12, 2026
9 checks passed
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.69072% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/spotforecast2/model_selection/boundary.py 87.65% 6 Missing and 4 partials ⚠️

📢 Thoughts on this report? Let us know!

@bartzbeielstein

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 8.1.0-rc.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@bartzbeielstein

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 8.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@bartzbeielstein bartzbeielstein deleted the feat/pacf-boundary branch June 12, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants