Skip to main content

industrialstats

CI Docs PyPI Python versions License: MIT Ruff Checked with mypy

Industrial statistics and design of experiments for Python.

industrialstats provides reproducible experimental-design generators, statistical analysis tools, diagnostics, power calculations, optimization methods, and visualizations for manufacturing, engineering, research, and other designed experiments.

Documentation: https://diogoribeiro7.github.io/industrialstats/

The project is currently pre-1.0. Its development priority is statistical correctness and validation against established DOE references before expanding the catalogue of design families.

Project principles

  • Statistical correctness first: implementations should be validated against textbook results, trusted reference software, or independently derived properties.
  • Reproducible experiments: randomization must be seedable and design matrices must remain inspectable.
  • Transparent methods: prefer explicit statistical calculations and documented assumptions over opaque abstractions.
  • Clear design semantics: terms such as effect, block, alias, resolution, whole plot, and optimality criterion must have precise DOE meanings.
  • Structured operational failures: DataExcept is the standard exception layer for data-loading, file-export, and other operational boundaries, with further schema and transformation coverage planned.
  • No false completeness: partially implemented or statistically provisional methods are labelled as such.

Current capabilities

Experimental designs

Design family Status Current capability
Full factorial Implemented Two-level, three-level, and mixed-level designs; replication; centre points; randomization; basic blocking; foldover and star-point augmentation
Fractional factorial Implemented Regular two-level fractions; generator parsing; automatic minimum-aberration generators; defining relations; resolution; alias chains; foldover options
Completely randomized design Implemented Treatment randomization, replication, multiple responses, sample-size calculation, summary statistics, and data-collection sheets
Randomized complete block design Implemented Within-block randomization, efficiency comparison, missing-plot inspection, and a Latin-square option
Plackett-Burman Implemented with limited catalogue Hadamard-based screening designs, reproducible randomization, and foldover
Definitive screening design Experimental Public API exists, but the construction is scheduled for statistical correction and stronger property-based validation
Response surface methodology Implemented Central composite and Box-Behnken designs, quadratic response-surface analysis, steepest ascent, ridge analysis, canonical analysis, and multiple-response optimization
Optimal designs Implemented Coordinate-exchange search with D-, A-, G-, and I-optimal criteria
Split-plot Basic implementation Restricted randomization and whole-plot/subplot layout generation; dedicated error-stratum analysis remains to be completed
Mixture Basic implementation Simplex-lattice designs, constraints, randomization, and three-component simplex plotting

Analysis

industrialstats currently includes:

  • ANOVA with Type I, II, and III sums of squares;
  • effect-size calculations;
  • multiple comparisons and planned expansion of correction methods;
  • contrasts;
  • mixed-effects modelling;
  • factorial main-effect and interaction analysis;
  • residual, leverage, influence, and assumption diagnostics;
  • power and sample-size calculations;
  • stepwise and hierarchical model-fitting utilities;
  • response-surface optimization;
  • design-efficiency and prediction-variance utilities.

Visualization

The visualization layer includes design-space plots, effects plots, diagnostic plots, response-surface plots, contour views, prediction-variance views, and related plotting helpers.

Validation

The repository already contains statistical-validation tests in addition to ordinary unit tests. Examples include comparisons with statsmodels, hand-computed factorial effects, Monte Carlo effect recovery, and fractional-factorial alias checks against the R FrF2 catalogue.

The long-term standard is stronger: every major design family should have algebraic property tests and at least one independent reference implementation or published example.

Current correctness priorities

Before adding many new DOE families, the package is being hardened around several known issues:

  1. replace the provisional definitive-screening construction with a genuine DSD algorithm and tests of its defining properties;
  2. replace index-based factorial blocking with deliberate block generators and explicit confounding rules;
  3. unify factorial-effect semantics around one canonical contrast-based implementation;
  4. generalize factorial degrees of freedom and interaction generation beyond three-way terms;
  5. correct split-plot replication semantics and add whole-plot/subplot error-stratum analysis;
  6. expand Plackett-Burman coverage and document the supported run catalogue;
  7. strengthen optimal-design and mixture-design validation.

See ROADMAP.md for the full development sequence.

DataExcept integration

industrialstats uses DataExcept as its structured exception layer at data and operational boundaries.

The current boundary layer covers external CSV loading and shared CSV, Excel, and JSON export failures. The intended policy is:

  • use DataExcept for file loading, tabular schema, missing columns, dtype mismatches, data transformations, import/export, and wrapped lower-level operational failures;
  • preserve the original exception as context when wrapping an external failure;
  • use specific exception types rather than a generic package-wide catch-all;
  • do not mechanically replace every ValueError or numerical exception: mathematical precondition failures should remain explicit unless a DataExcept type gives genuinely better semantics.

DataExcept ^1.3.0 is a runtime dependency. Broader schema and transformation integration remains planned work.

Installation

Install a released version from PyPI:

python -m pip install industrialstats

The supported Python range is 3.11 through 3.14.

For development from source, see Development below.

Core dependencies include NumPy, pandas, SciPy, statsmodels, scikit-learn, Matplotlib, seaborn, Plotly, openpyxl, and DataExcept.

Quick start

