Skip to content

flow_metrics

flow_metrics ¤

Flow metrics and Little's Law analysis for production lines.

Treats a process as a queue between an entry signal and an exit signal and derives the classic flow metrics an industrial engineer relies on:

  • work in process (WIP) over time, time-weighted,
  • throughput (units out per window),
  • lead time (FIFO-matched entry -> exit),
  • a flow summary tying them together via Little's Law (WIP = throughput x lead_time) plus Process Cycle Efficiency.

Entry and exit are boolean signals; each rising edge is one unit.

FlowMetricsEvents ¤

FlowMetricsEvents(
    dataframe: DataFrame,
    entry_uuid: str,
    exit_uuid: str,
    *,
    event_uuid: str = "prod:flow",
    value_column: str = "value_bool",
    time_column: str = "systime"
)

Bases: Base

WIP, throughput, lead time and Little's Law metrics for a process.

Example usage::

flow = FlowMetricsEvents(df, entry_uuid="u_in", exit_uuid="u_out")
flow.wip_over_time(window="1h")
flow.throughput(window="1h")
flow.lead_time()
flow.flow_summary(value_add_seconds=120, window="1h")

Initialize the flow-metrics analyser.

Parameters:

Name Type Description Default
dataframe DataFrame

Input DataFrame with timeseries data.

required
entry_uuid str

UUID of the boolean unit-entry signal.

required
exit_uuid str

UUID of the boolean unit-exit signal.

required
event_uuid str

UUID to tag derived events with.

'prod:flow'
value_column str

Column holding the boolean trigger.

'value_bool'
time_column str

Name of the timestamp column.

'systime'

wip_over_time ¤

wip_over_time(window: str = '1h') -> pd.DataFrame

Time-weighted work-in-process per window.

Parameters:

Name Type Description Default
window str

Resample window (e.g. "1h").

'1h'

Returns:

Type Description
DataFrame

Summary-shape DataFrame with columns: start, end, duration_seconds,

DataFrame

wip_mean, wip_max, wip_min.

throughput ¤

throughput(window: str = '1h') -> pd.DataFrame

Units completed (exit rising edges) per window.

Parameters:

Name Type Description Default
window str

Resample window.

'1h'

Returns:

Type Description
DataFrame

Summary-shape DataFrame with columns: start, end, duration_seconds,

DataFrame

units_out, throughput_per_hour.

lead_time ¤

lead_time() -> pd.DataFrame

FIFO-matched lead time per unit (entry -> exit).

The nth entry is matched to the nth exit (first-in-first-out).

Returns:

Type Description
DataFrame

Point-shape DataFrame with columns: systime (exit time), uuid,

DataFrame

source_uuid, lead_time_seconds, unit_index.

flow_summary ¤

flow_summary(
    *,
    value_add_seconds: _Number | None = None,
    window: str = "1h"
) -> pd.DataFrame

Combined flow metrics with a Little's Law consistency check.

Little's Law lead time = WIP / throughput. consistency_ratio is the measured FIFO lead time divided by that prediction (≈ 1 for a stable, FIFO process). Process Cycle Efficiency = value-add time / lead time.

Parameters:

Name Type Description Default
value_add_seconds _Number | None

Value-add (touch) time per unit, for PCE. Seconds number or offset string; omit to skip the PCE column.

None
window str

Resample window.

'1h'

Returns:

Type Description
DataFrame

Summary-shape DataFrame with columns: start, end, duration_seconds,

DataFrame

wip_mean, throughput_per_hour, lead_time_mean_seconds,

DataFrame

littles_law_lead_time_seconds, consistency_ratio, and

DataFrame

process_cycle_efficiency_pct when value_add_seconds is given.