Skip to content

Release train: PACF lag selection, boundary helpers, diagnostics plots#216

Merged
bartzbeielstein merged 9 commits into
mainfrom
develop
Jun 12, 2026
Merged

Release train: PACF lag selection, boundary helpers, diagnostics plots#216
bartzbeielstein merged 9 commits into
mainfrom
develop

Conversation

@bartzbeielstein

Copy link
Copy Markdown
Collaborator

Promotes develop → main for the 8.1.0 release:

  • feat(stats): select_pacf_lags — significance-band top-k PACF lag pick (upstreamed from the team4 operational script)
  • feat(model_selection): boundary.pyreport_boundary_positions, boundary_report, suggest_bounds (promoted from the ch14 qmd prototypes; closes the KB boundary-management follow-up)
  • feat(plots): diagnostics.py — ACF-with-lags, importance-by-family, SHAP summary, forecast-vs-reference figures

Union verified locally: 1257 tests green, consumer-contract test green, full quarto render green on both feature branches.

🤖 Generated with Claude Code

semantic-release-bot and others added 8 commits June 11, 2026 00:04
## [8.0.0-rc.2](v8.0.0-rc.1...v8.0.0-rc.2) (2026-06-11)

### Features

* **deps:** require spotforecast2-safe >=22.0.0 ([13893ad](13893ad))
…, SHAP summary, forecast-vs-reference)

Ports five matplotlib helpers from bart26k-lecture/scripts/team4_4zones_submit.py
into a reusable, stateless public API in spotforecast2.plots.diagnostics:

- feature_family(name) — maps LGBMRegressor feature names to six diagnostic families
- plot_acf_with_lags(acf, key_lags, conf) — bar chart with confidence band and annotated key lags
- plot_feature_importance_by_family(names, importances, top_n) — top-N barh coloured by family
- plot_shap_summary(estimator, X, max_samples) — subsampled TreeExplainer bar summary
- plot_forecast_vs_reference(forecast, reference, ...) — generalised forecast-vs-ENTSO-E line plot

All functions return matplotlib.figure.Figure; the caller saves/closes.
No plt.show(), no matplotlib.use(), no global state mutation.
Overlap MAD is logged at INFO via the module logger (preserved from the original).
44 new tests in tests/test_plots_diagnostics.py; 1207 tests pass total.
Registered in _quarto.yml sidebar + quartodoc contents (plots.diagnostics).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- 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>
FIX 1 (blocker): plot_forecast_vs_reference MAD log now uses
`mad * unit_scale` (not `mad / unit_scale`) so the value is
reported in the display unit (GW) rather than inflated by 1000×.
Log format updated to include the unit label. Strengthened test
asserts logged value is 1.0 GW for a constant 1000 MW offset.

FIX 2: plot_shap_summary docstring notes the figure is harvested
via plt.gcf() (shap API limitation), the function is not
thread-safe, and callers must close the returned figure before
other pyplot work.

FIX 3: plot_shap_summary docstring replaces "at most max_samples
rows" with the precise stride description.

FIX 4: Remove feature_family from plots/__init__.py re-exports
and __all__; it is a string classifier, not a plot function.
Remains public at spotforecast2.plots.diagnostics.feature_family.
Tests already used the full module path — no changes needed there.

FIX 5: Remove dead n_annotated variable in plot_acf_with_lags.

FIX 6: Remove per-example matplotlib.use("Agg") calls from the
four docstring Examples; examples still avoid plt.show().

FIX 7: Add two feature_family precedence cases to the parametrized
table: "poly_window_24" -> "polynomial" and "sin_window" ->
"weather_window", pinning holiday > poly > window > cyclical > lag.

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>
…acf-boundary

feat(model_selection): PACF lag selection + search-space boundary helpers
…iagnostics-plots

feat(plots): operational diagnostics plots
flag = (
"> upper"
if pos > 1 - warn_frac
else ("< lower" if pos < warn_frac else "")
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.56522% 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!

## [8.1.0-rc.1](v8.0.0...v8.1.0-rc.1) (2026-06-12)

### Features

* **plots:** operational diagnostics plots (ACF, importance-by-family, SHAP summary, forecast-vs-reference) ([0bbc0c6](0bbc0c6))
* **stats:** PACF lag selection + search-space boundary report ([c8079b2](c8079b2))

### Bug Fixes

* **plots:** apply code-review fixes to diagnostics.py ([5a7857c](5a7857c))
* **stats,model_selection:** code-review fixes for PACF lag selection and boundary helpers ([62af0dd](62af0dd))
@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 📦🚀

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.

3 participants