inventory_monitoring
inventory_monitoring ¤
Inventory monitoring events for supply chain timeseries.
Detects low stock intervals, calculates consumption rates, identifies reorder point breaches, and predicts stockouts.
InventoryMonitoringEvents ¤
InventoryMonitoringEvents(
dataframe: DataFrame,
level_uuid: str,
*,
event_uuid: str = "sc:inventory",
value_column: str = "value_double",
time_column: str = "systime"
)
Bases: Base
Monitor inventory levels from a timeseries signal and detect supply chain events.
Each inventory level is tracked via a UUID signal whose numeric value represents the current stock quantity.
Example usage
tracker = InventoryMonitoringEvents(df, level_uuid='warehouse_a_level') low = tracker.detect_low_stock(min_level=100, hold='5min') rate = tracker.consumption_rate(window='1h') breach = tracker.reorder_point_breach(reorder_level=200, safety_stock=50) prediction = tracker.stockout_prediction(consumption_rate_window='4h')
Initialize inventory monitoring.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
Input DataFrame with timeseries data. |
required |
level_uuid
|
str
|
UUID of the inventory level signal. |
required |
event_uuid
|
str
|
UUID assigned to generated events. |
'sc:inventory'
|
value_column
|
str
|
Column containing numeric inventory levels. |
'value_double'
|
time_column
|
str
|
Name of timestamp column. |
'systime'
|
detect_low_stock ¤
detect_low_stock(
min_level: float, hold: str = "0s"
) -> pd.DataFrame
Flag intervals where inventory stays below min_level for at least hold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
min_level
|
float
|
Threshold below which stock is considered low. |
required |
hold
|
str
|
Minimum duration the level must stay below threshold
(e.g. |
'0s'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: start, end, uuid, source_uuid, is_delta, |
DataFrame
|
min_value, avg_value, duration_seconds. |
consumption_rate ¤
consumption_rate(window: str = '1h') -> pd.DataFrame
Calculate rolling consumption rate from inventory level decreases.
Only considers intervals where the level decreased (consumption). The rate is expressed as units consumed per hour within each window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
str
|
Time-based window for grouping (e.g. |
'1h'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: window_start, uuid, is_delta, |
DataFrame
|
consumption_rate, level_start, level_end. |
reorder_point_breach ¤
reorder_point_breach(
reorder_level: float, safety_stock: float = 0.0
) -> pd.DataFrame
Detect when inventory falls below reorder point or safety stock level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reorder_level
|
float
|
The reorder point threshold. |
required |
safety_stock
|
float
|
Safety stock threshold (must be <= reorder_level). |
0.0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: systime, uuid, is_delta, current_level, |
DataFrame
|
breach_type ('reorder' or 'safety_stock'), deficit. |
stockout_prediction ¤
stockout_prediction(
consumption_rate_window: str = "4h",
) -> pd.DataFrame
Estimate time until stockout based on recent consumption rate.
For each data point, uses the consumption rate calculated over the preceding consumption_rate_window to project when inventory will reach zero.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
consumption_rate_window
|
str
|
Lookback window for calculating
consumption rate (e.g. |
'4h'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns: systime, uuid, is_delta, current_level, |
DataFrame
|
consumption_rate, estimated_stockout_time_hours. |