zawster / boolformer

Boolformer, best fit for noisy data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyPI Colab

Boolformer: symbolic regression of Boolean functions with transformers

This repository contains code for the paper Boolformer: symbolic regression of Boolean functions with transformers.

Installation

This package is installable via pip:

pip install boolformer

Demo

We include a small notebook that loads a pre-trained model you can play with here:

Colab

Usage

Import the model in a few lines of code:

from boolformer import load_boolformer
boolformer_noiseless = load_boolformer('noiseless')
boolformer_noisy     = load_boolformer('noisy')

Using the model:

import numpy as np
inputs = np.array([  
    [False, False],
    [False, True ],
    [True , False],
    [True , True ],
])
outputs1 = np.array([False, False, False, True])
outputs2 = np.array([True, False, False, True])
inputs = [inputs, inputs]
outputs = [outputs1, outputs2]
pred_trees, errors, complexities = boolformer_noiseless.fit(inputs, outputs, verbose=False, beam_size=10, beam_type="search")

for pred_tree in pred_trees:
    print(pred_tree)

Training and evaluation

To launch a model training with additional arguments (arg1,val1), (arg2,val2): python train.py --arg1 val1 --arg2 --val2

All hyper-parameters related to training are specified in parsers.py, and those related to the environment are in envs/environment.py.

Citation

If you want to reuse this material, please considering citing the following:

@misc{dascoli2023boolformer,
      title={Boolformer: Symbolic Regression of Logic Functions with Transformers}, 
      author={Stéphane d'Ascoli and Samy Bengio and Josh Susskind and Emmanuel Abbé},
      year={2023},
      eprint={2309.12207},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}

License

This repository is licensed under MIT licence.

About

Boolformer, best fit for noisy data.

License:MIT License


Languages

Language:Python 87.1%Language:Jupyter Notebook 12.9%