Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

name: op-attr-reg-residual
description: Per-row residual yᵢ − ŷᵢ from an OLS refit during the attribute prepass.
kind: operator
category: ATTR
operator: ATTR_REG_RESIDUAL
type: reference
applies_to: process, compose, predict
examples_tags: [regression, ols, outlier-detection, buffered-pipeline]

Use when

Adds to every row its residual: the actual target value minus the value a straight-line model predicts for it.

Questions it answers:

  • Which stores sell far more or less than their size and footfall predict?
  • Do the model’s misses grow with the predicted value, or bend in a curve?

Use something else:

  • REG_OLS when you want the model’s summary (coefficients, R-squared).

Params

Refit keys are top-level; fit is params.fit (regression-row-scores).

NameTypeDefaultDescription
targetfield(required)Dependent field; absent with fit.
predictorslist(required)Independent fields; absent with fit.
penaltyenum"""", l1, l2, elasticnet.
alphafloat—Strength.
l1_ratiofloat—L1 mix.
fitstring—Bound fit (fits / models), no refit: y − score.
kindenumresponsepearson, deviance, working, standardized, studentized.
residual_typeenumpearsonkind standardized only; or deviance.
carryoverbooltrueCarry adstock (regression-order).
orderobject—{field, partition?}; needed to carry.
weightslot weightinheritednull opts out; WLS refit; not with fit.

Inputs

target / predictors: see ## Contract (decimal128 as its float64 echo, packed_bool 0/1).

  • label — default <TYPE>_<target>, with params.fit <TYPE>_<fit>

Output

One float64 per record — yᵢ − ŷᵢ; null (never 0) when the target or any predictor is null, NaN or ±Inf (counted in n_null). With an intercept Σ ≈ 0.

Reading the output

  • value: Actual minus predicted: the row’s target value minus the value the straight-line model predicts for it, in the target’s units. Over the rows used in an unpenalized fit the residuals average 0.
    • Sign: positive means the row’s target is above what the model predicts from its predictors; negative means the row’s target is below what the model predicts from its predictors.
    • Caveat: A residual is what this model leaves unexplained, not a measurement error and not the effect of any one thing left out: another set of predictors gives other residuals.

Contract

  • Types (target, predictor): date, datetime, decimal128, f32, f64, packed_bool, u16, u32, u4, u64, u8; any other scalar type is PULSE_FIELD_TYPE_UNSUPPORTED.
  • Weight: weighted under frequency and probability weights.
  • Streaming: streamable.

Gotchas

See