Inventory Statistics
Computes per-partition inventory KPIs — current inventory count, rolling sales counts, days-supply, and (optionally) average days-on-lot — grouped by configurable dimensions like dealer, neighborhood, country, or carline.
The component is a pure aggregation engine over enriched inventory: it does no date arithmetic of its own, but applies a configurable rolling window over the sold_date_column provided by Inventory Enrichment. One Dagster asset is emitted per grouping, partitioned by day.
Inputs
inventory— Enriched inventory asset key. Defaults to<oem>/consolidated/inventory; typically set to<oem>/inventory_enrichedso sold-date and active-filter columns are present.joins— Reference tables left-joined onto inventory before aggregation, exposing the dimension columns referenced bygroup_by(e.g. dealer → country, model → carline).sold_date_column— Column used for the rolling sales window. May be all-null for OEMs without a sold-date signal — KPIs degrade gracefully (inferred_sales_count_{n}D = 0,days_supply_{n}D = inf).days_on_lot_column— Optional. When set, every grouping also emitsavg_days_on_lot_{n}Dper window.active_filter— Polars-SQL expression selecting active vehicles forcurrent_inventory_count. Omit to count all rows.windows— Rolling window sizes in days (default[90]).
Groupings
Each grouping defines the GROUP BY dimensions for one output asset:
type: ai_core.components.InventoryStatisticsComponent
attributes:
oem: mb
name: inventory_statistics
start_date: "2025-01-01"
inventory: mb/inventory_enriched
sold_date_column: inferred_sold_date
days_on_lot_column: days_on_lot
active_filter: "inferred_sold_date IS NULL"
windows: [90]
joins:
- asset: mb/consolidated/dealers
join_on: [dealer_id]
fields: [country]
- asset: mb/dealers/neighborhoods
join_on: [dealer_id]
fields: [neighborhood]
- asset: mb/consolidated/models
join_on: [model_id]
fields: [carline_id]
groupings:
- key: dealer_neighborhood
group_by: [dealer_id, neighborhood]
- key: country
group_by: [country]
- key: carline
group_by: [carline_id]
- key: dealer_model
group_by: [dealer_id, model_id]
| Field | Description |
|---|---|
key | Leaf segment of the asset key. Lands at <oem>/inventory_stats/<key> |
group_by | Columns to aggregate by. Must be present on the joined frame |
Output columns
Each grouping asset contains the group_by columns followed by:
| Column | Description |
|---|---|
current_inventory_count | Row count after applying active_filter (or all rows if unset) |
inferred_sales_count_{n}D | Rows with sold_date_column in [partition_date − n, partition_date) |
days_supply_{n}D | current_inventory_count / (inferred_sales_count_{n}D / n) — inf when no sales fall in the window |
avg_days_on_lot_{n}D | Mean days_on_lot_column across the same sold-window (only when days_on_lot_column is set) |
{n} substitutes each entry from windows.
Downstream consumers
The grouping assets feed two parts of the derived graph:
- Days on Lot — Joined onto each vehicle as features for both training and inference. Configurable per stats input via
stats_inputs. - Take Rates —
inventory_stats/countryis implicitly joined onto every featurized vehicle so attribute aggregations have country-scope context.