Batch phase 2: online Nomikos-MacGregor monitoring - #460
Open
kgdunn wants to merge 1 commit into
Open
Conversation
BatchPCA.predict_online projects a partially-observed batch onto the model by projection to the model plane (PMP): future trajectory columns are treated as missing and the score is the least-squares fit of the observed columns onto the loadings, with initial conditions always observed. At full observation it matches BatchPCA.diagnose. BatchMonitor builds time-varying T2 and SPE control limits by running every good batch through predict_online at each time sample and summarising the good-batch spread (spe_calculation per sample; the analytical F-based T2 limit). monitor() tracks a new batch sample by sample and flags where each statistic exceeds its limit. online_monitoring_plot draws the trace over the limit band with alarm markers. Bumps to 1.56.0 with CITATION, CHANGELOG, and docs updates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This was referenced Jul 16, 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
BatchPCA.predict_online: projection to the model plane (PMP) for a partially-observed batch. At each time sample the future trajectory columns are treated as missing and the score is the least-squares fit of the observed columns onto the loadings (t = pinv(P_obs) @ x_obs); initial conditions, known from the batch start, are always observed. At full observation it matchesBatchPCA.diagnoseexactly.BatchMonitor: builds time-varying Hotelling's T2 and SPE control limits by running every good batch throughpredict_onlineat each sample and summarising the good-batch spread (spe_calculationper sample; the analytical F-based T2 limit).monitor()tracks a new batch sample-by-sample and flags the samples where each statistic exceeds its limit.online_monitoring_plot: the online SPE/T2 chart, drawing the batch trace over the time-varying limit and the mean good-batch trace, with alarm samples marked.This is Phase 2 of the batch modernization plan (online monitoring). It builds on the offline
BatchPCAfrom Phase 1.Note on base branch: this PR is stacked on
claude/process-improve-library-review-9h1fn2(Phase 1, #459), sincepredict_onlineis a method onBatchPCAwhich isn't merged yet. GitHub will retarget the base tomainautomatically once #459 merges. Review #459 first.Test plan
tests/batch/test_batch_monitor.py: PMP matchesdiagnoseat full observation;upto_kbounds; limit shapes; a good training batch stays mostly in-limit; a large injected fault in a real nylon batch trips SPE in the fault window;upto_ktruncation; initial-conditions threaded end-to-endtests/batch/test_batch_plots.py: online monitoring plot builds for SPE and T2; bad-statistic guardruff check .andmypy src/process_improveclean (142 files)Checklist
pyproject.toml(MINOR: 1.55.0 -> 1.56.0) andCITATION.cffsyncedruff check .passesCHANGELOG.mdupdated🤖 Generated with Claude Code
https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6
Generated by Claude Code