feat(plots): operational diagnostics plots#215
Merged
Conversation
…, 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>
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>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
🎉 This PR is included in version 8.1.0-rc.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Collaborator
Author
|
🎉 This PR is included in version 8.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Upstreams the team4 diagnostic figures as a new
plots.diagnosticsmodule:feature_family,plot_acf_with_lags,plot_feature_importance_by_family,plot_shap_summary,plot_forecast_vs_reference(generalized forecast-vs-ENTSO-E plot; tolerates empty reference overlap). All return Figure, caller owns saving/closing. Reviewed (MAD-unit-scaling blocker + 4 findings resolved;feature_familykept out of the package-root namespace). Full pipeline green incl. quarto render.🤖 Generated with Claude Code