polars_online.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

spec

The spec to read, by name or by position. The default, None, reads every spec.

group

The group to read: one group key, as groups() reports it, or a list of keys, with None in the list for the null group. The default, None, reads every group. A key the bank has never seen gives no rows.

Returns

A DataFrame with one row per (spec, group, input column), in spec order, then in groups()’ order, and within each group the features, then the targets, then the weight column. The columns:

spec, group

As groups() reports them.

column, role

The column’s name, and "feature", "target" or "weight".

count, unusable_count

The 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_count is not Polars’ null_count, which counts the nulls alone.

mean, std, min, max

Over the counted values of every row fed, skipped rows included, undecayed and in row order, so chunking cannot move them. std is the sample standard deviation (ddof=1), null below two values.

A model with no targets lists none. An ew_class label column has its counts only. A seqtest that compares two specs (a= and b=) 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 its embargo passes, and a null for a row still held when the input ends.

Raises

KeyError

spec is a name the bank does not have.

IndexError

spec is a position the bank does not have.

TypeError

group is not a str, a list of them with None allowed, or None.

Examples

This code reads df from Example data:

spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0)
bank = po.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

  • summary(), each model’s row counts.

  • check(), which reads these statistics for its findings.

  • audit(), the fuller counts an audit spec keeps.