Skip to main content
Version: Next

ts_shape.events.profiling.settings

Mapping-free setting-change impact: did that parameter change help?

:class:SettingImpactEvents finds the held settings among the signals of one PLC -- numeric signals that change rarely and then hold their value for many cycles (a speed override, a temperature or pressure set value, a hold time) -- and compares the cycles before and after every change, a natural before/after experiment:

  • metrics: cycle time (non-pause cycles), every segment of the cycle profile's standard cycle, the bad-part rate and the energy per cycle when the counters for them are found (:func:~ts_shape.events.profiling.orders.counter_roles);
  • effect: shift (Hodges-Lehmann), Cliff's delta and a Mann-Whitney p-value, Benjamini-Hochberg q-values over all tests;
  • windows: only cycles of the variant running at the change are compared (cycle times differ between variants);
  • confounders: another setting change within the windows, a variant change or a pause at the change, and a trend already running before the change;
  • confidence: high (unconfounded, q < 0.05, enough cycles), medium (significant but confounded by a pause at the change or another setting) or low.

A setting whose changes all come with a variant change is a recipe parameter: listed, not tested (its effect cannot be told from the variant's).

Classes
NameDescription
SettingImpactEventsBefore/after effect of every change of a held setting.

SettingImpactEvents​

classsource
SettingImpactEvents(
dataframe: pd.DataFrame,
*,
cycle_profile: CycleProfileEvents | None = None,
signal_uuids: list[str] | None = None,
window_cycles: int = 30,
settle_cycles: int = 3,
min_window_cycles: int = 10,
time_column: str = "systime",
uuid_column: str = "uuid",
event_uuid: str = "prod:setting_impact",
**cycle_options: Any
) -> None

Bases: _CounterMixin

Before/after effect of every change of a held setting.

Example
>>> import ts_shape
>>> frame, truth = ts_shape.make_plc_cycles(
... n_cycles=400, seed=3, setting_changes=[(150, 130.0)])
>>> impact = ts_shape.SettingImpactEvents(frame).setting_impact()
>>> row = impact[impact["metric"] == "cycle_seconds"].iloc[0]
>>> bool(row["shift"] < 0), row["confidence"]
(True, 'high')
Functions
NameDescription
setting_changesEvery change of a held setting.
setting_impactBefore/after effect of every change on every metric.
setting_registerWhat each setting does to the cycle time, over all its holds.
evaluation_windowWhether the setting tests can be trusted, and why not.
summaryHeadline numbers (JSON-able).
Parameters
NameTypeDescriptionDefault
dataframeDataFrameLong-format signals of one PLC.required
cycle_profileCycleProfileEvents | NoneA computed cycle profile of the same signals to reuse; None (default) builds one.None
signal_uuidslist[str] | NoneSignals to use (default: all).None
window_cyclesintCycles compared before and after a change (at most; a window ends at the previous or next setting change).30
settle_cyclesintCycles right after a change left out (the process settles).3
min_window_cyclesintA side with fewer cycles makes the test low confidence.10
time_columnstrTimestamp column.'systime'
uuid_columnstrSignal column.'uuid'
event_uuidstruuid of the change records.'prod:setting_impact'
**cycle_optionsAnyOptions of the cycle profile built when cycle_profile is None.{}

setting_changes​

methodsource
setting_changes() -> pd.DataFrame

Every change of a held setting.

Returns
TypeDescription
DataFramePoint events: systime, uuid, source_uuid (the
DataFramesetting), before_value, after_value and
DataFramerecipe_parameter (the change came with a variant change).

setting_impact​

methodsource
setting_impact() -> pd.DataFrame

Before/after effect of every change on every metric.

Returns
TypeDescription
DataFrameOne row per change and metric: setting, change_ns,
DataFramebefore_value, after_value, metric
DataFrame(cycle_seconds, segment <from → to>, bad_parts,
DataFrameenergy <meter>), before_count, after_count,
DataFramebefore_median, after_median, shift (Hodges-Lehmann,
DataFrameafter - before), cliffs_delta_ratio, p_value,
DataFrameq_value, confounders, trend_before,
DataFramerecipe_parameter and confidence.

setting_register​

methodsource
setting_register() -> pd.DataFrame

What each setting does to the cycle time, over all its holds.

Returns
TypeDescription
DataFrameOne row per setting: setting, change_count,
DataFramevalues_seen, sensitivity_seconds_per_unit (Theil-Sen
DataFrameslope of the hold's median cycle time on the setting value),
DataFramebest_value_observed (the value with the shortest median
DataFramecycle) and potential_seconds (median cycle of the current
DataFramevalue minus that of the best).

evaluation_window​

methodsource
evaluation_window() -> pd.DataFrame

Whether the setting tests can be trusted, and why not.

Returns
TypeDescription
DataFrameOne row: scope (all), unit_count (setting changes),
DataFrameevaluable, reason (no_candidate_signal: held setting
DataFramewithout one), time_resolution_seconds, setting_count and
DataFramehigh_confidence_count (tests with high confidence).

summary​

methodsource
summary() -> dict[str, Any]

Headline numbers (JSON-able).

Returns
TypeDescription
dict[str, Any]evaluable, reason, change_count, setting_count and
dict[str, Any]best_cycle_time_change (the high-confidence change with the
dict[str, Any]largest cycle-time reduction, as "<setting>: a -> b").