Skip to content

roc registry metadata reports zero lookback despite period-dependent warmup #19

Description

@admin-cxcoast

Summary

At commit e3fcf1d9adc656b722e1f358241fa3bd7df4dfbd, the public feature catalog reports no parameters and a zero lookback for roc. Computing the registered feature with period=20, however, produces 20 leading nulls and its first value at index 20.

This makes registry-driven warmup planning understate the history required by ROC.

Environment

  • ml4t-engineer commit: e3fcf1d9adc656b722e1f358241fa3bd7df4dfbd
  • installed package: ml4t-engineer==0.1.0b10.dev6+ge3fcf1d9a
  • Python: 3.12.3
  • Polars: 1.42.1
  • Network: not required

Minimal reproduction

This self-contained example uses public APIs and a 21-row OHLCV Polars frame, the minimum needed to observe the first output for period=20:

import polars as pl
from ml4t.engineer import compute_features
from ml4t.engineer.discovery import features

period = 20
close = [float(100 + index) for index in range(period + 1)]
frame = pl.DataFrame(
    {
        "open": close,
        "high": [value + 1.0 for value in close],
        "low": [value - 1.0 for value in close],
        "close": close,
        "volume": [1.0] * len(close),
    }
)

metadata = features.describe("roc")
values = compute_features(
    frame, [{"name": "roc", "params": {"period": period}}]
).get_column("roc").to_list()
first_valid_index = next(
    (index for index, value in enumerate(values) if value is not None), None
)

print(metadata["parameters"], metadata["lookback_period"], first_valid_index)
assert metadata["lookback_period"] == first_valid_index

The complete offline reproduction in the reporting project was run with:

.venvs/engineer/bin/python reproductions/ml4t-engineer-registry-lookback.py

Output (exit status 1 is intentional while the issue is present):

environment: commit=e3fcf1d9adc656b722e1f358241fa3bd7df4dfbd package=0.1.0b10.dev6+ge3fcf1d9a python=3.12.3
expected: roc(period=20) registry_lookback=20
actual: parameters={} metadata_lookback=0 leading_nulls=20 first_valid_index=20
defect: registry lookback understates observed ROC warmup

Expected behavior

ROC's registry metadata should expose its default period and model lookback as parameter-dependent. A registry consumer planning roc(period=20) should obtain a lookback of 20, matching the 20 leading nulls emitted by the computation.

Actual behavior

features.describe("roc") returns:

{"parameters": {}, "lookback_period": 0, ...}

The registered decorator currently declares lookback=0 and does not declare parameter metadata, while the implementation accepts period (default 10) and shifts by that period.

Focused suggested fix

Declare ROC with the decorator's existing parameter-dependent metadata support, equivalent to:

lookback="period"
parameters={"period": 10}

A regression test could check both the default catalog description and lookback(period=20) == 20, plus agreement with the first non-null computed value.

Verified sibling scope

At the same pinned commit, public catalog descriptions for rocr and mom also report parameters == {} and lookback_period == 0; their decorators likewise declare lookback=0 while accepting a period. They may merit the same narrow metadata correction, but this reproduction intentionally remains scoped to ROC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions