polars_online.gram.Gram¶
- class polars_online.gram.Gram[source]¶
Bases:
TypedDictThe mapping that
gram()returns and the functions here take.It holds the Gram behind one fit as numpy arrays: the weight of the rows, the columns’ means and co-moments, and each target’s moments. Use it as the type of a Gram you pass between the functions of this module.
gram()says what each key holds and its shape.Examples
This code reads
dffrom Example data:spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = po.ModelBank([spec]) bank.fit_predict(df) g = bank.gram("ridge")[0] # the spec has no groups: one Gram print(g["columns"], g["targets"], g["comoments"].shape)
['intercept', 'x0', 'x1'] ['y'] (3, 3)
See also
gram(), which returns it and describes each key.from_row(), which builds one from a closed group’s row.
Notes
merge(),subset()andfrom_row()return the same keys, so a Gram from any of them goes on to any other function here. The arrays are typedAnybecause numpy is an optional extra of this package.within_partsandtarget_within_partsare present only on a Gram pooled within parts (merge(within=True)).