Skip to content

Batch phase 4: BatchPLS to final quality - #462

Open
kgdunn wants to merge 1 commit into
claude/batch-phase3-transformersfrom
claude/batch-phase4-batchpls
Open

Batch phase 4: BatchPLS to final quality#462
kgdunn wants to merge 1 commit into
claude/batch-phase3-transformersfrom
claude/batch-phase4-batchpls

Conversation

@kgdunn

@kgdunn kgdunn commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds BatchPLS: batchwise-unfolded (multiway) PLS relating the unfolded [Z | X] batch matrix to a final-quality block Y (one row per batch), built by composition over multivariate.PLS. It mirrors BatchPCA'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.
  • The X-weights keep the (tag, sequence) index so they reshape to a variable-by-time grid and plot with the existing time_varying_loading_plot. predict and transform return 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 scores
  • Full batch suite: 129 passed; ruff check . and mypy src/process_improve clean (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 BatchPLS on that same [Z | X] matrix instead.

Checklist

  • Version bumped in pyproject.toml (MINOR: 1.57.0 -> 1.58.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

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
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
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