rheon.spec.output_index¶
- rheon.spec.output_index(spec: dict[str, Any]) _Frame[source]¶
List every field a spec writes, with the values its name encodes.
Use it to reach a field without building its name by hand, by filtering on what the field is about, such as its target, its ridge value and its half-life. For the names alone, use
output_fields(), and for each coefficient’s place in acoeflist,coef_fields().Parameters
specA spec, as a builder of
rheon.specreturns it.
Returns
A frame with one row per field, in the output column’s order. No two rows hold the same values apart from
field, so a filter on the other columns reaches each field alone. Its columns:fieldThe name, as it appears in the output column.
kindWhat it is:
pred,resid,sigma,weight_sum,coef,penalty_selected,selected, a statistic’s stem, and so on.targetThe target the field is about, or null.
instanceThe instance the field belongs to, by its suffix, as
coef(),gram()andclosed_groups()name it:"@h500", or""for a single instance. Null on a field that chooses across the instances (emit_selected,emit_averaged) and on the clocks, which are the spec’s own.half_life,lamThe decay of the instance the field belongs to, filled for a single instance as for a grid.
half_lifeis the instance’s half-life in clock units, in seconds under a duration (300.0for"5m"),inffor an infinite one, and null underlam.lamis the spec’slam, and null under a half-life.ridge,feature_set,penaltyThe grid point: the ridge value, the feature set’s name and the lasso penalty, each null where the spec has no such grid.
quantileThe level of a
resid_quantilesormahal_quantilesfield.lagThe lag, in learned rows, of an
ew_covlag_corrfield.componentThe principal component of an
ew_covpc<j>_*field.stateThe hidden state an
hmmposterior is about (filtered_state<s>,predicted_state<s>).classThe class an
ew_classposterior is about (p_<class>).columnsThe columns the field is computed from:
one for an
ew_covmean, variance or standard deviation, for a feature-health field, and forbocpd’s predictive mean of a column (pred_<column>);the pair for a correlation or a covariance, ordered for
lag_corr;every feature for
mahal, the principal components and the other fields ofkmeans,micro,ew_class,hmm,bocpdandcorrchange;a block or a pair of blocks for
deco.
Null where no column set describes the field, as for a prediction.
dtypeThe type the bank declares to Polars before the first row is read:
f64,bool,list[f64],enum(anEnumof its values in their order:withheld_reason’s, anew_classspec’sclassesforclass, a grid’s slots forselected_<t>),i64(every integer: a count, a state, a row index, an id or a cluster label), orclock(scored_clockandlearned_clock, in the clock column’s own type).
Raises
ValueErrorspecis not a valid spec, as foroutput_fields().
Examples
This code reads
dffrom Example data:grid = rp.spec.ewridge( "m", targets=["y"], features=["x0", "x1"], half_life=[100.0, 500.0], ridge=[1e-6, 0.5] ) out = rp.ModelBank([grid]).fit_predict(df) # a half-life grid by a ridge grid idx = rp.spec.output_index(grid) name = idx.filter( (pl.col("kind") == "pred") & (pl.col("target") == "y") & (pl.col("ridge") == 0.5) & (pl.col("half_life") == 500.0) )["field"].item() print(name, out["m"].struct.field(name).count())
pred_y__r0.5@h500 396
See also
output_fields(), the names alone.coef_fields(), each coefficient’s place incoef.OUTPUTS.md, every model’s fields.
Notes
Every name follows one grammar, which is stable. Read left to right, a name is the kind (
pred,abs_resid,lag_corr), then its qualifier, then the target or the columns it is about, then the grid point after__and the instance after@. A qualifier is a number glued to the letter that says what it is:qa quantile level,la lag (abs_resid_q0.05_y,mahal_q0.99,lag_corr_l1_x0_x1). The grid point uses letters too,ra ridge andpa lasso penalty, and the instanceh, a half-life. A thing the spec has several of is numbered where it is named, glued to its word:pc0_var,filtered_state0,pc0_loading_x1.The table is made by the Rust code that writes the names, so it cannot drift from them.