feature

feature

Named, versioned feature definitions and materialization.

q.feature owns the lifecycle of model inputs: metadata, point-in-time computation, feature sets, and persistence. Market measurements live in q.indicator; fitted training transformations live in q.preprocess.

Classes

Name Description
Feature One reproducible, scalar feature definition.
FeatureSet Features sharing one entity and timestamp contract.

Feature

feature.Feature(
    name,
    function,
    inputs,
    params=dict(),
    entity_keys=('symbol',),
    timestamp='datetime',
    version='1',
    lookback=None,
    available_at=None,
)

One reproducible, scalar feature definition.

Parameters

Name Type Description Default
name str Stable output-column name. required
function FeatureFunction Callable returning one Series. required
inputs Mapping[str, str] Mapping from callable argument names to source columns. required
params Mapping[str, Any] Fixed keyword arguments passed to function. dict()
entity_keys tuple[str, …] Columns that identify independent entities. Computation is applied separately to each entity to prevent history leakage. ('symbol',)
timestamp str Column defining observation order and feature availability. 'datetime'
version str Definition version stored alongside the feature name. '1'
lookback int | None Required history in rows, when known. None
available_at str | None Human-readable availability boundary such as "bar_close". This is metadata, not a scheduling instruction. None

Attributes

Name Description
identity Return the stable name:version identity.

FeatureSet

feature.FeatureSet(features, *, name='default', version='1')

Features sharing one entity and timestamp contract.

Functions

Name Description
compute Compute a feature set without crossing entity boundaries.
materialize Compute a feature set and write it to a database-like sink.

compute

feature.compute(features, data)

Compute a feature set without crossing entity boundaries.

The source must already be ordered by timestamp within each entity. qrt validates this invariant instead of silently sorting database extracts. Entity and timestamp columns are retained for point-in-time persistence.

materialize

feature.materialize(features, data, sink, *, table)

Compute a feature set and write it to a database-like sink.

Back to top