Batch phase 3: sklearn transformer facades and f_rupture - #461
Open
kgdunn wants to merge 1 commit into
Open
Conversation
Adds BaseEstimator/TransformerMixin facades over the existing batch free functions so a batch workflow can be an sklearn pipeline, with the learned state carried on the fitted estimator: BatchScaler (range scaling with inverse_transform), ResampleAligner (linear resampling to a common length), DTWAligner (iterative weighted DTW, learning a reference and weights and aligning new batches to them), and BatchFeatureExtractor (batch dict to a batch-by-feature matrix for PLS-to-quality). The free functions are unchanged and remain the implementation layer. Implements the previously-stubbed f_rupture via the optional ruptures library (PELT changepoint detection), and re-points the batch extra to ruptures - it previously declared openpyxl and scikit-image, which were imported nowhere. Bumps to 1.57.0 with CITATION, CHANGELOG, and docs updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
6 tasks
kgdunn
pushed a commit
that referenced
this pull request
Aug 21, 2026
…plots, loaders Consolidates the stale #459 / #460 / #462 stack onto current main, as one commit series inside the mid-course-correction PR: - BatchPCA: batchwise-unfolded (Nomikos-MacGregor) PCA with an optional initial-conditions (Z) join, composed over multivariate.PCA and MCUVScaler; batch-level scores, SPE, T2, contributions and the plot and limit conveniences. - BatchPCA.predict_online: projection to the model plane for a partially-observed batch (upgraded to the shared missing-data projection API in a later commit series). - BatchMonitor: time-varying online SPE and T2 limits learned from good batches, with per-sample alarms, plus online_monitoring_plot. - BatchPLS: batchwise-unfolded [Z | X] -> Y regression to final quality. Refreshed beyond the original: the class now owns both scalers publicly (center_/scale_ for the unfolded block, y_center_/y_scale_ for the quality block; the inner PLS runs with scale=False), reports beta and RMSE in engineering units, and adds a prediction_interval wrapper. The mid-course corrector reads these public attributes instead of any PLS internals. - time_varying_loading_plot and contribution_at_time_plot for the unfolded structure; dataset loaders load_nylon, load_dryer and load_batch_fake_data for the bundled batch CSVs. - Integration test: BatchPLS on a simulator historical campaign (80 batches, 4 components) reaches fit R2 0.83 and out-of-sample correlation 0.80 against fresh batches; thresholds pinned below with margin. The #461 transformer facades are deliberately not re-landed; they can be revived separately if wanted. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZAyiPT8xURSdi24yFKCra
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.
Summary
BaseEstimator/TransformerMixinfacades over the existing batch free functions, so a batch workflow can be expressed as a pipeline and the learned state is carried on the fitted estimator:BatchScaler(range scaling withinverse_transform),ResampleAligner(linear resampling to a common length),DTWAligner(iterative weighted DTW that learns a reference and weights and aligns new batches to them), andBatchFeatureExtractor(a batch dict to a batch-by-feature matrix suitable as the X block of a PLS-to-quality model). The free functions are unchanged and remain the implementation layer.f_rupturevia the optionalruptureslibrary (PELT changepoint detection), and re-points thebatchextra toruptures- it previously declaredopenpyxlandscikit-image, which were imported nowhere.This is Phase 3 of the batch modernization plan (pipeline ergonomics + feature completion).
Note on base branch: stacked on
claude/batch-phase2-online-monitoring(#460), which is stacked on Phase 1 (#459). GitHub will retarget the base automatically as each parent merges. Review #459, then #460, then this.Test plan
tests/batch/test_transformers.py: scaler round-trip; resampler equal-length + auto-reference; DTW aligns the training set and a held-out batch to the reference length; feature matrix shape/index and feeding a PLS model; unknown-feature guard;f_rupturedetects an injected step (guarded byimportorskip("ruptures")) and rejects multi-column inputruff check .andmypy src/process_improvecleanChecklist
pyproject.toml(MINOR: 1.56.0 -> 1.57.0) andCITATION.cffsyncedruff check .passesCHANGELOG.mdupdated🤖 Generated with Claude Code
https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
Generated by Claude Code