Skip to content

Commit

Permalink
Merge branch 'master' into compathelper/new_version/2024-10-15-00-11-…
Browse files Browse the repository at this point in the history
…26-498-00928743823
  • Loading branch information
MilesCranmer authored Nov 20, 2024
2 parents 9d1d9a4 + de9f67b commit 265cdb4
Show file tree
Hide file tree
Showing 64 changed files with 5,343 additions and 1,040 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Documentation
# Modelled from DiffEqDocs

on:
push:
Expand Down Expand Up @@ -30,6 +29,7 @@ jobs:
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: "Build and deploy"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # For authentication with SSH deploy key
run: julia --project=docs/ docs/make.jl
DOCUMENTER_KEY_ASTROAUTOMATA: ${{ secrets.DOCUMENTER_KEY }}
DOCUMENTER_KEY_CAM: ${{ secrets.DAMTP_DEPLOY_KEY }}
run: |
julia --project=docs/ docs/make.jl
6 changes: 1 addition & 5 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ jobs:
- name: "Cache dependencies"
uses: julia-actions/cache@v2
- name: Install JuliaFormatter and format
# This will use the latest version by default but you can set the version like so:
#
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
julia -e 'using JuliaFormatter; format(".", verbose=true)'
julia --startup-file=no -e 'using Pkg; pkg"activate --temp"; pkg"add [email protected]"; using JuliaFormatter; format("."; verbose=true)'
- name: "Format check"
run: |
julia -e '
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.dataset*.jl
.hyperparams*.jl
outputs
*.csv
*.bak
*.bkup
performance*txt
*.out
trials*
**/__pycache__
build
dist
Manifest.toml
Manifest*.toml
*.cov
.coveralls.yml
**/*tmp*.jl
Expand Down
1,569 changes: 1,569 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SymbolicRegression"
uuid = "8254be44-1295-4e6a-a16d-46603ac705cb"
authors = ["MilesCranmer <[email protected]>"]
version = "1.0.0-beta1"
version = "1.0.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand All @@ -14,18 +14,20 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
DynamicQuantities = "06fc5a27-2a28-4c7c-a15d-362465fb6821"
LineSearches = "d3d80556-e9d4-5f37-9878-2ab0fcc64255"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
LossFunctions = "30fc2ffe-d236-52d8-8643-a9d8f7c094a7"
MLJModelInterface = "e80e1ace-859a-464e-9ed9-23947d8ae3ea"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
ProgressBars = "49802e3a-d2f1-5c88-81d8-b72133a6f568"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StyledStrings = "f489334b-da3d-4c2e-b8f0-e476e12c162b"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[weakdeps]
Expand All @@ -40,34 +42,32 @@ SymbolicRegressionSymbolicUtilsExt = "SymbolicUtils"

[compat]
ADTypes = "^1.4.0"
Compat = "^4.2"
ConstructionBase = "<1.5.7, 1.5.8 - 1"
Compat = "^4.16"
ConstructionBase = "1.0.0 - 1.5.6"
ConstructionBase = "1.0.0 - 1.5.7, 1.5.8 - 1"
Dates = "1"
DifferentiationInterface = "0.5, 0.6"
DispatchDoctor = "0.4"
DispatchDoctor = "^0.4.17"
Distributed = "<0.0.1, 1"
DynamicExpressions = "1"
DynamicExpressions = "1.5.0"
DynamicQuantities = "1"
Enzyme = "0.12"
Enzyme = "0.12, 0.13"
JSON3 = "1"
LineSearches = "7"
Logging = "1"
LossFunctions = "0.10, 0.11"
MLJModelInterface = "~1.5, ~1.6, ~1.7, ~1.8, ~1.9, ~1.10, ~1.11"
MacroTools = "0.4, 0.5"
Optim = "~1.8, ~1.9"
Optim = "~1.8, ~1.9, ~1.10"
Pkg = "<0.0.1, 1"
PrecompileTools = "1"
Printf = "<0.0.1, 1"
ProgressBars = "~1.4, ~1.5"
ProgressMeter = "1.10"
Random = "<0.0.1, 1"
Reexport = "1"
SpecialFunctions = "0.10.1, 1, 2"
StatsBase = "0.33, 0.34"
StyledStrings = "1"
SymbolicUtils = "0.19, ^1.0.5, 2, 3"
TOML = "<0.0.1, 1"
julia = "1.10"

[extras]
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ https://github.com/MilesCranmer/SymbolicRegression.jl/assets/7593028/f5b68f1f-98

| Latest release | Documentation | Forums | Paper |
| :---: | :---: | :---: | :---: |
| [![version](https://juliahub.com/docs/SymbolicRegression/version.svg)](https://juliahub.com/ui/Packages/SymbolicRegression/X2eIS) | [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://astroautomata.com/SymbolicRegression.jl/dev/) | [![Discussions](https://img.shields.io/badge/discussions-github-informational)](https://github.com/MilesCranmer/PySR/discussions) | [![Paper](https://img.shields.io/badge/arXiv-2305.01582-b31b1b)](https://arxiv.org/abs/2305.01582) |
| [![version](https://juliahub.com/docs/SymbolicRegression/version.svg)](https://juliahub.com/ui/Packages/SymbolicRegression/X2eIS) | [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ai.damtp.cam.ac.uk/symbolicregression/dev/) | [![Discussions](https://img.shields.io/badge/discussions-github-informational)](https://github.com/MilesCranmer/PySR/discussions) | [![Paper](https://img.shields.io/badge/arXiv-2305.01582-b31b1b)](https://arxiv.org/abs/2305.01582) |

| Build status | Coverage |
| :---: | :---: |
Expand Down Expand Up @@ -110,7 +110,7 @@ where here we choose to evaluate the second equation.

For fitting multiple outputs, one can use `MultitargetSRRegressor`
(and pass an array of indices to `idx` in `predict` for selecting specific equations).
For a full list of options available to each regressor, see the [API page](https://astroautomata.com/SymbolicRegression.jl/dev/api/).
For a full list of options available to each regressor, see the [API page](https://ai.damtp.cam.ac.uk/symbolicregression/dev/api/).

### Low-Level Interface

Expand Down Expand Up @@ -495,4 +495,4 @@ done | vims -l 'f a--> ' | sort

## Search options

See https://astroautomata.com/SymbolicRegression.jl/stable/api/#Options
See https://ai.damtp.cam.ac.uk/symbolicregression/stable/api/#Options
3 changes: 3 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DynamicExpressions = "a40a106e-89c9-4ca8-8020-a735e8728b6b"
Gumbo = "708ec375-b3d6-5a57-a7ce-8257bf98657a"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[compat]
Documenter = "0.27"
34 changes: 24 additions & 10 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ using SymbolicRegression:
@extend_operators
using DynamicExpressions

DocMeta.setdocmeta!(
SymbolicRegression, :DocTestSetup, :(using LossFunctions); recursive=true
)
DocMeta.setdocmeta!(
SymbolicRegression, :DocTestSetup, :(using DynamicExpressions); recursive=true
)
include("utils.jl")
process_literate_blocks("test")
process_literate_blocks("examples")

readme = open(dirname(@__FILE__) * "/../README.md") do io
read(io, String)
Expand Down Expand Up @@ -88,19 +85,29 @@ open(dirname(@__FILE__) * "/src/index.md", "w") do io
write(io, index_base)
end

DocMeta.setdocmeta!(
SymbolicRegression,
:DocTestSetup,
:(using LossFunctions, DynamicExpressions);
recursive=true,
)
makedocs(;
sitename="SymbolicRegression.jl",
authors="Miles Cranmer",
doctest=true,
strict=:doctest,
clean=true,
format=Documenter.HTML(;
canonical="https://astroautomata.com/SymbolicRegression.jl/stable"
canonical="https://ai.damtp.cam.ac.uk/symbolicregression/stable"
),
pages=[
"Contents" => "index_base.md",
"Home" => "index.md",
"Examples" => "examples.md",
"Examples" => [
"Short Examples" => "examples.md",
"Template Expressions" => "examples/template_expression.md",
"Parameterized Expressions" => "examples/parameterized_function.md",
],
"API" => "api.md",
"Losses" => "losses.md",
"Types" => "types.md",
Expand Down Expand Up @@ -133,9 +140,16 @@ apply_to_a_href!(html.root) do element
element.attributes["href"] = "#LossFunctions." * element.children[1].text
end

# Then, we write the new html to the file:
# Then, we write the new html to the file, only if it has changed:
open("docs/build/losses/index.html", "w") do io
write(io, string(html))
end

deploydocs(; repo="github.com/MilesCranmer/SymbolicRegression.jl.git")
if !haskey(ENV, "JL_LIVERELOAD")
ENV["DOCUMENTER_KEY"] = get(ENV, "DOCUMENTER_KEY_ASTROAUTOMATA", "")
deploydocs(; repo="github.com/MilesCranmer/SymbolicRegression.jl.git")

ENV["DOCUMENTER_KEY"] = get(ENV, "DOCUMENTER_KEY_CAM", "")
ENV["GITHUB_REPOSITORY"] = "ai-damtp-cam-ac-uk/symbolicregression.git"
deploydocs(; repo="github.com/ai-damtp-cam-ac-uk/symbolicregression.git")
end
21 changes: 21 additions & 0 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,24 @@ Note that use of this function requires `SymbolicUtils.jl` to be installed and l
```@docs
calculate_pareto_frontier
```

## Logging

```@docs
SRLogger
```

The `SRLogger` allows you to track the progress of symbolic regression searches.
It can wrap any `AbstractLogger` that implements the Julia logging interface,
such as from TensorBoardLogger.jl or Wandb.jl.

```julia
using TensorBoardLogger

logger = SRLogger(TBLogger("logs/run"), log_interval=2)

model = SRRegressor(;
logger=logger,
kws...
)
```
15 changes: 13 additions & 2 deletions docs/src/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,30 @@ You can create your own expression types by defining a new type that extends `Ab

```@docs
AbstractExpression
ExpressionInterface
```

The interface is fairly flexible, and permits you define specific functional forms,
extra parameters, etc. See the documentation of DynamicExpressions.jl for more details on what
methods you need to implement. Then, for SymbolicRegression.jl, you would
methods you need to implement. You can test the implementation of a given interface by using
`ExpressionInterface` which makes use of `Interfaces.jl`:

```@docs
ExpressionInterface
```

Then, for SymbolicRegression.jl, you would
pass `expression_type` to the `Options` constructor, as well as any
`expression_options` you need (as a `NamedTuple`).

If needed, you may need to overload `SymbolicRegression.ExpressionBuilder.extra_init_params` in
case your expression needs additional parameters. See the method for `ParametricExpression`
as an example.

You can look at the files `src/ParametricExpression.jl` and `src/TemplateExpression.jl`
for more examples of custom expression types, though note that `ParametricExpression` itself
is defined in DynamicExpressions.jl, while that file just overloads some methods for
SymbolicRegression.jl.

## Other Customizations

Other internal abstract types include the following:
Expand Down
Loading

0 comments on commit 265cdb4

Please sign in to comment.