Skip to content

Batch phase 2: online Nomikos-MacGregor monitoring#460

Open
kgdunn wants to merge 1 commit into
claude/process-improve-library-review-9h1fn2from
claude/batch-phase2-online-monitoring
Open

Batch phase 2: online Nomikos-MacGregor monitoring#460
kgdunn wants to merge 1 commit into
claude/process-improve-library-review-9h1fn2from
claude/batch-phase2-online-monitoring

Conversation

@kgdunn

@kgdunn kgdunn commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds 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 matches BatchPCA.diagnose exactly.
  • Adds BatchMonitor: builds time-varying Hotelling's T2 and SPE control limits by running every good batch through predict_online at each 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 the samples where each statistic exceeds its limit.
  • Adds 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 BatchPCA from Phase 1.

Note on base branch: this PR is stacked on claude/process-improve-library-review-9h1fn2 (Phase 1, #459), since predict_online is a method on BatchPCA which isn't merged yet. GitHub will retarget the base to main automatically once #459 merges. Review #459 first.

Test plan

  • tests/batch/test_batch_monitor.py: PMP matches diagnose at full observation; upto_k bounds; 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_k truncation; initial-conditions threaded end-to-end
  • tests/batch/test_batch_plots.py: online monitoring plot builds for SPE and T2; bad-statistic guard
  • Full batch suite: 111 passed; ruff check . and mypy src/process_improve clean (142 files)

Checklist

  • Version bumped in pyproject.toml (MINOR: 1.55.0 -> 1.56.0) and CITATION.cff synced
  • Tests added or updated where relevant
  • ruff check . passes
  • CHANGELOG.md updated

🤖 Generated with Claude Code

https://claude.ai/code/session_01SyEpexCyqHn1rwTMYQSiP6


Generated by Claude Code

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

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.17857% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/process_improve/batch/_batch_pca.py 83.33% 3 Missing and 3 partials ⚠️
src/process_improve/batch/_batch_monitor.py 94.11% 2 Missing and 1 partial ⚠️
src/process_improve/batch/_batch_plots.py 91.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants