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) orlow.
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).
| Name | Description |
|---|---|
SettingImpactEvents | Before/after effect of every change of a held setting. |
SettingImpactEvents
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')
| Name | Description |
|---|---|
setting_changes | Every change of a held setting. |
setting_impact | Before/after effect of every change on every metric. |
setting_register | What each setting does to the cycle time, over all its holds. |
evaluation_window | Whether the setting tests can be trusted, and why not. |
summary | Headline numbers (JSON-able). |
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | Long-format signals of one PLC. | required |
cycle_profile | CycleProfileEvents | None | A computed cycle profile of the same signals to reuse; None (default) builds one. | None |
signal_uuids | list[str] | None | Signals to use (default: all). | None |
window_cycles | int | Cycles compared before and after a change (at most; a window ends at the previous or next setting change). | 30 |
settle_cycles | int | Cycles right after a change left out (the process settles). | 3 |
min_window_cycles | int | A side with fewer cycles makes the test low confidence. | 10 |
time_column | str | Timestamp column. | 'systime' |
uuid_column | str | Signal column. | 'uuid' |
event_uuid | str | uuid of the change records. | 'prod:setting_impact' |
**cycle_options | Any | Options of the cycle profile built when cycle_profile is None. | {} |
setting_changes
setting_changes() -> pd.DataFrame
Every change of a held setting.
| Type | Description |
|---|---|
DataFrame | Point events: systime, uuid, source_uuid (the |
DataFrame | setting), before_value, after_value and |
DataFrame | recipe_parameter (the change came with a variant change). |
setting_impact
setting_impact() -> pd.DataFrame
Before/after effect of every change on every metric.
| Type | Description |
|---|---|
DataFrame | One row per change and metric: setting, change_ns, |
DataFrame | before_value, after_value, metric |
DataFrame | (cycle_seconds, segment <from → to>, bad_parts, |
DataFrame | energy <meter>), before_count, after_count, |
DataFrame | before_median, after_median, shift (Hodges-Lehmann, |
DataFrame | after - before), cliffs_delta_ratio, p_value, |
DataFrame | q_value, confounders, trend_before, |
DataFrame | recipe_parameter and confidence. |
setting_register
setting_register() -> pd.DataFrame
What each setting does to the cycle time, over all its holds.
| Type | Description |
|---|---|
DataFrame | One row per setting: setting, change_count, |
DataFrame | values_seen, sensitivity_seconds_per_unit (Theil-Sen |
DataFrame | slope of the hold's median cycle time on the setting value), |
DataFrame | best_value_observed (the value with the shortest median |
DataFrame | cycle) and potential_seconds (median cycle of the current |
DataFrame | value minus that of the best). |
evaluation_window
evaluation_window() -> pd.DataFrame
Whether the setting tests can be trusted, and why not.
| Type | Description |
|---|---|
DataFrame | One row: scope (all), unit_count (setting changes), |
DataFrame | evaluable, reason (no_candidate_signal: held setting |
DataFrame | without one), time_resolution_seconds, setting_count and |
DataFrame | high_confidence_count (tests with high confidence). |
summary
summary() -> dict[str, Any]
Headline numbers (JSON-able).
| Type | Description |
|---|---|
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"). |