polars_online.fit_predict¶
- polars_online.fit_predict(frame: pl.LazyFrame, specs: Specs | None = None, *, load_state: State | ModelBank | None = None, save_state: State | None = None, closed_groups: State | None = None, chunk_size: int | None = None, threads: int | None = None) pl.LazyFrame[source]¶
- polars_online.fit_predict(frame: pl.DataFrame, specs: Specs | None = None, *, load_state: State | ModelBank | None = None, save_state: State | None = None, closed_groups: State | None = None, chunk_size: int | None = None, threads: int | None = None) pl.DataFrame
Add each spec’s output column to a query’s or a frame’s rows, learning them.
It is
frame.online.fit_predict(...)as a plain function, so that a type checker can see it: theonlinenamespaces are attached when the package is imported, which a type checker does not follow. The namespace methods take the same arguments.Parameters
frameA query or a frame. A query gives a query that learns the rows when it runs (
fit_predict()). A frame gives the frame with the bank’s columns (fit_predict()).specsThe specs of a bank that starts with nothing learned.
load_stateWhat to start from in place of the specs: the path of a saved state, or a
ModelBank, which is copied.save_stateThe path to write the state the bank ends in.
closed_groupsThe path of a file to write the groups that closed to.
chunk_sizeHow many rows the bank learns at a time, from a query or a frame alike.
threadsHow many threads the bank runs on, as
ModelBanktakes it.
Returns
A query for a query, and a frame for a frame, with one output column added per spec.
Raises
TypeErrorframeis neither a query nor a frame.
Otherwise, what the namespace method raises.
Examples
This code reads
lffrom Example data:spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) out = po.fit_predict(lf, [spec]) # a LazyFrame to a type checker too print(out.collect()["ridge"].struct.field("pred_y").count())
396
See also
fit_predict(), each parameter in full, for a query.fit_predict(), the same for a frame.