Spaces:
Running
Running
MilesCranmer
commited on
Merge pull request #214 from MilesCranmer/organize-params-list
Browse files- docs/_api.md +64 -0
- docs/api.md +0 -16
- docs/gen_docs.sh +9 -3
- docs/gen_param_docs.py +67 -0
- docs/param_groupings.yml +89 -0
docs/_api.md
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# PySRRegressor Reference
|
2 |
+
|
3 |
+
`PySRRegressor` has many options for controlling a symbolic regression search.
|
4 |
+
Let's look at them below.
|
5 |
+
|
6 |
+
PARAMSKEY
|
7 |
+
|
8 |
+
## PySRRegressor Functions
|
9 |
+
|
10 |
+
::: pysr.PySRRegressor.fit
|
11 |
+
options:
|
12 |
+
show_root_heading: true
|
13 |
+
heading_level: 3
|
14 |
+
show_root_full_path: false
|
15 |
+
|
16 |
+
::: pysr.PySRRegressor.predict
|
17 |
+
options:
|
18 |
+
show_root_heading: true
|
19 |
+
heading_level: 3
|
20 |
+
show_root_full_path: false
|
21 |
+
|
22 |
+
::: pysr.PySRRegressor.from_file
|
23 |
+
options:
|
24 |
+
show_root_heading: true
|
25 |
+
heading_level: 3
|
26 |
+
show_root_full_path: false
|
27 |
+
|
28 |
+
::: pysr.PySRRegressor.sympy
|
29 |
+
options:
|
30 |
+
show_root_heading: true
|
31 |
+
heading_level: 3
|
32 |
+
show_root_full_path: false
|
33 |
+
|
34 |
+
::: pysr.PySRRegressor.latex
|
35 |
+
options:
|
36 |
+
show_root_heading: true
|
37 |
+
heading_level: 3
|
38 |
+
show_root_full_path: false
|
39 |
+
|
40 |
+
::: pysr.PySRRegressor.pytorch
|
41 |
+
options:
|
42 |
+
show_root_heading: true
|
43 |
+
heading_level: 3
|
44 |
+
show_root_full_path: false
|
45 |
+
|
46 |
+
::: pysr.PySRRegressor.jax
|
47 |
+
options:
|
48 |
+
show_root_heading: true
|
49 |
+
heading_level: 3
|
50 |
+
show_root_full_path: false
|
51 |
+
|
52 |
+
::: pysr.PySRRegressor.latex_table
|
53 |
+
options:
|
54 |
+
show_root_heading: true
|
55 |
+
heading_level: 3
|
56 |
+
show_root_full_path: false
|
57 |
+
|
58 |
+
::: pysr.PySRRegressor.refresh
|
59 |
+
options:
|
60 |
+
show_root_heading: true
|
61 |
+
heading_level: 3
|
62 |
+
show_root_full_path: false
|
63 |
+
|
64 |
+
|
docs/api.md
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
# PySRRegressor Reference
|
2 |
-
|
3 |
-
::: pysr.PySRRegressor
|
4 |
-
options:
|
5 |
-
members:
|
6 |
-
- fit
|
7 |
-
- predict
|
8 |
-
- from_file
|
9 |
-
- sympy
|
10 |
-
- latex
|
11 |
-
- pytorch
|
12 |
-
- jax
|
13 |
-
- latex_table
|
14 |
-
- refresh
|
15 |
-
show_root_members_full_path: true
|
16 |
-
heading_level: 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docs/gen_docs.sh
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
#!/bin/bash -e
|
2 |
|
3 |
# Generate home page using README.md:
|
4 |
-
echo '<div style="width:100%;height:0px;position:relative;padding-bottom:56.250%;"><iframe src="https://streamable.com/e/ncvqhy" frameborder="0" width="100%" height="100%" allowfullscreen style="width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden;"></iframe></div>' >
|
5 |
-
cat ../README.md | grep -v 'user-images' | grep -E -v '\<.*div.*\>' >>
|
6 |
|
7 |
# Transform "### Test status" to "**Test status**":
|
8 |
sed -i.bak 's/\#\#\# Test status/**Test status**/g' index.md
|
@@ -10,4 +10,10 @@ sed -i.bak 's/\#\#\# Test status/**Test status**/g' index.md
|
|
10 |
sed -i.bak '10,$s/^\# /## /g' index.md
|
11 |
|
12 |
# Create papers.md
|
13 |
-
python generate_papers.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
#!/bin/bash -e
|
2 |
|
3 |
# Generate home page using README.md:
|
4 |
+
echo '<div style="width:100%;height:0px;position:relative;padding-bottom:56.250%;"><iframe src="https://streamable.com/e/ncvqhy" frameborder="0" width="100%" height="100%" allowfullscreen style="width:100%;height:100%;position:absolute;left:0px;top:0px;overflow:hidden;"></iframe></div>' >index.md
|
5 |
+
cat ../README.md | grep -v 'user-images' | grep -E -v '\<.*div.*\>' >>index.md
|
6 |
|
7 |
# Transform "### Test status" to "**Test status**":
|
8 |
sed -i.bak 's/\#\#\# Test status/**Test status**/g' index.md
|
|
|
10 |
sed -i.bak '10,$s/^\# /## /g' index.md
|
11 |
|
12 |
# Create papers.md
|
13 |
+
python generate_papers.py
|
14 |
+
|
15 |
+
# Copy _api.md up to but not including PARAMSKEY and all tex after:
|
16 |
+
cat _api.md | sed -n '1,/PARAMSKEY/p' | sed '$d' >api.md
|
17 |
+
python gen_param_docs.py >> api.md
|
18 |
+
# Copy _api.md after PARAMSKEY:
|
19 |
+
cat _api.md | sed -n '/PARAMSKEY/,$p' | sed '1d' >>api.md
|
docs/gen_param_docs.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Load YAML file param_groupings.yml:
|
2 |
+
from pathlib import Path
|
3 |
+
from yaml import safe_load
|
4 |
+
import sys
|
5 |
+
|
6 |
+
sys.path.append("..")
|
7 |
+
from pysr import PySRRegressor
|
8 |
+
import pysr
|
9 |
+
import re
|
10 |
+
from docstring_parser import parse
|
11 |
+
|
12 |
+
found_params = []
|
13 |
+
|
14 |
+
|
15 |
+
def str_param_groups(param_groupings, params, cur_heading=2):
|
16 |
+
global found_params
|
17 |
+
# Recursively print the parameter descriptions, defaults,
|
18 |
+
# with headings from the param groupings dict.
|
19 |
+
if isinstance(param_groupings, list):
|
20 |
+
return "\n\n".join(
|
21 |
+
str_param_groups(param, params, cur_heading) for param in param_groupings
|
22 |
+
)
|
23 |
+
elif isinstance(param_groupings, dict):
|
24 |
+
for heading, param_grouping in param_groupings.items():
|
25 |
+
return (
|
26 |
+
f"{'#' * cur_heading} {heading}"
|
27 |
+
+ "\n\n"
|
28 |
+
+ str_param_groups(param_grouping, params, cur_heading + 1)
|
29 |
+
)
|
30 |
+
elif isinstance(param_groupings, str):
|
31 |
+
found_params.append(param_groupings)
|
32 |
+
|
33 |
+
clean_desc = re.sub(r"Default is .*", "", params[param_groupings].description)
|
34 |
+
default_value = re.search(
|
35 |
+
r"Default is `(.*)`", params[param_groupings].description
|
36 |
+
)
|
37 |
+
return (
|
38 |
+
f"**`{param_groupings}`**"
|
39 |
+
+ "\n\n"
|
40 |
+
+ clean_desc
|
41 |
+
+ ("\n" + f"*Default:* `{default_value.group(1)}`" if default_value else "")
|
42 |
+
)
|
43 |
+
else:
|
44 |
+
raise TypeError(f"Unexpected type {type(param_groupings)}")
|
45 |
+
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
+
# This is the path to the param_groupings.yml file
|
49 |
+
# relative to the current file.
|
50 |
+
path = "param_groupings.yml"
|
51 |
+
with open(path, "r") as f:
|
52 |
+
param_groupings = safe_load(f)
|
53 |
+
|
54 |
+
# This is basically a dict of lists and dicts.
|
55 |
+
|
56 |
+
# Let's load in the parameter descriptions from the docstring of PySRRegressor:
|
57 |
+
raw_params = parse(PySRRegressor.__doc__).params
|
58 |
+
params = {
|
59 |
+
param.arg_name: param
|
60 |
+
for param in raw_params
|
61 |
+
if param.arg_name[-1] != "_" and param.arg_name != "**kwargs"
|
62 |
+
}
|
63 |
+
|
64 |
+
output = str_param_groups(param_groupings, params, cur_heading=3)
|
65 |
+
assert len(set(found_params) ^ set(params.keys())) == 0
|
66 |
+
print("## PySRRegressor Parameters")
|
67 |
+
print(output)
|
docs/param_groupings.yml
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
- The Algorithm:
|
2 |
+
- Creating the Search Space:
|
3 |
+
- binary_operators
|
4 |
+
- unary_operators
|
5 |
+
- maxsize
|
6 |
+
- maxdepth
|
7 |
+
- Setting the Search Size:
|
8 |
+
- niterations
|
9 |
+
- populations
|
10 |
+
- population_size
|
11 |
+
- ncyclesperiteration
|
12 |
+
- The Objective:
|
13 |
+
- loss
|
14 |
+
- model_selection
|
15 |
+
- Working with Complexities:
|
16 |
+
- parsimony
|
17 |
+
- constraints
|
18 |
+
- nested_constraints
|
19 |
+
- complexity_of_operators
|
20 |
+
- complexity_of_constants
|
21 |
+
- complexity_of_variables
|
22 |
+
- warmup_maxsize_by
|
23 |
+
- use_frequency
|
24 |
+
- use_frequency_in_tournament
|
25 |
+
- Mutations:
|
26 |
+
- weight_add_node
|
27 |
+
- weight_insert_node
|
28 |
+
- weight_delete_node
|
29 |
+
- weight_do_nothing
|
30 |
+
- weight_mutate_constant
|
31 |
+
- weight_mutate_operator
|
32 |
+
- weight_randomize
|
33 |
+
- weight_simplify
|
34 |
+
- crossover_probability
|
35 |
+
- annealing
|
36 |
+
- alpha
|
37 |
+
- perturbation_factor
|
38 |
+
- skip_mutation_failures
|
39 |
+
- Tournament Selection:
|
40 |
+
- tournament_selection_n
|
41 |
+
- tournament_selection_p
|
42 |
+
- Constant Optimization:
|
43 |
+
- optimizer_algorithm
|
44 |
+
- optimizer_nrestarts
|
45 |
+
- optimize_probability
|
46 |
+
- optimizer_iterations
|
47 |
+
- should_optimize_constants
|
48 |
+
- Migration between Populations:
|
49 |
+
- fraction_replaced
|
50 |
+
- fraction_replaced_hof
|
51 |
+
- migration
|
52 |
+
- hof_migration
|
53 |
+
- topn
|
54 |
+
- Data Preprocessing:
|
55 |
+
- denoise
|
56 |
+
- select_k_features
|
57 |
+
- Stopping Criteria:
|
58 |
+
- max_evals
|
59 |
+
- timeout_in_seconds
|
60 |
+
- early_stop_condition
|
61 |
+
- Performance and Parallelization:
|
62 |
+
- procs
|
63 |
+
- multithreading
|
64 |
+
- cluster_manager
|
65 |
+
- batching
|
66 |
+
- batch_size
|
67 |
+
- precision
|
68 |
+
- fast_cycle
|
69 |
+
- turbo
|
70 |
+
- random_state
|
71 |
+
- deterministic
|
72 |
+
- warm_start
|
73 |
+
- Monitoring:
|
74 |
+
- verbosity
|
75 |
+
- update_verbosity
|
76 |
+
- progress
|
77 |
+
- Environment:
|
78 |
+
- temp_equation_file
|
79 |
+
- tempdir
|
80 |
+
- delete_tempfiles
|
81 |
+
- julia_project
|
82 |
+
- update
|
83 |
+
- Exporting the Results:
|
84 |
+
- equation_file
|
85 |
+
- output_jax_format
|
86 |
+
- output_torch_format
|
87 |
+
- extra_sympy_mappings
|
88 |
+
- extra_torch_mappings
|
89 |
+
- extra_jax_mappings
|