PySR 发布 Python/Julia 符号回归库

原标题:Symbolic Learning in Python and Julia
45AI 研判分

开源项目 PySR 提供基于 Python 和 Julia 的符号回归功能,支持通过 pip 快速安装。该工具旨在从数据中发现可解释的数学公式,适用于科学计算与模型可解释性场景。

关联知识实体

报道正文

本文目录6 个章节
<h1><img align="left" height="171" src="/api/v1/file/hot_img_8d60f938d681e1460f3a754c1ffcba9e.webp" alt="">PySR<br><sub><sub>Symbolic Regression in Python and Julia</sub></sub><br><sub><sub>[Docs](https://pysr.ai/) &nbsp;×&nbsp; [Examples](https://pysr.ai/examples) &nbsp;×&nbsp; [API](https://pysr.ai/api) &nbsp;×&nbsp; [Forum](https://github.com/astroautomata/PySR/discussions) &nbsp;×&nbsp; [Agents](#ai-agent-skill)</sub></sub><br><sub>[<img src="https://img.shields.io/pypi/v/pysr" alt="PyPI">](https://pypi.org/project/pysr/) [<img src="https://img.shields.io/conda/vn/conda-forge/pysr" alt="conda-forge">](https://anaconda.org/conda-forge/pysr) [<img src="https://img.shields.io/badge/arXiv-2305.01582-b31b1b" alt="arXiv">](https://arxiv.org/abs/2305.01582)</sub><br clear="all"></h1>
BASH
pip install pysr

If you find PySR useful, please cite the paper arXiv:2305.01582. If you've finished a project with PySR, please submit a PR to showcase your work on the research showcase page!

Contents:

Why PySR?

PySR is an open-source tool for Symbolic Regression: a machine learning task where the goal is to find an interpretable symbolic expression that optimizes some objective.

Over a period of several years, PySR has been engineered from the ground up to be (1) as high-performance as possible, (2) as configurable as possible, and (3) easy to use. PySR is developed alongside the Julia library SymbolicRegression.jl, which forms the powerful search engine of PySR. The details of these algorithms are described in the PySR paper.

Symbolic regression works best on low-dimensional datasets, but one can also extend these approaches to higher-dimensional spaces by using "Symbolic Distillation" of Neural Networks, as explained in 2006.11287, where we apply it to N-body problems. Here, one essentially uses symbolic regression to convert a neural net to an analytic equation. Thus, these tools simultaneously present an explicit and powerful way to interpret deep neural networks.

Installation

You can install PySR with pip or conda:

BASH
pip install pysr
BASH
conda install -c conda-forge pysr

Julia dependencies will be installed at first import.

AI Agent Skill

Install the PySR skill to provide your coding agents guidance using PySR as part of a larger agentic loop:

BASH
npx skills add astroautomata/PySR

Add --global to install the skill globally.

<details> <summary>

Docker

</summary>

You can also use the Dockerfile to install PySR in a docker container

  1. Clone this repo.
  2. Within the repo's directory, build the docker container:
BASH
docker build -t pysr .
  1. You can then start the container with an IPython execution with:
BASH
docker run -it --rm pysr ipython

For more details, see the docker section.

</details> <details> <summary>

Apptainer

</summary>

If you are using PySR on a cluster where you do not have root access, you can use Apptainer to build a container instead of Docker. The Apptainer.def file is analogous to the Dockerfile, and can be built with:

BASH
apptainer build --notest pysr.sif Apptainer.def

and launched with

BASH
apptainer run pysr.sif
</details> <details> <summary>

Troubleshooting

</summary>

One issue you might run into can result in a hard crash at import with a message like "GLIBCXX_... not found". This is due to another one of the Python dependencies loading an incorrect libstdc++ library. To fix this, you should modify your LD_LIBRARY_PATH variable to reference the Julia libraries. For example, if the Julia version of libstdc++.so is located in $HOME/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/lib/julia/ (which likely differs on your system!), you could add:

BASH
export LD_LIBRARY_PATH=$HOME/.julia/juliaup/julia-1.10.0+0.x64.linux.gnu/lib/julia/:$LD_LIBRARY_PATH

to your .bashrc or .zshrc file.

</details>

(注:更多技术实现细节与完整 API 文档请查阅原项目 README)