Skip to main content

processbehavior

PyPI version Python versions CI codecov License

A Python library for Process Behavior Analysis following Thomas A. Bishop's Variation Analysis System (VAS) methodology.

Unlike traditional SPC packages, processbehavior faithfully implements Bishop's VAS equation-by-equation: automatic detection of the three-state design lineage (PDS / ODS / ADS), variance decomposition via R1-R6 residuals, and chart selection routed by the data your study can actually analyze.

Installation

pip install processbehavior

Plotting (plotly) is included. For Excel export and static image export, install the corresponding extras:

pip install "processbehavior[excel]"   # openpyxl, for result.to_excel(...)
pip install "processbehavior[images]"  # kaleido, for static plot images

Quickstart

A column of values, charted in the order received, is an X/mR chart in two calls:

import pandas as pd
import processbehavior as pb

df = pd.DataFrame({'weight': [50.2, 49.8, 50.5, 50.1, 49.6, 50.9, 50.3, 49.9, 50.4, 50.0, 49.7, 50.6]})

study = pb.formulate(df, response='weight')   # no time column: rows are numbered 1..N as 'Observation'
result = study.execute(companion=True)        # X chart with its mR companion
print(result.statistics('X'))                 # {'N': 1, 'center': 50.167, 'lpl': 48.619, 'upl': 51.714}
result.plot()

When the data has a time order, factors, or both, name them. The design state routes the analysis:

import processbehavior as pb

# Generate a sample dataset (replace with your own DataFrame)
df = pb.make_design(state=1, seed=42)
# Columns: 'time', 'factor 1', 'factor 2', 'y'

# Formulate — detects PDS / ODS / ADS and builds the analysis dataset
study = pb.formulate(
    df,
    response='y',
    time='time',
    factors=['factor 1', 'factor 2'],
)
print(f"Observed:   ODS {study.observed_design_state.sds}")
print(f"Analytical: ADS {study.analytical_design_state.sds}")
print(f"Recommended chart: {study.recommended_chart}")

# Execute analysis (routes by ADS)
result = study.execute()                       # uses the recommended chart
stats = result.statistics('Xbar')              # always {'N', 'center', 'lpl', 'upl'}
print(f"Center: {stats['center']}")

# When subgroup sizes differ the limits differ per subgroup, so the scalar
# 'lpl'/'upl' are None and stats['limits_vary'] is True. The per-subgroup
# limits live in the chart table:
print(result.get_chart('Xbar')[['center', 'lpl', 'upl']].head())

# Plot (interactive plotly figure)
result.plot()

# Export to Excel (requires the [excel] extra)
result.to_excel('analysis.xlsx')

The whole pipeline is one expression when you don't need the intermediate objects:

pb.formulate(df, response='y', factors=['factor 1'], time='time').execute().plot()

A process that changed on purpose gets its own limits for each stage with phased=True:

import processbehavior as pb

# The bundled coffee-shop data: a new machine in week 8, a new POS in week 12, new baristas from week 14
pbd = pb.load_coffee_shop().bin('week', method='breaks', breaks=[8, 12, 14],
                                bin_labels=['baseline', 'new machine', 'new POS', 'new baristas'],
                                label='stage')
staged = pbd.formulate(response='wait_sec', factors=['stage'], time='date').execute(chart='Xbar', phased=True, companion=True)
staged.phase_statistics('Xbar')   # one row per stage: center, S-bar, sigma-hat, limits
staged.plot(chart='Xbar', title='Wait time: limits per stage')

Use pb.ProcessBehavior(df) directly when you want the fluent derived-variable verbs (.transform(...), .bin(...)), which attach before formulating. With that object in hand, pbd.cols.<column_name> provides IDE auto-completion for column references.

Key Concepts

Two-Step Workflow

The API mirrors how analysts think:

  1. formulate() - Understand your data structure. Detects PDS / ODS / ADS, identifies valid charts, and computes residuals. This is the expensive step.
  2. execute() - Run analysis. Produces charts from the pre-computed data. This is cheap and can be called multiple times for different charts from the same study.

Design-State Lineage (PDS / ODS / ADS)

processbehavior reports three design states at three points in the analysis lifecycle:

State Computed from Codomain Meaning
PDS — Planned Your declared factors and time (or an explicit plan=) {1, 2} What you intended to collect
ODS — Observed Raw data, before NA filtering {1..6} What was actually collected (cells with all-NA responses count as "attempted but empty")
ADS — Analytical Tidy data, after NA filtering {0, 1, 2, 3} What survives tidying; drives chart selection, residual availability, and variance decomposition

The integer codes are Bishop's reference scale ("Bishop Table 1"):

Code Cell Sizes (N_kt)
1 Complete grid, all N_kt >= 2 (full replication)
2 Complete grid, all N_kt = 1 (no replication)
3 Complete grid, mix of N_kt = 1 and N_kt >= 2
4 Incomplete grid, occupied cells N_kt >= 2
5 Incomplete grid, occupied cells N_kt = 1
6 Incomplete grid, mixed N_kt

ODS values in {4, 5, 6} collapse to ADS values in {1, 2, 3} during tidying (empty cells drop and the surviving subset becomes the analytical grid).

Access the lineage on a formulated study:

study.plan_design_state        # PDS (when a plan was supplied)
study.observed_design_state    # ODS — what the raw data showed
study.analytical_design_state  # ADS — what the analysis is fit for
study.design()                 # DesignReport: full lineage in one object

Residual System (R1-R6)

