Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
################################################################################
Expand All @@ -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 }}
Expand Down Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions algorithms/lagh/install.sh
Original file line number Diff line number Diff line change
@@ -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"
15 changes: 15 additions & 0 deletions algorithms/lagh/metadata.yml
Original file line number Diff line number Diff line change
@@ -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
39 changes: 39 additions & 0 deletions algorithms/lagh/regressor.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions algorithms/lagh/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy
sympy
Loading