polars_online.ModelBank.summary¶
- ModelBank.summary(spec: str | int | None = None, group: str | Iterable[str | None] | None = None) DataFrame[source]¶
Return what each model has been fed, one row per spec and group.
Use it after a run to see how many rows each model learned, skipped or reset on, and whether it is warmed up, from the bank or from one loaded from a state file. For each input column’s statistics use
describe(), and for findings about the data,check().Parameters
specThe spec to read, by name or by position. The default,
None, reads every spec.groupThe group to read: one group key, as
groups()reports it, or a list of keys, withNonein the list for the null group. The default,None, reads every group. A key the bank has never seen gives no rows.
Returns
A
DataFramewith one row per (spec, group), in spec order, then ingroups()’ order. The counts and ranges cover every row routed to the group since its state began, undecayed, so they say what the model learned from, not what it still remembers. Every count is anInt64. The columns:spec,groupAs
groups()reports them.rows_fedThe rows routed to the group, skipped or not, as
groups()counts them.rows_processedThe rows the models saw: every feature and the weight usable.
rows_skippedrows_fed - rows_processed: the rows with a null, NaN, infinite or out-of-bound feature or weight.rows_learnedThe processed rows with a positive weight and, for a model with targets, at least one usable target. A formula target’s row counts when it is released with a value, once its window has closed.
rows_zero_weightThe processed rows with weight 0: the clock moved, and nothing was learned.
weight_sumThe sum of the processed rows’ weights, 1 for a row without a weight column. It is undecayed, so it is not the output’s
weight_sumfield.clock_min,clock_max,clock_lastThe range of the clock fed, and its last value, exactly, in the clock column’s own dtype, as
groups()givesclock_last. Null for a spec without a clock.session_changesThe rows whose session differed from the row before.
clock_backwardsThe rows whose clock fell below the row before within a session, which
restart_after_step_backdecided about.resetsThe rows at which
session_gap = "reset"orrestart_after_step_backreset the model.solve_failuresThe solves that needed jitter or kept the previous fit, which
solve_failures()reports.refit_given_upThe targets whose refit of their first rows was given up, past the spec’s
refit_budgetor past the cap on how long its buffer of rows ages. Four models refit their first rows and count it:huber,quantile,sgd(loss="huber"), and amarginalwhose bins refit (bin_refit_rows). 0 on every other spec.labels_missing,labels_droppedUnder
label_clock, the rows whose targets were never learned.labels_missingcounts the rows not skipped whoselabel_clockis null.labels_droppedcounts the rows held for theirlabel_clocktime and dropped, byheld_overflow="drop_oldest"or by a clock that reset the model. 0 on every other spec.settled_fracHow far the first instance (the part of the model that fits the spec’s first half-life) has come toward its steady state under decay, after the last row: the fraction the next row’s
settled_fracfield reads. Underembargoit counts the clock the held rows have covered too. Null where the model has no such reading.weight_sum_settledThe weight the model’s
weight_sumtops out at, projected from where it stands (see Notes). It says, before the model gets there, whether amin_weightcan be met. Null after a single row, with no decay, and underwindow_size.error_inflationThe largest ratio the
max_error_inflationgate checks, over the first instance’s slots (see Notes). Null where the model has no such gate.support_coef_min,support_coef_min_feature,n_coefThe smallest coefficient’s data share, the feature it belongs to, and the number of coefficients a target, read from the model’s first instance after the last row, as
settled_fracanderror_inflationare.
An
audit(polars_online.spec.audit()) reads every row and learns from none: itsrows_processedisrows_fed, itsrows_skippedis 0, and itsrows_learnedandn_coefare null. What it counted isaudit()’s.Raises
KeyErrorspecis a name the bank does not have.IndexErrorspecis a position the bank does not have.TypeErrorgroupis not a str, a list of them withNoneallowed, orNone.ValueErrorspecisNoneand two specs read clocks of different dtypes, which one clock column cannot hold. Read them one spec at a time, as forgroups().
Examples
This code reads
dffrom Example data:spec = po.spec.ewridge( "ridge", targets=["y"], features=["x0", "x1"], half_life=100.0, clock="t", gap_cap=300.0, ) bank = po.ModelBank([spec]) holes = pl.when(pl.col("t") % 10 == 0).then(None).otherwise(pl.col("x1")) bank.fit(df.with_columns(x1=holes)) # x1 null on every tenth row row = bank.summary().row(0, named=True) # one row: the spec has no groups print(row["rows_fed"], row["rows_processed"], row["rows_skipped"], row["rows_learned"])
400 360 40 360
See also
describe(), each input column’s statistics.check(), findings about the data, read from this summary and more.solve_failures(), one of these columns alone.Is it ready?, on
settled_frac,error_inflationandweight_sum_settled.
Notes
The counts are kept in the state file, so a bank loaded from a file gives them too.
predict()moves none of them, and feeding the same rows in one chunk or a thousand gives the same numbers to the bit.settled_fracreads the model’s own decay,half_life, asmin_settled_fracand the readiness warnings do. It does not read a second memory the model keeps beside it, such asholt’s trend: the diagnostics wait for the longest of those instead (One memory per diagnostic).error_inflationisewridge’ssqrt(1 + edf / n_kish),rls’ssqrt(1 + k_total / n_kish)andlasso’ssqrt(1 + df / n_kish).kalman’s gate reads each row’s own value, so its reading here is the gate’s mean over the design,sqrt(1 + sum_i P_ii E[z_i^2] / R).weight_sum_settledis(W - w1 * (1 - s)) / s.Wis the accumulated weight a next row would report asweight_sum,w1a row’s weight (1 without a weight column, the rows’ mean with one), andshow far the learned rows have come toward their steady state.sissettled_fracexcept underembargo, where the held rows’ clock is left out:Whas neither decayed by nor accumulated them, and the projection pairs a weight with the clock it has covered. On a regular stream, rowsdapart of one weight, it is exactly the ceiling1 / (1 - 2 ** (-d / half_life))times that weight, from the second row on. It is exactly 0 whereW - w1 * (1 - s)is within its own rounding: a model whose weight is still its first row’s alone, which would otherwise read a few 1e-16 above or below 0, by the platform’s math library. The rounding allowed is8 * 2**-53times the rows read timesW + w1.