pyoperon is the python bindings library of Operon, a modern C++ framework for symbolic regression developed by Heal-Research at the University of Applied Sciences Upper Austria.
A scikit-learn regressor is also available:
from pyoperon.sklearn import SymbolicRegressorSymbolicRegressor accepts a callbacks= argument for monitoring or early stopping during fit(), in the style of Keras/Lightning callbacks:
from pyoperon.sklearn import SymbolicRegressor
from pyoperon import EarlyStopping
reg = SymbolicRegressor(
population_size=1000, generations=1000,
callbacks=[EarlyStopping(patience=20)],
)
reg.fit(X, y)Subclass pyoperon.Callback (on_fit_begin/on_generation_end/on_fit_end) for custom monitoring; return True from on_generation_end to request early termination. See pyoperon/callback.py for the full API.
fit() also accepts sample_weight=, matching the scikit-learn convention, for training on non-uniformly sampled data (e.g. stratified/reweighted survey data, or down-weighting outliers) without distorting the fitted model:
reg.fit(X, y, sample_weight=sample_weight)The example folder contains sample code for using either the Python bindings directly or the pyoperon.sklearn module.
New releases are published on github and on PyPI.
Most of the time pip install pyoperon should be enough.
- Clone the repository
git clone https://github.com/heal-research/pyoperon.git
cd pyoperon- Install and activate the environment (replace
micromambawith your package manager)
micromamba env create -f environment.yml
micromamba activate pyoperon- Build the C++ dependencies and install
pyoperon
export CC=clang
export CXX=clang++
python script/dependencies.py
pip install . --no-build-isolationThe repository includes a flake.nix with a development shell that provides all C++ and Python dependencies.
- Clone the repository
git clone https://github.com/heal-research/pyoperon.git
cd pyoperon- Enter the dev shell and install
pyoperoninto a virtual environment
nix develop .#pyenv
virtualenv --system-site-packages .venv
source .venv/bin/activate
pip install scikit-build-core
pip install --no-build-isolation .- Run the tests (optional)
pip install --no-build-isolation '.[test]'
pytest tests/ -vSee the CONTRIBUTING document.