diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 572b55c0b..88eb4ba05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ on: env: CACHE_NUMBER: 0 + # the 2022 baseline env pulls the deprecated PyPI "sklearn" shim, which now + # hard-errors on install; this is the workaround the error message names + SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL: "True" jobs: ################################################################################ @@ -41,18 +44,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Setup Mambaforge - uses: conda-incubator/setup-miniconda@v2 + name: Setup Miniforge + uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 miniforge-version: latest activate-environment: srbench use-mamba: true - name: Cache conda - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /usr/share/miniconda3/envs/srbench key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{hashFiles('environment.yml','experiment/methods/src/*.sh')}}-${{ github.sha }} @@ -85,7 +88,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: generate alg list run: bash ci/get_algorithm_list.sh @@ -111,18 +114,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Setup Mambaforge - uses: conda-incubator/setup-miniconda@v2 + name: Setup Miniforge + uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 miniforge-version: latest activate-environment: srbench use-mamba: true - name: Cache conda - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /usr/share/miniconda3/envs/srbench key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml','experiment/methods/src/*.sh') }}-${{ github.sha }} @@ -156,18 +159,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Setup Mambaforge - uses: conda-incubator/setup-miniconda@v2 + name: Setup Miniforge + uses: conda-incubator/setup-miniconda@v3 with: - miniforge-variant: Mambaforge + miniforge-variant: Miniforge3 miniforge-version: latest activate-environment: srbench use-mamba: true - name: Cache conda - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /usr/share/miniconda3/envs/srbench key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml','experiment/methods/src/*.sh') }}-${{ github.sha }} diff --git a/algorithms/lagh/install.sh b/algorithms/lagh/install.sh new file mode 100755 index 000000000..3cf38c46b --- /dev/null +++ b/algorithms/lagh/install.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +# SRBench install hook: pull lagh from its stable source repository. +set -e +pip install "git+https://github.com/jascal/lagh@master" diff --git a/algorithms/lagh/metadata.yml b/algorithms/lagh/metadata.yml new file mode 100644 index 000000000..f3ecba134 --- /dev/null +++ b/algorithms/lagh/metadata.yml @@ -0,0 +1,15 @@ +# SRBench method metadata (contract: algorithms/feat/metadata.yml format) +name: lagh +short_name: lagh +description: > + Certified symbolic law discovery. Outputs are three-track: machine-checked + exact certificates (every point within a declared epsilon; chance-fit + significance bound alpha reported), labeled empirical conjectures, or + explicit abstentions. For this harness the conjecture track always answers; + certificate status is carried as estimator metadata (track_/tag_/ + alpha_log10_). Zero-confident-wrong invariant: the system never claims an + exact law it cannot certify. +authors: James Allan Scott (jascal) +url: https://github.com/jascal/lagh +license: Apache-2.0 +language: python diff --git a/algorithms/lagh/regressor.py b/algorithms/lagh/regressor.py new file mode 100644 index 000000000..8138c6d3c --- /dev/null +++ b/algorithms/lagh/regressor.py @@ -0,0 +1,39 @@ +"""SRBench entry for lagh (certified symbolic law discovery). + +Contract objects: `est` (sklearn-compatible regressor), `model(est, X)` +(sympy-compatible string), `eval_kwargs`. +""" +from lagh.sklearn import LaghRegressor + +est = LaghRegressor(max_time=3600) + + +def model(est, X=None): + """Sympy-compatible model string, with x_i mapped to X's column names + (SRBench requirement: variable names must match the training DataFrame).""" + m = est.model() + if X is not None and hasattr(X, "columns"): + mapping = {"x_" + str(i): k for i, k in enumerate(X.columns)} + for k, v in reversed(list(mapping.items())): + m = m.replace(k, str(v)) + return m + + +eval_kwargs = {} + + +def complexity(est): + """Parse-tree node count of the final expression (srbench_2025 fallback; + normally computed from the sympy string).""" + import sympy as sp + e = sp.sympify(est.model()) + return int(sp.count_ops(e, visual=False)) + len(e.free_symbols) + 1 + + +def get_population(est): + """lagh keeps a single certified/conjectured model, not a population.""" + return [est] + + +def get_best_solution(est): + return est diff --git a/algorithms/lagh/requirements.txt b/algorithms/lagh/requirements.txt new file mode 100644 index 000000000..05bdf190f --- /dev/null +++ b/algorithms/lagh/requirements.txt @@ -0,0 +1,2 @@ +numpy +sympy