Spaces:
Running
Running
MilesCranmer
commited on
Commit
·
34fadcf
1
Parent(s):
78cf882
Update documentation
Browse files- README.md +9 -15
- pysr/sr.py +3 -0
README.md
CHANGED
@@ -129,22 +129,13 @@ which is `hall_of_fame.csv` by default. It also prints the
|
|
129 |
equations to stdout.
|
130 |
|
131 |
```python
|
132 |
-
pysr(X=None, y=None, threads=4, niterations=20
|
133 |
-
ncyclesperiteration=int(default_ncyclesperiteration),
|
134 |
-
binary_operators=["plus", "mult"], unary_operators=["cos", "exp", "sin"],
|
135 |
-
alpha=default_alpha, annealing=True, fractionReplaced=default_fractionReplaced,
|
136 |
-
fractionReplacedHof=default_fractionReplacedHof, npop=int(default_npop),
|
137 |
-
parsimony=default_parsimony, migration=True, hofMigration=True
|
138 |
-
shouldOptimizeConstants=True, topn=int(default_topn),
|
139 |
-
weightAddNode=default_weightAddNode, weightDeleteNode=default_weightDeleteNode,
|
140 |
-
weightDoNothing=default_weightDoNothing,
|
141 |
-
weightMutateConstant=default_weightMutateConstant,
|
142 |
-
weightMutateOperator=default_weightMutateOperator,
|
143 |
-
weightRandomize=default_weightRandomize, weightSimplify=default_weightSimplify,
|
144 |
-
timeout=None, equation_file='hall_of_fame.csv', test='simple1', maxsize=20)
|
145 |
```
|
146 |
|
147 |
Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
|
|
|
|
|
|
148 |
|
149 |
**Arguments**:
|
150 |
|
@@ -174,7 +165,12 @@ equations from hall of fame.
|
|
174 |
- `shouldOptimizeConstants`: bool, Whether to numerically optimize
|
175 |
constants (Nelder-Mead/Newton) at the end of each iteration.
|
176 |
- `topn`: int, How many top individuals migrate from each population.
|
|
|
|
|
|
|
|
|
177 |
- `weightAddNode`: float, Relative likelihood for mutation to add a node
|
|
|
178 |
- `weightDeleteNode`: float, Relative likelihood for mutation to delete a node
|
179 |
- `weightDoNothing`: float, Relative likelihood for mutation to leave the individual
|
180 |
- `weightMutateConstant`: float, Relative likelihood for mutation to change
|
@@ -196,8 +192,6 @@ pd.DataFrame, Results dataframe, giving complexity, MSE, and equations
|
|
196 |
(as strings).
|
197 |
|
198 |
|
199 |
-
|
200 |
-
|
201 |
# TODO
|
202 |
|
203 |
- [ ] Why don't the constants continually change? It should optimize them every time the equation appears.
|
|
|
129 |
equations to stdout.
|
130 |
|
131 |
```python
|
132 |
+
pysr(X=None, y=None, threads=4, niterations=100, ncyclesperiteration=300, binary_operators=["plus", "mult"], unary_operators=["cos", "exp", "sin"], alpha=0.1, annealing=True, fractionReplaced=0.10, fractionReplacedHof=0.10, npop=1000, parsimony=1e-4, migration=True, hofMigration=True, shouldOptimizeConstants=True, topn=10, weightAddNode=1, weightInsertNode=3, weightDeleteNode=3, weightDoNothing=1, weightMutateConstant=10, weightMutateOperator=1, weightRandomize=1, weightSimplify=0.01, perturbationFactor=1.0, nrestarts=3, timeout=None, equation_file='hall_of_fame.csv', test='simple1', verbosity=1e9, maxsize=20)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
```
|
134 |
|
135 |
Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
136 |
+
Note: most default parameters have been tuned over several example
|
137 |
+
equations, but you should adjust `threads`, `niterations`,
|
138 |
+
`binary_operators`, `unary_operators` to your requirements.
|
139 |
|
140 |
**Arguments**:
|
141 |
|
|
|
165 |
- `shouldOptimizeConstants`: bool, Whether to numerically optimize
|
166 |
constants (Nelder-Mead/Newton) at the end of each iteration.
|
167 |
- `topn`: int, How many top individuals migrate from each population.
|
168 |
+
- `nrestarts`: int, Number of times to restart the constant optimizer
|
169 |
+
- `perturbationFactor`: float, Constants are perturbed by a max
|
170 |
+
factor of (perturbationFactor\*T + 1). Either multiplied by this
|
171 |
+
or divided by this.
|
172 |
- `weightAddNode`: float, Relative likelihood for mutation to add a node
|
173 |
+
- `weightInsertNode`: float, Relative likelihood for mutation to insert a node
|
174 |
- `weightDeleteNode`: float, Relative likelihood for mutation to delete a node
|
175 |
- `weightDoNothing`: float, Relative likelihood for mutation to leave the individual
|
176 |
- `weightMutateConstant`: float, Relative likelihood for mutation to change
|
|
|
192 |
(as strings).
|
193 |
|
194 |
|
|
|
|
|
195 |
# TODO
|
196 |
|
197 |
- [ ] Why don't the constants continually change? It should optimize them every time the equation appears.
|
pysr/sr.py
CHANGED
@@ -68,6 +68,9 @@ def pysr(X=None, y=None, threads=4,
|
|
68 |
constants (Nelder-Mead/Newton) at the end of each iteration.
|
69 |
:param topn: int, How many top individuals migrate from each population.
|
70 |
:param nrestarts: int, Number of times to restart the constant optimizer
|
|
|
|
|
|
|
71 |
:param weightAddNode: float, Relative likelihood for mutation to add a node
|
72 |
:param weightInsertNode: float, Relative likelihood for mutation to insert a node
|
73 |
:param weightDeleteNode: float, Relative likelihood for mutation to delete a node
|
|
|
68 |
constants (Nelder-Mead/Newton) at the end of each iteration.
|
69 |
:param topn: int, How many top individuals migrate from each population.
|
70 |
:param nrestarts: int, Number of times to restart the constant optimizer
|
71 |
+
:param perturbationFactor: float, Constants are perturbed by a max
|
72 |
+
factor of (perturbationFactor*T + 1). Either multiplied by this
|
73 |
+
or divided by this.
|
74 |
:param weightAddNode: float, Relative likelihood for mutation to add a node
|
75 |
:param weightInsertNode: float, Relative likelihood for mutation to insert a node
|
76 |
:param weightDeleteNode: float, Relative likelihood for mutation to delete a node
|