rheon.polars.ModelBank.load_bytes¶
- classmethod ModelBank.load_bytes(data: bytes, specs: Iterable[dict[str, Any]] | None = None, *, threads: int | None = None) ModelBank[source]¶
Load a bank from the bytes
save_bytes()gave.Use it for a state kept in a store that is not a file.
load()takes bytes as well, with the same checks.Parameters
dataThe bytes
save_bytes()returned, or abytearrayormemoryviewof them.specsThe specs you expect the bytes to hold, checked as
load()checks them.None, the default, takes their specs unchecked.threadsThe loaded bank’s
threads, asModelBanktakes it.
Returns
A
ModelBankholding the saved state.Raises
ValueErrorandTypeErrorAs
load()raises them, for bytes that are not a bank this build loads, and for athreadsit refuses.TypeErroralso whendatais notbytes, abytearrayor amemoryview.UnstableWarningUnder
RHEON_WARN_UNSTABLE=1, for bytes holding 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) again = rp.ModelBank.load_bytes(bank.save_bytes(), specs=[spec]) print(again.rows_fed)
400
See also
save_bytes(), which gives the bytes.load(), which reads a file too.