fitted_rule¶
Validated, JSON-serializable specifications for bounded fitted operators.
FittedRulePlan
¶
Bases: BaseModel
A bounded provider response containing only typed feature rules.
Source code in featcopilot/core/fitted_rule.py
FittedRuleSpec
¶
Bases: BaseModel
Specify one allowlisted feature without executable code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Unique output name, distinct from every input column. |
required |
operator
|
str
|
One of standardize, clip, frequency, group_mean, target_mean, rare_category, multiply, divide, or log1p. |
required |
columns
|
list[str]
|
One source column, except group_mean which takes [group, numeric_value]. Multiply takes two distinct numeric columns; divide takes distinct [numerator, denominator] columns. Log1p takes one numeric column. Sources must be original input columns, not other rule outputs. |
required |
parameters
|
dict
|
Operator-specific options. Clip accepts lower_quantile/upper_quantile (defaults 0.01/0.99); target_mean accepts nonnegative smoothing (default 10); rare_category accepts min_frequency (fraction, default 0.01) and other_label (default "other"). Other operators take none. |
required |
explanation
|
str
|
Human-readable purpose, retained with the fitted feature metadata. |
required |
Notes
Missing/nonfinite numerical values produce zero for standardize and clip. Standardization uses population standard deviation, unit scale for constant/all-missing training data, and saturates overflow to finite float64 limits. All-missing clipping bounds default to zero. Frequency uses training row fractions; missing and unknown categories produce zero. Group and target means use the training global mean for missing/unknown categories (zero if no valid group-mean values exist). Cross-fitted target means use only the fold's eligible training labels; the initial temporal prefix without a validation fold receives a fixed zero prior rather than any full-training target statistic. Numeric/boolean binary targets retain fixed 0/1 codes even if only one class is observed. Other binary labels use sorted class codes stored with the fitted state; comparisons of those codes assume a fixed label vocabulary. Rare-category rules require strings and map missing/unknown/rare values to other_label. Category keys distinguish strings, numbers and booleans. Multiply, divide and log1p are rowwise and learn no statistics. Log1p means log(1 + abs(x)), matching TabularEngine. Missing/nonfinite operands and zero denominators produce NaN; finite-input overflow saturates to float64 limits. These operators accept no parameters.