rheon¶
Streaming and online regression models.
The names that need no dataframe library: the model builders
(rheon.spec), the Gram tools (rheon.gram), the correlation
tools (rheon.corr), the library’s errors and warnings, and the
versions. The Polars interface (the model bank, the frame namespaces, the
window operators and the scoring functions) is rheon.polars, which
re-exports every name here.
Streaming and online regression models for Polars.
One Rust core, run three ways, with the same numbers from each:
inside a Polars query:
lf.rheon.fit_predict(specs)is a query that feeds its rows through a bank when it runs, anddf.rheon.fit_predict(specs)fits a frame already in memory;ModelBank, a model bank fed one chunk at a time, whose memory grows with the models’ state and never with the number of rows that have passed. Handed a query, it reads the query a chunk at a time (ModelBank.fit_predict_batches(),ModelBank.fit());the
rheoncommand line: Parquet, Arrow IPC, CSV or NDJSON in and out, with the state saved and resumed between runs (docs/RUNNER.md).
A spec names a model and the columns it reads (rheon.spec).
Every way in takes a list of specs and writes one output column per spec. A
target is a column, a column under a name of its own (target()), or a
formula target, an expression over the window operators that looks ahead.
To fit a target computed from its own row’s columns, such as a price
against the mid, make the column with Polars’ with_columns in the query
before the bank.
The modules around the bank:
module |
what it does |
|---|---|
scores a bank’s output |
|
solves and diagnoses the Grams a bank exports |
|
transforms a query: targets whose values arrive late, series that tick at their own times, and exponentially weighted means, sums, rates, variances and quantiles looking back or ahead |
|
the window operators that |
|
repairs and reads correlation matrices |
|
simulates streams whose truth is known |
Errors follow one contract throughout, and each docstring says which part of it applies:
what went wrong |
the exception |
|---|---|
a file that cannot be read or written |
the |
a value that is refused: a spec parameter, a config key, what a column holds |
|
a column a spec reads that the frame does not have |
|
a spec’s output column that a scoring function’s frame does not have |
|
a wrong type |
|
a value out of range, or a combination of settings refused |
|
a spec name or position a bank does not have |
|
a bank fed from two threads at once |
|
Subclasses of this library’s own. WrongTypeError is a
TypeError, RefusedValueError a ValueError and
OutputColumnNotFoundError a ColumnNotFoundError, each
with the one parent the table above gives its problem, so catch the class
the table names.
Inside a running Polars query the same exception arrives wrapped in
Polars’ ComputeError under py-polars 1.x, carrying its message, and as
itself under 2.0: how a query wraps an error is Polars’ to change. A run
the bank refuses, or one abandoned before its last row, never replaces a
state file. A refused chunk leaves a bank
as it was, apart from the two cases ModelBank.fit_predict() names.
See also
The feature index, every feature of the library with a line each.
The highlights page, four use cases run end to end.
The model bank¶
Run a model bank over a query, a frame or chunks you feed it, and turn the output column it adds into columns, or hand it over as Arrow. Give a target’s output fields a name of your own, or write a target as a formula that looks ahead. Read the compiled extension’s version, the version of the state files it writes, and the number of threads a bank runs on.
A set of models fitted together over the same rows, fed one chunk at a time. |
|
Add each spec’s output column to a query’s or a frame’s rows, learning them. |
|
Predict a query’s or a frame’s rows from a bank as it stands, learning nothing. |
|
Turn each spec’s output column in a query or a frame into one column per field. |
|
Name a target column’s output fields after a name of your own. |
|
A target column under a name of its own, written as a table. |
|
A formula target, written as a table. |
|
One spec’s output column, as an Arrow struct array a consumer reads once. |
|
The number of threads a bank given this |
|
The version of the compiled extension, which equals |
|
The version of the state file’s layout that this build writes. |
Errors¶
This library’s own errors, each also a subclass of the built-in or Polars class a handler may already catch.
The error raised when a column a call reads is not in its input. |
|
The error raised when a spec’s output column is not in the frame a scoring function reads. |
|
The error raised for a value of the wrong type. |
|
The error raised for a refused value. |
Warnings¶
RheonWarning, and the warnings the library issues, each a subclass
of it.
The base class of every warning this library issues. |
|
A warning that a model is not ready, or may never become ready. |
|
A warning that Polars may change the row order of a query a bank or a window run reads. |
|
A warning that a query whose source is written in Python may give its rows only once. |
|
A warning that a name still read is on its way out. |
|
A warning that a part of the API not yet promised to stay the same was used. |