Skip to content

heal-research/pyoperon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

354 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyoperon

License build-linux build-macos Matrix chat

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 SymbolicRegressor

SymbolicRegressor 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.

Installation

New releases are published on github and on PyPI.

Most of the time pip install pyoperon should be enough.

Building from source

Conda/Mamba

  1. Clone the repository
git clone https://github.com/heal-research/pyoperon.git
cd pyoperon
  1. Install and activate the environment (replace micromamba with your package manager)
micromamba env create -f environment.yml
micromamba activate pyoperon
  1. Build the C++ dependencies and install pyoperon
export CC=clang
export CXX=clang++
python script/dependencies.py
pip install . --no-build-isolation

Nix

The repository includes a flake.nix with a development shell that provides all C++ and Python dependencies.

  1. Clone the repository
git clone https://github.com/heal-research/pyoperon.git
cd pyoperon
  1. Enter the dev shell and install pyoperon into 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 .
  1. Run the tests (optional)
pip install --no-build-isolation '.[test]'
pytest tests/ -v

Contributing

See the CONTRIBUTING document.

About

Python bindings and scikit-learn interface for the Operon library for symbolic regression.

Topics

Resources

License

Code of conduct

Contributing

Stars

80 stars

Watchers

6 watching

Forks

Packages

 
 
 

Contributors