Batch phase 4: BatchPLS to final quality - #462
Open
kgdunn wants to merge 1 commit into
Open
Conversation
BatchPLS mirrors BatchPCA's construction (unfold the batches batchwise, join an optional initial-conditions Z block onto the one-row-per-batch matrix) but fits the existing multivariate.PLS against a batch-indexed final-quality block Y. It relates the initial conditions and time-varying trajectory deviations to the final product quality, and predicts the quality of a completed batch. The X-weights keep the (tag, sequence) index so they reshape to a variable-by-time grid and plot with time_varying_loading_plot; predict and transform return results in the input batch order. Bumps to 1.58.0 with CITATION, CHANGELOG, and docs updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
This was referenced Aug 21, 2026
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
BatchPLS: batchwise-unfolded (multiway) PLS relating the unfolded[Z | X]batch matrix to a final-quality blockY(one row per batch), built by composition overmultivariate.PLS. It mirrorsBatchPCA's construction (batchwise unfold, optional initial-conditions Z join) but is supervised: it relates the initial conditions and time-varying trajectory deviations to the final product quality, and predicts the quality of a completed batch.(tag, sequence)index so they reshape to a variable-by-time grid and plot with the existingtime_varying_loading_plot.predictandtransformreturn results in the input batch order.This is Phase 4 (the final phase) of the batch modernization plan: the batch regression / prediction counterpart to
BatchPCA.Note on base branch: stacked on
claude/batch-phase3-transformers(#461) → #460 → #459. GitHub retargets the base automatically as each parent merges. Review order: #459, #460, #461, then this.Test plan
tests/batch/test_batch_pls.py: fit + predict on the real dryer dataset (scores shape, MultiIndex weights, R2, prediction correlates with quality); weights reshape to a (tag, time) grid; Z-block join; a synthetic batch whose quality is a known function of its trajectories is recovered; Y type/index guards; wrong-length rejection; transform returns scoresruff check .andmypy src/process_improveclean (144 files)Note on the OWU phase
The originally-planned Phase 4 was observationwise unfolding (OWU / OWU-TBWU) plus maturity-variable alignment. Per your steer, OWU was dropped (batchwise unfolding only, one row per batch, Z included), so this phase delivers
BatchPLSon that same[Z | X]matrix instead.Checklist
pyproject.toml(MINOR: 1.57.0 -> 1.58.0) andCITATION.cffsyncedruff check .passesCHANGELOG.mdupdated🤖 Generated with Claude Code
https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
Generated by Claude Code