rheon.polars.fit_predict

rheon.polars.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]
rheon.polars.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.rheon.fit_predict(...) as a plain function, so that a type checker can see it: the rheon namespaces are attached when the package is imported, which a type checker does not follow. The namespace methods take the same arguments.

Parameters

frame

A 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()).

specs

The specs of a bank that starts with nothing learned.

load_state

What to start from in place of the specs: the path of a saved state, or a ModelBank, which is copied.

save_state

The path to write the state the bank ends in.

closed_groups

The path of a file to write the groups that closed to.

chunk_size

How many rows the bank learns at a time, from a query or a frame alike.

threads

How many threads the bank runs on, as ModelBank takes it.

Returns

A query for a query, and a frame for a frame, with one output column added per spec.

Raises

TypeError

frame is neither a query nor a frame.

Otherwise, what the namespace method raises.

Examples

This code reads lf from Example data:

spec = rp.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0)
out = rp.fit_predict(lf, [spec])     # a LazyFrame to a type checker too
print(out.collect()["ridge"].struct.field("pred_y").count())
396

See also