PySR¶
flowcean.pysr provides symbolic regression through PySR.
Install the pysr extra as described in installation.
Configure a PySRRegressor, wrap it in PySRLearner, and call learn(inputs, outputs) with lazy Polars frames. The inputs contain the explanatory variables and the outputs contain one target column. The returned PySRModel predicts that target and exposes the learned equation through flow_summary().
from pysr import PySRRegressor
from flowcean.pysr import PySRLearner
learner = PySRLearner(PySRRegressor(niterations=10))
model = learner.learn(inputs, outputs)
predictions = model.predict(inputs).collect()
print(model.flow_summary())
For HyDRA discovery, supply a factory that creates a fresh learner and regressor for each fit:
pysr
¶
Classes¶
PySRLearner
¶
Bases: SupervisedLearner
Fit a symbolic equation for one target from a batch of observations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PySRRegressor
|
Configured PySR regressor used by |
required |
For HyDRA discovery, supply a factory that creates a fresh PySRLearner
and PySRRegressor for each fit.
Attributes¶
Methods:¶
learn
¶
learn(inputs: LazyFrame, outputs: LazyFrame) -> Model
Fit the configured regressor and return its prediction model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
LazyFrame
|
Lazy Polars frame of explanatory variables. |
required |
outputs
|
LazyFrame
|
Lazy Polars frame with one target column and rows aligned
with |
required |
Returns:
| Type | Description |
|---|---|
Model
|
A |