rheon.polars.ModelBank.describe¶
- ModelBank.describe(spec: str | int | None = None, group: str | Iterable[str | None] | None = None) DataFrame[source]¶
Return statistics of each input column each model was fed, one row per column.
Use it to see the counts and moments of the features, targets and weight each model was fed, from the bank or from one loaded from a state file. For each model’s row counts use
summary(), 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, input column), in spec order, then ingroups()’ order, and within each group the features, then the targets, then the weight column. The columns:spec,groupAs
groups()reports them.column,roleThe column’s name, and
"feature","target"or"weight".count,unusable_countThe rows fed, split in two. A value counts when it is finite and within the input bound, as the models take it, and is unusable otherwise: a Polars null, NaN, an infinity and a magnitude beyond the bound alike. So
unusable_countis not Polars’null_count, which counts the nulls alone.mean,std,min,maxOver the counted values of every row fed, skipped rows included, undecayed and in row order, so chunking cannot move them.
stdis the sample standard deviation (ddof=1), null below two values.
A model with no targets lists none. An
ew_classlabel column has its counts only. Aseqtestthat compares two specs (a=andb=) lists as its target the value it tests on each row,|resid_b| - |resid_a|, named as the spec names it. A formula target counts the value each row is learned from, when the row is learned: a null until the row’s window closes and itsembargopasses, and a null for a row still held when the input ends.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.
Examples
This code reads
dffrom Example data:spec = rp.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = rp.ModelBank([spec]) bank.fit(df) stats = bank.describe().select("column", "role", "count", "mean") for column, role, count, mean in stats.iter_rows(): print(f"{column} ({role}): {count} values, mean {mean:.2f}")
x0 (feature): 400 values, mean -0.04 x1 (feature): 400 values, mean -0.02 y (target): 400 values, mean 0.94
See also