For factorial designs (ADS 1-3), processbehavior decomposes variation into diagnostic residuals:

  • R1 - The response centered at 0 (Bishop §13.1); the building block for the rest
  • R2 - Within-cell noise (measurement error, short-term fluctuation)
  • R3 - Interaction between design conditions and time
  • R4 - Time main effects (trends, seasonality, batch effects)
  • R5 - Design condition main effects, all factors combined
  • R6 - A single design factor's main effect (machine-to-machine, operator bias)
# Chart any residual
result = study.execute(chart='Xbar', value='R4')  # Time main effects
result = study.execute(chart='Xbar', value='R5')  # Design condition main effects
result = study.execute(chart='Xbar', value='R6', by=['machine'])  # One factor's effect

Not every chart pairs with every residual — the valid pairs depend on the ADS. study.residual_charts lists them, and study.why_not('X', value='R4') explains any pair it refuses.

Stratified Analysis

For X/mR charts with grouping factors, processbehavior produces a single combined chart with per-stratum limits:

result = study.execute(chart='X', by=['machine'])

# Drill into a specific stratum
for stratum in result.strata:
    focused = result.focus(stratum)
    focused.plot()

Validation

processbehavior's analytical outputs are verified against Dr. Thomas A. Bishop's VAS (Minitab-based) reference results on every push. The validator at validation/e2e_bishop_report.py runs 1,547 numerical assertions through the full formulate → execute → capability / loss pipeline, across 14 of his VAS runs:

VAS runs Data Analytical design states Assertions Status
PM SDS 1–6 PBTESTDATABASE_T100.csv ADS 1, 2, 3 630 ✅ all pass
PM INERT SDS 1–6 (pure noise) PBTESTDATABASE_T100.csv ADS 1, 2, 3 630 ✅ all pass
PM SDS 1 KNOWN (known effects) PBTESTKNOWNEFFECTS_T100.csv ADS 1 101 ✅ all pass
Medicare ACO (PCE) aco_per_capita_expenditure.csv ADS 2 186 ✅ all pass

Reference data is Bishop's VAS output for the 10-12-2026 manual (his runs of October 2026). The library matches every chart center, control limit, capability index and loss-function value that output prints, to within the precision Bishop reports. Where subgroup sizes differ, VAS prints "UNEQUAL" instead of a limit; there every subgroup's limits are read from the limit lines VAS draws and compared one by one. SDS 4–6 are incomplete grids (ODS 4–6), checked as the complete design that survives tidying (ADS 1–3). Four values, the factor S-chart limits of the known-effects run, wait for a VAS rerun. The per-run table is in docs/reference/validation.md.

The full report renders to validation/e2e_bishop_report.html.

Features

  • Three-state lineage: PDS / ODS / ADS detected automatically; chart selection routes by ADS
  • Correct charts: Xbar-S, X (Individual), mR (Moving Range), Histogram with proper limit calculations
  • Variance decomposition: R1-R6 residuals for factorial designs
  • Effects analysis: Main effects, time effects, and interaction effects
  • Stratified charts: Automatic per-stratum limits for grouped individual data
  • Staged charts: phased=True gives each stage its own center and limits on X/mR and Xbar/S; phase_statistics() returns the numbers behind the steps
  • Signal detection: all eight Western Electric rules on X/mR; Rule 1 (3-sigma) on Xbar/S, where the run- and zone-based rules need a time order that subgroup comparisons don't have
  • Beyond the charts: capability indices (Cp/Cpk/Pp/Ppk), Taguchi loss decomposition, and maximum-information analysis — validated in the same Bishop-reference CI gate
  • IDE support: Column auto-completion via ProcessBehavior(df).cols
  • Self-diagnostic errors: Helpful messages that say what's available and how to fix it
  • Excel export: Publication-ready workbooks with charts and statistics
  • Interactive plots: Plotly-based charts with hover details

Scope

processbehavior is the computational engine for Bishop's VAS methodology. It handles data ingestion, design-state lineage detection (PDS / ODS / ADS), residual computation, chart generation, and export.

For the curated analyst experience — guided workflows, interactive dashboards, and collaboration features — see processbehavior.com.

For the methodological foundation — the theory behind VAS, design-state classification, and residual interpretation — see Bishop's published book below and the forthcoming book by Dr. Thomas A. Bishop and Chris Nicholas.

References

The methodology this library implements:

Bishop, Thomas A. (2021). The Scientific Basis for Modern Analytic Practice. Lulu Press. 279 pp.

To cite the software itself, see CITATION.cff.

License

Apache 2.0

Metadata

Release files for processbehavior 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for processbehavior 0.5.0
File Size Uploaded Provenance Actions
processbehavior-0.5.0.tar.gz 729.2 kB With provenance Details for processbehavior-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for processbehavior 0.5.0
File Interpreter ABI Platform Actions
processbehavior-0.5.0-py3-none-any.whl Python 3 none any Details for processbehavior-0.5.0-py3-none-any.whl

Total release size: 1.0 MB

Release files / processbehavior-0.5.0.tar.gz

Download URL processbehavior-0.5.0.tar.gz
Size 729.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1a1b49fe3c2bad76937cfd0514c8f41bd5793f2aea60ea724d0028b1c0e656e7
BLAKE2b-256 checksum
How to use checksums
863081e56c9fe9f77f108b1c8578e4c97f353dd91c8388485c56bed4f7e60b5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Release files / processbehavior-0.5.0-py3-none-any.whl

Download URL processbehavior-0.5.0-py3-none-any.whl
Size 291.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d4ac8f401d5ffdf2cc50e57db62dfb50d960ae4fe4227364ae15704b42705a3
BLAKE2b-256 checksum
How to use checksums
0888d8f93bdbc68fab5977e460f4deec4c70fe328331698f1f7c82473dddb621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

Security for processbehavior 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for processbehavior-0.5.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page