rheon.polars.ModelBank.save_bytes¶
- ModelBank.save_bytes() bytes[source]¶
The bytes
save()writes, for a store that is not a file.Use it to keep a state in a database or an object store, and read it back with
load_bytes(). Pickle andcopy.deepcopycarry a bank as these bytes.Returns
bytes: the state, assave()writes it to a file.Raises
RuntimeErrorA call that learns is in flight on another thread.
ValueErrorA refused chunk left the bank unable to go on (
fit_predict(), Notes).UnstableWarningUnder
RHEON_WARN_UNSTABLE=1, for a formula target, assave()says.
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) blob = bank.save_bytes() # to keep wherever bytes can be kept print(rp.ModelBank.load_bytes(blob).rows_fed)
400
See also
load_bytes(), which reads the bytes back.save(), which writes them to a file.