ts_shape.events.profiling.orders
Mapping-free order and scrap profiling.
On top of the cycle profile of one PLC
(:class:~ts_shape.events.profiling.cycles.CycleProfileEvents):
:func:counter_roles
Which counter is the total, the good and the bad count -- learned from
the identity good + bad = total per cycle (a lag of up to
:data:COUNTER_MAX_LAG_CYCLES cycles allowed), not from names. Equal
counters are aliases; a counter with non-integer increments is
energy-like (a meter).
:class:OrderProfileEvents
Which orders run slow or scrap the most? The order signal is found
with :func:~ts_shape.signals.identify.identify_objects (an identifier
held over many cycles), else the variant signal. Per order: cycles, run
and stop time, speed against the variant's best, good and bad parts and,
with a plan, the attainment.
:class:ScrapProfileEvents
What precedes a bad part? -- a scrap Pareto without reason codes. Every
cycle with a bad-counter increment is a NOK unit; its context (a stop in
the cycle, after a stop, after a changeover, a long cycle, an analog
deviation, and every rare discrete event in the cycle) is compared with
the context of good cycles by enrichment.
| Name | Description |
|---|---|
OrderProfileEvents | Production orders: setup, speed against the best, scrap, attainment. |
ScrapProfileEvents | What precedes a bad part: a scrap Pareto without reason codes. |
OrderProfileEvents
OrderProfileEvents(
dataframe: pd.DataFrame,
*,
cycle_profile: CycleProfileEvents | None = None,
signal_uuids: list[str] | None = None,
plan: pd.DataFrame | None = None,
order_uuid: str | None = None,
min_orders: int = 3,
time_column: str = "systime",
uuid_column: str = "uuid",
event_uuid: str = "prod:order_profile",
**cycle_options: Any
) -> None
Bases: _CounterMixin
Production orders: setup, speed against the best, scrap, attainment.
Example
>>> import ts_shape
>>> frame, truth = ts_shape.make_plc_cycles(
... n_cycles=300, seed=2, order_size=25, scrap_probability=0.03)
>>> orders = ts_shape.OrderProfileEvents(frame)
>>> orders.evaluation_window()["order_uuid"].iloc[0]
'plc:order_no'
| Name | Description |
|---|---|
order_records | One record per order. |
counter_roles | Roles of the counters (total, good, bad ...) learned from the data. |
order_register | Orders ranked by lost time, per variant. |
evaluation_window | Whether the order profile 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 |
plan | DataFrame | None | Optional plan with order_id and planned_quantity; adds planned_quantity and attainment_ratio. | None |
order_uuid | str | None | The order signal; None (default) finds it (an identifier held over many cycles, else the variant signal). | None |
min_orders | int | Fewer orders are not evaluable. | 3 |
time_column | str | Timestamp column. | 'systime' |
uuid_column | str | Signal column. | 'uuid' |
event_uuid | str | uuid of the order records. | 'prod:order_profile' |
**cycle_options | Any | Options of the cycle profile built when cycle_profile is None. | {} |
order_records
order_records() -> pd.DataFrame
One record per order.
| Type | Description |
|---|---|
DataFrame | Point events at the order end: systime, uuid, |
DataFrame | source_uuid (the order signal), unit_uuid (the order id), |
DataFrame | start_ns, end_ns, duration_seconds, variant, |
DataFrame | cycle_count, run_seconds (non-pause cycles), |
DataFrame | stop_seconds (pause cycles), median_cycle_seconds, |
DataFrame | speed_ratio (variant's best cycle / the order's median), |
DataFrame | loss_seconds (cycle time beyond the variant's best, pause |
DataFrame | cycles included), good_count, scrap_count, |
DataFrame | scrap_ratio and, with a plan, planned_quantity and |
DataFrame | attainment_ratio. |
counter_roles
counter_roles() -> pd.DataFrame
Roles of the counters (total, good, bad ...) learned from the data.
| Name | Type | Description |
|---|---|---|
See | DataFrame | func:~ts_shape.events.profiling._counters.counter_roles. |
order_register
order_register() -> pd.DataFrame
Orders ranked by lost time, per variant.
| Type | Description |
|---|---|
DataFrame | func:~ts_shape.events.profiling._base.potential_register |
DataFrame | of the orders' loss_seconds per variant, plus |
DataFrame | scrap_count and worst_order (the order with the most loss). |
evaluation_window
evaluation_window() -> pd.DataFrame
Whether the order profile can be trusted, and why not.
| Type | Description |
|---|---|
DataFrame | One row: scope, unit_count (orders), evaluable, |
DataFrame | reason (no_candidate_signal: order id without an order |
DataFrame | or variant signal), time_resolution_seconds, order_uuid |
DataFrame | and order_source (given, identifier or variant). |
summary
summary() -> dict[str, Any]
Headline numbers (JSON-able).
| Type | Description |
|---|---|
dict[str, Any] | evaluable, reason, order_count, order_uuid, |
dict[str, Any] | worst_order, worst_order_loss_hours and scrap_count. |
ScrapProfileEvents
ScrapProfileEvents(
dataframe: pd.DataFrame,
*,
cycle_profile: CycleProfileEvents | None = None,
signal_uuids: list[str] | None = None,
bad_uuid: str | None = None,
min_nok: int = 10,
time_column: str = "systime",
uuid_column: str = "uuid",
event_uuid: str = "prod:scrap_profile",
**cycle_options: Any
) -> None
Bases: _CounterMixin
What precedes a bad part: a scrap Pareto without reason codes.
Example
>>> import ts_shape
>>> frame, truth = ts_shape.make_plc_cycles(
... n_cycles=600, seed=4, scrap_probability=0.02, rampup_cycles=4,
... curve_faults={"late_rise": 0.05})
>>> scrap = ts_shape.ScrapProfileEvents(frame)
>>> scrap.evaluation_window()["bad_uuid"].iloc[0]
'plc:bad_counter'
| Name | Description |
|---|---|
nok_records | One record per cycle with a bad part. |
counter_roles | Roles of the counters (total, good, bad ...) learned from the data. |
scrap_pareto | Scrap contexts ranked: where bad parts are over-represented. |
evaluation_window | Whether the scrap profile 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 |
bad_uuid | str | None | The bad-part counter; None (default) learns it (:func:counter_roles). | None |
min_nok | int | Fewer cycles with a bad part are not evaluable. | 10 |
time_column | str | Timestamp column. | 'systime' |
uuid_column | str | Signal column. | 'uuid' |
event_uuid | str | uuid of the NOK records. | 'prod:scrap_profile' |
**cycle_options | Any | Options of the cycle profile built when cycle_profile is None. | {} |
nok_records
nok_records() -> pd.DataFrame
One record per cycle with a bad part.
| Type | Description |
|---|---|
DataFrame | Point events at the cycle end: systime, uuid, |
DataFrame | source_uuid (the bad counter), unit_uuid (the cycle), |
DataFrame | start_ns, end_ns, duration_seconds, variant, |
DataFrame | cycle_class, bad_count, context (every context label, |
DataFrame | ;-joined) and assigned_context (the significant context |
DataFrame | with the highest lift, or unexplained). |
counter_roles
counter_roles() -> pd.DataFrame
Roles of the counters (total, good, bad ...) learned from the data.
| Name | Type | Description |
|---|---|---|
See | DataFrame | func:~ts_shape.events.profiling._counters.counter_roles. |
scrap_pareto
scrap_pareto() -> pd.DataFrame
Scrap contexts ranked: where bad parts are over-represented.
| Type | Description |
|---|---|
DataFrame | One row per context (stop_in_cycle, after_stop, |
DataFrame | after_changeover, long_cycle, short_cycle, |
DataFrame | deviation <signal>:<stat>, curve <signal> (a curve-shape |
DataFrame | anomaly of the cycle profile), event <label>): context, |
DataFrame | nok_count (bad cycles with it), nok_share_ratio, |
DataFrame | rate_in_context_ratio (bad-cycle rate with the context), |
DataFrame | rate_outside_ratio, lift_factor, p_value, |
DataFrame | q_value and is_significant (q < 0.05, lift >= 2), |
DataFrame | significant contexts first by lift. |
evaluation_window
evaluation_window() -> pd.DataFrame
Whether the scrap profile can be trusted, and why not.
| Type | Description |
|---|---|
DataFrame | One row: scope (scrap), unit_count (cycles with a bad |
DataFrame | part), evaluable, reason (``no_candidate_signal: bad |
DataFrame | counterwithout one),time_resolution_seconds, bad_uuid`` |
DataFrame | and explained_share_ratio (bad cycles with a significant |
DataFrame | context). |
summary
summary() -> dict[str, Any]
Headline numbers (JSON-able).
| Type | Description |
|---|---|
dict[str, Any] | evaluable, reason, nok_cycle_count, bad_uuid, |
dict[str, Any] | top_context (the significant context with most bad cycles) |
dict[str, Any] | and explained_share_ratio. |