from industrialstats.designs.base import Factor
from industrialstats.designs.factorial import FactorialDesign

factors = [
    Factor("temperature", [180, 220], factor_type="continuous"),
    Factor("pressure", [10, 20], factor_type="continuous"),
]

design = FactorialDesign(
    factors=factors,
    replicates=2,
    randomize=True,
    seed=42,
)

matrix = design.generate_design()
print(matrix)

For a regular fractional factorial:

from industrialstats.designs.base import Factor
from industrialstats.designs.fractional_factorial import FractionalFactorialDesign

factors = [Factor(name, [-1, 1]) for name in "ABCDEFG"]

design = FractionalFactorialDesign(
    factors,
    fraction="1/8",
    randomize=False,
)

matrix = design.generate_design()
print(design.resolution_analysis())
print(design.alias_structure()["A"])

For response-surface methodology:

from industrialstats.designs.base import Factor
from industrialstats.designs.response_surface import ResponseSurfaceDesign

factors = [
    Factor("temperature", [180, 220], factor_type="continuous"),
    Factor("pressure", [10, 20], factor_type="continuous"),
]

design = ResponseSurfaceDesign(
    factors,
    design_type="CCD",
    center_points=4,
)

matrix = design.generate_design()
print(matrix)

Command-line interface

industrialstats exposes a command-line interface for selected analysis workflows.

Power analysis

industrialstats power --analysis t-test --effect-size 0.5 --power 0.8

Stepwise model fitting

printf 'y,A,B\n1,0,0\n2,0,1\n3,1,0\n4,1,1\n' > model.csv
industrialstats model --data model.csv --response y --entry-threshold 0.01 --removal-threshold 0.2

Examples

The repository contains executable examples for:

  • manufacturing optimization;
  • pharmaceutical development;
  • fractional-factorial analysis;
  • response-surface optimization;
  • simulation studies;
  • advanced end-to-end DOE workflows.

Jupyter notebooks cover introductory DOE, response-surface optimization, and model diagnostics.

Development

git clone https://github.com/DiogoRibeiro7/industrialstats.git
cd industrialstats
python -m pip install -e . \
    pytest pytest-cov hypothesis ruff mypy pre-commit \
    pandas-stubs types-openpyxl types-PyYAML
pre-commit install
pytest

The quality toolchain is:

Tool Purpose Command
Ruff Linting and formatting (replaces black, isort, flake8) ruff check . / ruff format .
mypy Static type checking over src/industrialstats mypy
pytest Tests, with a coverage floor enforced in CI pytest
Hypothesis Property-based tests for design invariants included in pytest
pre-commit Runs the above on every commit pre-commit run --all-files

pytest works on a fresh clone without an editable install, because src is on the pytest path. Timing-based benchmarks are excluded from the default run; select them with pytest -m benchmark.

The package ships a PEP 561 py.typed marker, so its annotations are visible to type checkers in downstream projects.

When implementing or changing a statistical method, add tests that verify mathematical properties or compare against an independent reference. Passing shape and run-count tests alone is not sufficient for statistical algorithms. See CONTRIBUTING.md for the validation requirements and the type-checking ratchet policy.

Documentation

python -m pip install mkdocs mkdocs-material "mkdocstrings[python]"
mkdocs serve

The API reference is generated from the NumPy-style docstrings in the source, so improving a docstring improves the published site.

Releases

Release preparation and the PyPI/Zenodo publication workflow are documented in RELEASE.md. GitHub Releases are the canonical release event for both destinations.

Package status

Current package version: 0.1.0.

The public API is still evolving. Design and analysis objects that are not exported from industrialstats directly can currently be imported from their submodules. API cleanup is part of the pre-1.0 roadmap.

Citation

Citation metadata is provided in CITATION.cff. The real Zenodo DOI is minted from the first archived GitHub Release; placeholder DOIs are intentionally not stored in the citation metadata.

License

Licensed under the MIT License. See LICENSE for details.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

industrialstats-0.2.0.tar.gz (114.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

industrialstats-0.2.0-py3-none-any.whl (126.1 kB view details)

Uploaded Python 3

File details

Details for the file industrialstats-0.2.0.tar.gz.

File metadata

  • Download URL: industrialstats-0.2.0.tar.gz
  • Upload date:
  • Size: 114.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for industrialstats-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9ac66be894cf4b34705763b84b89a5e37f1e5ac3cff3f0f9e9358b6353ec448f
MD5 251ff3b49771eaac8fb7f3b4515e957d
BLAKE2b-256 99a846b18817a949f655dc32944afe10a1e16636ea2f0563a3c2c472fbb411c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for industrialstats-0.2.0.tar.gz:

Publisher: release.yml on DiogoRibeiro7/industrialstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file industrialstats-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: industrialstats-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 126.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for industrialstats-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 415213d360d41461eb6ec9e77bea07ff7859193adeb0657b33a253268ea36d37
MD5 4725c8467cea62dec363363d7272aa89
BLAKE2b-256 5b7622f015799e84696b7560b0ebfa173f359e8847f83485346c6846935567e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for industrialstats-0.2.0-py3-none-any.whl:

Publisher: release.yml on DiogoRibeiro7/industrialstats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

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