rheon.polars.predict¶
- rheon.polars.predict(frame: pl.LazyFrame, bank: ModelBank | State, *, chunk_size: int | None = None, threads: int | None = None) pl.LazyFrame[source]¶
- rheon.polars.predict(frame: pl.DataFrame, bank: ModelBank | State, *, chunk_size: int | None = None, threads: int | None = None) pl.DataFrame
Predict a query’s or a frame’s rows from a bank as it stands, learning nothing.
It is
frame.rheon.predict(bank)as a plain function, so that a type checker can see it: therheonnamespaces are attached when the package is imported, which a type checker does not follow.Parameters
frameA query, which gives a query (
predict()), or a frame, which gives a frame (predict()).bankA
ModelBank, or the path of a saved state.chunk_sizeHow many rows are predicted at a time, from a query or a frame alike.
threadsHow many threads to predict on, as the namespace method takes 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
dfandtodayfrom Example data:spec = rp.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = rp.ModelBank([spec]) bank.fit(df) scored = rp.predict(today, bank) # a DataFrame to a type checker too print(scored["ridge"].struct.field("pred_y").count())
400
See also