rheon.spec.output_fields

rheon.spec.output_fields(spec: dict[str, Any]) → list[str][source]

List the names of the fields a spec writes, in order.

Use it to see a spec’s fields before any row is fed: the fields are fixed by the spec. For a whole bank, read rheon.polars.ModelBank.output_fields, and for what each field is, with the values its name encodes, use output_index().

Parameters

spec

A spec, as a builder of rheon.spec returns it.

Returns

The field names, in the order the output column holds them.

Raises

ValueError

spec is not a valid spec, with the builders’ message. A value that is not a spec at all is told what it lacks, such as invalid spec: missing field `name`.

Examples

spec = rp.spec.ewridge(
    "ridge", targets=["y"], features=["x0", "x1"], half_life=100.0, ridge=[1e-6, 0.1]
)
fields = rp.spec.output_fields(spec)
print(fields[:4])                         # each ridge value's prediction and residual
print(fields[4:])                         # the fields the ridge values share
['pred_y__r0.000001', 'resid_y__r0.000001', 'pred_y__r0.1', 'resid_y__r0.1']
['weight_sum', 'settled_frac', 'withheld_reason', 'coef', 'support_coef']

See also