Skip to content

Primitives reference

featurizer registers 67 aggregations (applied across backward relationships, parent ← child) and 83 transformers (applied to features within an entity). This page is generated from the registry at build time, so it cannot drift from the code. Select primitives per config with the aggregations: / transformations: keys — see the configuration reference.

Discover the same information from the CLI:

Terminal window
uv run python -m featurizer list-primitives --type agg --show-sql
primitivedescriptionSQL example
countCount of non-null valuesCOUNT(status)
maxMaximum valueMAX(amount)
meanArithmetic mean (average)AVG(amount)
minMinimum valueMIN(amount)
nuniqueCount of distinct valuesCOUNT(DISTINCT status)
stddevStandard deviationSTDDEV(amount)
sumSum of all valuesSUM(amount)
varianceStatistical varianceVARIANCE(amount)
primitivedescriptionSQL example
allTrue if all values are true (boolean AND)BOOL_AND(is_active)
anyTrue if any value is true (boolean OR)BOOL_OR(is_active)
primitivedescriptionSQL example
kl_driftKL divergence: recent vs prior-window category distributionSUM(p_recent * LN(p_recent / p_baseline)) over shared support
wasserstein_driftQuantile L1 drift: recent vs prior-window numeric distribution|q10_r - q10_b| + |q50_r - q50_b| + |q90_r - q90_b|
primitivedescriptionSQL example
gap_cvCoefficient of variation of inter-event gapsSTDDEV(gap) / NULLIF(AVG(gap), 0)
gap_maxMaximum inter-event gap durationMAX(ts - LAG(ts) OVER (ORDER BY ts))
gap_meanMean inter-event gap durationAVG(ts - LAG(ts) OVER (ORDER BY ts))
gap_minMinimum inter-event gap durationMIN(ts - LAG(ts) OVER (ORDER BY ts))
gap_stddevStandard deviation of inter-event gapsSTDDEV(ts - LAG(ts) OVER (ORDER BY ts))
primitivedescriptionSQL example
entropyShannon entropy of categorical distribution-SUM(p * LN(p)) where p = COUNT(val) / SUM(COUNT(val))
giniGini coefficient (inequality measure, 0-1)2 * SUM(rank * val) / (n * SUM(val)) - (n+1)/n
hhiHerfindahl-Hirschman Index (concentration measure)SUM(p^2) where p = COUNT(val) / SUM(COUNT(val))
theilTheil-T inequality index over positive valuesAVG((x/mean) * LN(x/mean))
primitivedescriptionSQL example
geometric_meanGeometric mean (for growth rates)EXP(AVG(LOG(value)))
harmonic_meanHarmonic mean (for rates and ratios)COUNT(value) / SUM(1.0/value)
trimmed_mean_10Mean of values within the 10th-90th percentile rangeAVG(x) WHERE x BETWEEN p10 AND p90
primitivedescriptionSQL example
medianMedian value (50th percentile)PERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY amount)
modeMost frequent valueMODE() WITHIN GROUP (ORDER BY status)
p1010th percentilePERCENTILE_CONT(0.10) WITHIN GROUP (ORDER BY amount)
p2525th percentile (first quartile)PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY amount)
p7575th percentile (third quartile)PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY amount)
p9090th percentilePERCENTILE_CONT(0.90) WITHIN GROUP (ORDER BY amount)
p9595th percentilePERCENTILE_CONT(0.95) WITHIN GROUP (ORDER BY amount)
p9999th percentilePERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY amount)
primitivedescriptionSQL example
longest_streakLongest consecutive streak of same valueMAX(streak_length) using gaps-and-islands
ngram_2_freqBigram frequency distribution of categorical sequencesCOUNT(DISTINCT val || '->' || LEAD(val)) / COUNT(*)
ngram_3_freqTrigram frequency distribution of categorical sequencesCOUNT(DISTINCT val || '->' || LEAD(val,1) || '->' || LEAD(val,2)) / COUNT(*)
sequence_entropyTransition entropy of categorical sequences-SUM(p_ij * LN(p_ij)) over transition matrix
primitivedescriptionSQL example
bbox_areaApproximate latitude-corrected bounding-box area (m^2)(max(lat)-min(lat))*(max(lon)-min(lon))*cos(avg(lat))*111320^2
distance_travelledTotal great-circle distance over consecutive events (m)SUM(haversine(lag(lat,lon), (lat,lon)))
radius_of_gyrationRMS great-circle distance of events from their centroid (m)sqrt(AVG(haversine(centroid, point)^2))
spatial_stdDegree-space dispersion: sqrt(var(lat) + var(lon))sqrt(var_samp(lat) + var_samp(lon))
primitivedescriptionSQL example
markov_conditional_entropyFirst-order Markov entropy rate H(X_t | X_{t-1}) in nats-SUM(p(i,j) * LN(p(j|i))) over the transition matrix
max_transition_probPredictability: largest conditional transition probabilityMAX(freq / row_total) over the transition matrix
recurrence_intervalMean days between consecutive occurrences of the same stateAVG(ts - LAG(ts) OVER (PARTITION BY value ORDER BY ts))
rework_countCount of consecutive repeats (self-loops, prev == curr)count(*) WHERE prev = curr
state_volatilityCount of categorical value changes over timecount(*) WHERE prev IS DISTINCT FROM curr
time_in_current_stateDays since the most recent change of a categorical attributeaod.as_of_date - max(ts WHERE value changed)
transition_matrix_summaryNumber of distinct observed (prev -> curr) transitionscount(DISTINCT (prev, curr))
primitivedescriptionSQL example
cvCoefficient of variation (STDDEV / MEAN)STDDEV(amount) / NULLIF(AVG(amount), 0)
iqrInterquartile range (P75 - P25)PERCENTILE_CONT(0.75) WITHIN GROUP (ORDER BY amount) - PERCENTILE_CONT(0.25) WITHIN GROUP (ORDER BY amount)
kurtosisMeasure of distribution tailedness((value - AVG(value)) / STDDEV(value))^4
mean_deviationAverage absolute deviation from the mean (two-pass subquery)AVG(ABS(value - (SELECT AVG(value) ...)))
median_absolute_deviationRobust spread: median(|x - median(x)|)percentile_cont(0.5) WITHIN GROUP (ORDER BY abs(x - median))
rangeRange (MAX - MIN)MAX(amount) - MIN(amount)
skewnessMeasure of distribution asymmetry((value - AVG(value)) / STDDEV(value))^3
variance_ratioVariance ratio: var(value) / var(first difference)var_samp(x) / NULLIF(var_samp(x - LAG(x)), 0)
primitivedescriptionSQL example
cross_type_latencyMean seconds from an A-typed event to the next B-typed eventAVG(MIN(b.ts) - a.ts) for a=A-rows, b=next B-rows
first_passage_timeDays from the first event to the first ‘target’ state (else NULL)MIN(ts) FILTER (WHERE col = 'target') - MIN(ts)
right_censoring_indicator1 if the terminal event has not occurred by t0 (censored)(count(*) FILTER (WHERE col = 'terminal') = 0)::int
primitivedescriptionSQL example
age_in_systemAlias of tenure: days since the first observed eventaod.as_of_date - min(event_ts)
event_rateEvents per unit timeCOUNT(*) / EXTRACT(EPOCH FROM MAX(ts) - MIN(ts))
inter_event_hazard_proxyEvents per day over the observed lifespan (count / tenure)count(*) / (aod.as_of_date - min(event_ts))
recencyDays since the most recent event (aod - max event ts)aod.as_of_date - max(event_ts)
tenureDays since the first observed event (age in system)aod.as_of_date - min(event_ts)
time_spanTime span between first and last eventEXTRACT(EPOCH FROM MAX(ts) - MIN(ts))
primitivedescriptionSQL example
acf_1Lag-1 autocorrelation: corr(x_t, x_{t-1})corr(x, LAG(x,1) OVER (ORDER BY ts))
burstinessGoh-Barabasi burstiness index (-1 to 1)(STDDEV(gap) - AVG(gap)) / NULLIF(STDDEV(gap) + AVG(gap), 0)
cosinor_amplitude_weeklyWeekly cosinor amplitude (sin/cos regression approximation)sqrt(regr_slope(x,sin)^2 + regr_slope(x,cos)^2)
primitivedescriptionSQL example
identityPass-through (no transformation)column_name
primitivedescriptionSQL example
daily_binBin days into weekday/weekendCASE WHEN dow < 6 THEN 'weekday' ELSE 'weekend' END
hourly_binBin hours into time-of-day categoriesCASE WHEN hour < 5 THEN 'night' ... END
primitivedescriptionSQL example
in_arrayCheck if value is in arrayvalue = ANY(ARRAY[...])
is_nullCheck if value is null(value IS NULL)
primitivedescriptionSQL example
cusumCUSUM: cumulative sum of deviations from target meanSUM(value - target_mean) OVER (PARTITION BY id ORDER BY date)
mean_shift_ratio_14Ratio of recent 14-period mean to overall mean (change-point detection)AVG(value) OVER (... ROWS 13 PRECEDING) / NULLIF(AVG(value) OVER (), 0)
mean_shift_ratio_7Ratio of recent 7-period mean to overall mean (change-point detection)AVG(value) OVER (... ROWS 6 PRECEDING) / NULLIF(AVG(value) OVER (), 0)
primitivedescriptionSQL example
cum_countCumulative count over timeCOUNT(value) OVER (PARTITION BY id ORDER BY date)
cum_maxCumulative maximum over timeMAX(value) OVER (PARTITION BY id ORDER BY date)
cum_meanCumulative mean over timeAVG(value) OVER (PARTITION BY id ORDER BY date)
cum_minCumulative minimum over timeMIN(value) OVER (PARTITION BY id ORDER BY date)
cum_sumCumulative sum over timeSUM(value) OVER (PARTITION BY id ORDER BY date)
cumprodRunning product via log-sum-exp (positive series only)exp(sum(ln(value)) OVER (PARTITION BY id ORDER BY date))
primitivedescriptionSQL example
cyclic_dayDay of week as sin/cos pair for cyclical encodingSIN(dow * 2*PI/7), COS(dow * 2*PI/7)
cyclic_hourHour as sin/cos pair for cyclical encodingSIN(hour * 2*PI/24), COS(hour * 2*PI/24)
cyclic_monthMonth as sin/cos pair for cyclical encodingSIN((month-1) * 2*PI/12), COS((month-1) * 2*PI/12)
primitivedescriptionSQL example
centuryCentury numberTO_CHAR(date, 'CC')
dayDay of month (1-31)TO_CHAR(date, 'DD')
domDay of month (DD format)TO_CHAR(date, 'DD')
dowISO day of week (1=Monday to 7=Sunday)TO_CHAR(date, 'ID')
doyDay of year (1-366)TO_CHAR(date, 'DDD')
hourHour (0-23)TO_CHAR(date, 'HH24')
monthMonth number (1-12)TO_CHAR(date, 'MM')
quarterQuarter of year (1-4)TO_CHAR(date, 'Q')
tzTime zone abbreviationTO_CHAR(date, 'TZ')
tz_offsetTime zone offsetTO_CHAR(date, 'OF')
weekWeek of monthTO_CHAR(date, 'W')
week_of_yearWeek of year (1-53)TO_CHAR(date, 'WW')
yearFour-digit yearTO_CHAR(date, 'YYYY')
primitivedescriptionSQL example
cdfCumulative distribution function valueCUME_DIST() OVER (PARTITION BY id ORDER BY value)
ntileDivide into N equal groups (default: 5)NTILE(5) OVER (PARTITION BY id ORDER BY value)
percent_rankRelative rank as percentage (0-1)PERCENT_RANK() OVER (PARTITION BY id ORDER BY value)
primitivedescriptionSQL example
ema_1414-period exponential moving averageSUM(value * EXP(decay * t)) / SUM(EXP(decay * t)) OVER (...)
ema_77-period exponential moving averageSUM(value * EXP(decay * t)) / SUM(EXP(decay * t)) OVER (...)
primitivedescriptionSQL example
holt_winters_level_1414-period Holt-Winters levelAVG(value) OVER (... ROWS BETWEEN 13 PRECEDING AND CURRENT ROW)
holt_winters_level_77-period Holt-Winters level (smoothed average)AVG(value) OVER (... ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
holt_winters_trend_1414-period Holt-Winters trendREGR_SLOPE(value, time) OVER (...)
holt_winters_trend_77-period Holt-Winters trend (slope)REGR_SLOPE(value, time) OVER (...)
primitivedescriptionSQL example
lag_1Value from 1 period agoLAG(value, 1) OVER (PARTITION BY id ORDER BY date)
lag_3Value from 3 periods agoLAG(value, 3) OVER (PARTITION BY id ORDER BY date)
lag_7Value from 7 periods agoLAG(value, 7) OVER (PARTITION BY id ORDER BY date)
primitivedescriptionSQL example
absAbsolute valueABS(value)
cbrtCube rootCBRT(value)
ceilRound up to nearest integerCEIL(value)
expExponential (e^x)EXP(value)
floorRound down to nearest integerFLOOR(value)
lnNatural logarithmLN(value)
logBase-10 logarithmLOG(value)
signSign of value (-1, 0, or 1)SIGN(value)
sqrtSquare rootSQRT(value)
truncTruncate decimal portionTRUNC(value)
primitivedescriptionSQL example
pct_change_1Percentage change from 1 period ago(value - LAG(value, 1)) / LAG(value, 1)
pct_change_3Percentage change from 3 periods ago(value - LAG(value, 3)) / LAG(value, 3)
primitivedescriptionSQL example
cross_entity_percentilePercentile rank across all entities in the populationPERCENT_RANK() OVER (ORDER BY value)
cross_entity_zscoreZ-score normalized across all entities in the population(value - AVG(value) OVER ()) / NULLIF(STDDEV(value) OVER (), 0)
primitivedescriptionSQL example
rolling_iqr_1414-period rolling interquartile rangePERCENTILE_CONT(0.75) - PERCENTILE_CONT(0.25) OVER (...)
rolling_iqr_77-period rolling interquartile range (P75 - P25)PERCENTILE_CONT(0.75) - PERCENTILE_CONT(0.25) OVER (...)
rolling_mean_1414-period rolling meanAVG(value) OVER (... ROWS BETWEEN 13 PRECEDING AND CURRENT ROW)
rolling_mean_33-period rolling meanAVG(value) OVER (... ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
rolling_mean_77-period rolling meanAVG(value) OVER (... ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
rolling_median_55-period rolling medianPERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY value) OVER (...)
rolling_median_77-period rolling medianPERCENTILE_CONT(0.5) WITHIN GROUP (ORDER BY value) OVER (...)
rolling_std_1414-period rolling standard deviationSTDDEV(value) OVER (... ROWS BETWEEN 13 PRECEDING AND CURRENT ROW)
rolling_std_33-period rolling standard deviationSTDDEV(value) OVER (... ROWS BETWEEN 2 PRECEDING AND CURRENT ROW)
rolling_std_77-period rolling standard deviationSTDDEV(value) OVER (... ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)
primitivedescriptionSQL example
avg_word_lengthMean characters per wordnon_space_chars::numeric / nullif(num_words, 0)
caps_ratioUppercase letters / all lettersupper_letters::numeric / nullif(all_letters, 0)
digit_ratioDigits / all charactersdigit_chars::numeric / nullif(length(text), 0)
exclamation_countCount of ’!’ characterslength(text) - length(replace(text, '!', ''))
num_charsCharacter count in textCHAR_LENGTH(text)
num_sentencesSentence-terminator count (. ! ?)length(text) - length(regexp_replace(text, '[.!?]', '', 'g'))
num_wordsWhitespace-delimited word count(SELECT count(*) FROM regexp_split_to_table(text, '\s+') t(w) WHERE w <> '')
punct_ratioPunctuation / all characterspunct_chars::numeric / nullif(length(text), 0)
question_countCount of ’?’ characterslength(text) - length(replace(text, '?', ''))
unique_word_ratioDistinct words / total words (type-token ratio)distinct_words::numeric / nullif(num_words, 0)
primitivedescriptionSQL example
diffDifference from previous valuevalue - LAG(value) OVER (...)
diff2Second difference (acceleration): x - 2*lag1 + lag2value - 2*LAG(value,1) OVER w + LAG(value,2) OVER w
diff3Third difference (jerk): x - 3lag1 + 3lag2 - lag3value - 3*LAG(value,1) + 3*LAG(value,2) - LAG(value,3) OVER w
firstFirst value in partitionFIRST_VALUE(value) OVER (PARTITION BY id ORDER BY date)
lastLast value in partitionLAST_VALUE(value) OVER (PARTITION BY id ORDER BY date)
previousPrevious row’s valueLAG(value) OVER (PARTITION BY id ORDER BY date)
time_since_previousTime elapsed since previous recorddate - LAG(date) OVER (...)