name: op-agg-mode
description: Most-frequent value of the field (ties broken by the smallest value).
kind: operator
category: AGG
operator: AGG_MODE
type: reference
applies_to: process, compose, predict
examples_tags: [cardinality-analysis, cross-tabulation]
Use when
Most common value of a field, over all rows or per group.
Questions it answers:
- What is the most common answer to the preferred-brand question?
- Which product is ordered most often in each store?
Use something else:
GROUP_CATEGORYwhen you want the count of every value, not only the top one: group by the field, then count.AGG_MEDIANwhen the field is numeric and you want its middle value.
Params
Weighted: the value with the largest Σw; count becomes that Σw (a float).
Inputs
field — admitted types: see ## Contract.
Output
Scalar float64 — the modal value (categorical: its dictionary index). Per-group under a grouper. A process chain admits it: a later stage reads that index as a CODE — a numeric reader over it (a sum, mean, min, …) is PULSE_FIELD_TYPE_UNSUPPORTED (forwarded_code); a packed_bool 0/1 mode still sums.
Components
value— Most-frequent valuecount— Row count of the modal value (weighted: Σw)distinct_count— Distinct values observedtie_count— Values tied at the max count
Contract
- Types (
field):categorical_*,date,datetime,f32,f64,packed_bool,u16,u32,u4,u64,u8; any other scalar type isPULSE_FIELD_TYPE_UNSUPPORTED;decimal128isPULSE_AGG_NOT_MEANINGFUL_FOR_DECIMAL. - Weight: weighted under
frequencyandprobabilityweights. - Streaming: streamable; components
partial. - Components:
n,n_null,value,count,distinct_count,tie_count; optionalsum_weights,n_eff,n_weight_invalid.
Gotchas
- Ties go to the SMALLEST value (or index), not the first seen;
tie_count > 1flags a tie. - High cardinality costs memory; pre-filter.
- No non-null value →
null(NaN), never 0. - Over
categorical_*/packed_boolthe value is a CODE: an overlay scoring it (any host;params.field, elseaggregations[0]) is refusedPROCESSING_CONFIG, reasoncategorical_code(+field,field_type). So is a crosstab (or Compose crosstab slot) whose CELL is a code, under any kind that reads cell values (slot/hostthe cell path; the moment pairwise kinds read none). Score a count or share instead. Code-ness survives a process chain: a later stage’s column written by a code-emitting aggregation is still a code (field_typeits origin type), soAGG_MODEover it, scored, is refused too.
See
pulse_examples_search tags=[cardinality-analysis]- Skills:
aggregation-design,response-components