rheon.polars.ModelBank.predict_arrow¶
- ModelBank.predict_arrow(df: DataFrame) list[ArrowStruct][source]¶
Predict a frame’s rows without learning, and return each spec’s output as an Arrow array.
Use it to serve a bank’s predictions to a library other than Polars. It is to
predict()whatfit_predict_arrow()is tofit_predict(): the same predictions, the same values, and the bank left exactly as it was.Warning
The Arrow output (
fit_predict_arrow(), this method andArrowStruct) is unstable: it may change in any release without that counting as a breaking change. UnderRHEON_WARN_UNSTABLE=1, each call issuesUnstableWarning.Parameters
dfThe rows to predict, as a Polars
DataFrame, aspredict()takes it.
Returns
A list of
ArrowStruct, one per spec, asfit_predict_arrow()returns, each readable once.Raises
What
predict()raises for the same frame.UnstableWarningA warning, not an error: issued by each call under
RHEON_WARN_UNSTABLE=1.
Examples
This code reads
dffrom Example data:spec = rp.spec.ewridge("ridge", targets=["y"], features=["x0", "x1"], half_life=100.0) bank = rp.ModelBank([spec]) bank.fit_predict(df.head(300)) structs = bank.predict_arrow(df.tail(100)) # the bank is not changed served = df.tail(100).with_columns([pl.Series(s) for s in structs]) print(served["ridge"].struct.field("pred_y").count(), bank.rows_fed)
100 300
See also
predict(), the same with the output added to the frame.fit_predict_arrow(), which learns the rows too.