DataFrame.online.predict¶
- DataFrameOnlineNamespace.predict(bank: ModelBank | str | PathLike[str], *, chunk_size: int | None = None, threads: int | None = None) DataFrame[source]¶
Predict a frame’s rows from a bank as it stands, learning nothing.
It is
predict()over the frame, from a bank or a saved state. Use it to serve rows in memory from a bank that has learned. For a query, uself.online.predict.Parameters
bankThe bank to predict from: a
ModelBank, which does not move, or the path of a saved state.chunk_sizeHow many rows are predicted at a time, as
lf.online.predictreads its input.None, the default, predicts the frame as one chunk. The numbers are the same either way.coefis written on each group’s last row in each chunk that is not skipped, whatevercoef_everyandmax_rows_between_coefssay.threadsHow many threads to predict on, as
LazyFrameOnlineNamespace.predict()takes it.
Returns
The frame with one output column added per spec, as
predict()returns it.Raises
What
load()(for a path) andpredict()raise, and:TypeErrorbankis neither a bank nor a path, orchunk_sizeis not a whole number, asWrongTypeError, which is aValueErrortoo.ValueErrorchunk_sizeis below 1.
Examples
This code reads
dfandtodayfrom Example data:spec = po.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = po.ModelBank([spec]) bank.fit(df) # learn df's 400 rows scored = today.online.predict(bank) # the next 400, unlearned print(scored["ridge"].struct.field("pred_y").count(), bank.rows_fed)
400 400
See also
LazyFrameOnlineNamespace.predict(), the same over a query.polars_online.predict(), this method as a function a type checker can see.