Skip to content

capability_trending

CapabilityTrendingEvents ¤

CapabilityTrendingEvents(
    dataframe: DataFrame,
    signal_uuid: str,
    *,
    upper_spec: float | None = None,
    lower_spec: float | None = None,
    upper_spec_uuid: str | None = None,
    lower_spec_uuid: str | None = None,
    value_column: str = "value_double",
    event_uuid: str = "quality:capability_trend",
    time_column: str = "systime",
    sigma_method: SigmaMethod = "moving_range"
)

Bases: Base

Quality: Process Capability Trending

Track process capability indices (Cp, Cpk, Pp, Ppk) over rolling time windows to detect capability degradation before quality escapes occur.

Specification limits can be provided as fixed floats or as UUIDs referencing signal rows in the DataFrame (matching the ToleranceDeviationEvents pattern).

Sigma (AIAG SPC manual; Montgomery, Introduction to Statistical Quality Control, section 8.3), per window:

  • Cp = (USL - LSL) / 6 sigma_within, Cpk = min(USL - mean, mean - LSL) / 3 sigma_within, with the within (short-term) sigma MR-bar / 1.128 of consecutive samples in the window (sigma_method="moving_range", default);
  • Pp / Ppk: the same formulas with the window's overall sample standard deviation s (ddof=1).

sigma_method="std" uses s for Cp/Cpk as well (Cp = Pp, the earlier Cp/Cpk). Before October 2026, Pp/Ppk combined the window mean with the standard deviation of the whole signal (later windows included); they now use only the window's own data.

Methods: - capability_over_time: Cp/Cpk/Pp/Ppk per time window. - detect_capability_drop: Alert when Cpk falls below threshold. - capability_forecast: Extrapolate Cpk trend to predict threshold breach. - yield_estimate: Estimated yield, DPMO, and sigma level per window.

Example

import ts_shape df = ts_shape.make_timeseries(["dia"], n_points=960, freq="1min", drift=3.0) cap = ts_shape.CapabilityTrendingEvents(df, "dia", upper_spec=105, lower_spec=95) out = cap.capability_over_time(window="8h") out[["start", "cpk", "ppk"]].round({"cpk": 2, "ppk": 2}) start cpk ppk 0 2025-01-01 00:00:00 1.56 1.33 1 2025-01-01 08:00:00 0.94 0.83

capability_over_time ¤

capability_over_time(window: str = '8h') -> pd.DataFrame

Compute Cp, Cpk, Pp, Ppk per time window.

Each window uses only its own samples (see the class docstring): Cp/Cpk from the within sigma (MR-bar / 1.128 of consecutive samples; the window's s with sigma_method="std"), Pp/Ppk from the window's sample standard deviation s (ddof=1).

Parameters:

Name Type Description Default
window str

Resample window size.

'8h'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, cp, cpk, pp, ppk, mean, std (the window's s),

DataFrame

std_within (the sigma behind cp/cpk), n_samples.

DataFrame

end is start plus one window. Windows with fewer than

DataFrame

two samples are skipped. Without spread (constant values) the

DataFrame

indices are NaN; a signal without any spread also emits a

DataFrame

class:~ts_shape.errors.DataQualityWarning.

DataFrame

Canonical twin columns: sample_count (after n_samples); each holds

DataFrame

the same values as the deprecated column right before it, which is removed

DataFrame

in the next major release.

detect_capability_drop ¤

detect_capability_drop(
    window: str = "8h",
    min_cpk: float = 1.33,
    lookback: int = 5,
) -> pd.DataFrame

Detect windows where Cpk drops below threshold or degrades significantly.

Parameters:

Name Type Description Default
window str

Resample window size.

'8h'
min_cpk float

Minimum acceptable Cpk value.

1.33
lookback int

Number of previous windows for rolling average comparison.

5

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, cpk, prev_avg_cpk, drop_pct, alert.

DataFrame

end is start plus one window.

capability_forecast ¤

capability_forecast(
    window: str = "8h",
    horizon: int = 5,
    threshold: float = 1.33,
) -> pd.DataFrame

Extrapolate Cpk trend to predict when it will breach threshold.

Parameters:

Name Type Description Default
window str

Resample window size.

'8h'
horizon int

Number of future windows to forecast.

5
threshold float

Cpk threshold to predict breach for.

1.33

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, cpk, trend_slope, forecast_cpk,

DataFrame

windows_to_threshold. end is start plus one window.

yield_estimate ¤

yield_estimate(window: str = '8h') -> pd.DataFrame

Estimate yield, DPMO, and sigma level per window.

Assumes normal distribution within each window.

Parameters:

Name Type Description Default
window str

Resample window size.

'8h'

Returns:

Type Description
DataFrame

DataFrame with columns: start, end, duration_seconds, uuid,

DataFrame

source_uuid, estimated_yield_pct, dpmo, sigma_level.

DataFrame

end is start plus one window.