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-fitted
description: Per-row fitted value ŷᵢ = Xᵢ · β + β₀ from an OLS refit during the attribute prepass.
kind: operator
category: ATTR
operator: ATTR_REG_FITTED
type: reference
applies_to: process, compose, predict
examples_tags: [regression, ols, buffered-pipeline]

Use when

Adds to every row the value a straight-line model predicts for its target from its predictors.

Questions it answers:

  • What order value would we expect for each customer given their visits and tenure?
  • Which stores sell above or below what their size and footfall predict?

Use something else:

  • REG_OLS when you want the coefficients, R-squared and p-values of the model.
  • REG_GLM when the target is yes/no or a count.

Params

Refit keys are top-level, not params; 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—Regularization strength.
l1_ratiofloat—Elasticnet mix.
fitstring—Bound fit (fits / models), no refit: its score (a GLM’s fitted mean); no refit keys.
carryoverbooltrueCarry adstock (regression-order).
orderobject—{field, partition?}; needed to carry.
weightslot weightinheritednull opts out; a WLS refit; ignored 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 — the model’s prediction ŷᵢ. Null (never 0) when any predictor is null, NaN or ±Inf, so a downstream aggregation counts the row in n_null; a null target alone still gets ŷᵢ.

Reading the output

  • value: The target value the fitted straight-line model predicts for the row from its predictors: intercept + sum(coefficient * predictor), in the target’s units. The model is fitted by least squares to the rows that passed the filters and have the target and every predictor.
    • Caveat: The model describes association in these rows: a fitted value is what rows with these predictor values look like here, not what would happen to a row if a predictor were changed; a causal reading needs a design that supports it.

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

  • Two-pass: each slot refits on its own. With params.fit row-local (two-pass with order), the bound model’s score bit for bit; refusals, failed fit (PULSE_FIT_UNAVAILABLE, all null): regression-row-scores.
  • A penalty shrinks coefficients toward zero when alpha / l1_ratio is mis-tuned.

See