Spaces:
Running
Running
MilesCranmer
commited on
Commit
•
67558da
1
Parent(s):
0a3b812
Warm up to a fraction of total training time
Browse files- Project.toml +1 -1
- pysr/sr.py +10 -8
- setup.py +1 -1
Project.toml
CHANGED
@@ -2,5 +2,5 @@
|
|
2 |
SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
|
3 |
|
4 |
[compat]
|
5 |
-
SymbolicRegression = "0.5.
|
6 |
julia = "1.5"
|
|
|
2 |
SymbolicRegression = "8254be44-1295-4e6a-a16d-46603ac705cb"
|
3 |
|
4 |
[compat]
|
5 |
+
SymbolicRegression = "0.5.10"
|
6 |
julia = "1.5"
|
pysr/sr.py
CHANGED
@@ -97,7 +97,7 @@ def pysr(X=None, y=None, weights=None,
|
|
97 |
batching=False,
|
98 |
batchSize=50,
|
99 |
select_k_features=None,
|
100 |
-
|
101 |
constraints={},
|
102 |
useFrequency=False,
|
103 |
tempdir=None,
|
@@ -106,7 +106,8 @@ def pysr(X=None, y=None, weights=None,
|
|
106 |
julia_project=None,
|
107 |
user_input=True,
|
108 |
update=True,
|
109 |
-
temp_equation_file=False
|
|
|
110 |
):
|
111 |
"""Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
112 |
Note: most default parameters have been tuned over several example
|
@@ -191,10 +192,10 @@ def pysr(X=None, y=None, weights=None,
|
|
191 |
Python using random forests, before passing to the symbolic regression
|
192 |
code. None means no feature selection; an int means select that many
|
193 |
features.
|
194 |
-
:param
|
195 |
a small number up to the maxsize (if greater than 0).
|
196 |
-
If greater than 0, says
|
197 |
-
|
198 |
:param constraints: dict of int (unary) or 2-tuples (binary),
|
199 |
this enforces maxsize constraints on the individual
|
200 |
arguments of operators. E.g., `'pow': (-1, 1)`
|
@@ -220,6 +221,7 @@ def pysr(X=None, y=None, weights=None,
|
|
220 |
(as strings).
|
221 |
|
222 |
"""
|
|
|
223 |
if isinstance(X, pd.DataFrame):
|
224 |
variable_names = list(X.columns)
|
225 |
X = np.array(X)
|
@@ -269,7 +271,7 @@ def pysr(X=None, y=None, weights=None,
|
|
269 |
shouldOptimizeConstants=shouldOptimizeConstants,
|
270 |
unary_operators=unary_operators, useFrequency=useFrequency,
|
271 |
use_custom_variable_names=use_custom_variable_names,
|
272 |
-
variable_names=variable_names,
|
273 |
weightAddNode=weightAddNode,
|
274 |
weightDeleteNode=weightDeleteNode,
|
275 |
weightDoNothing=weightDoNothing,
|
@@ -418,7 +420,7 @@ def _make_hyperparams_julia_str(X, alpha, annealing, batchSize, batching, binary
|
|
418 |
maxdepth, maxsize, migration, nrestarts, npop,
|
419 |
parsimony, perturbationFactor, populations, procs, shouldOptimizeConstants,
|
420 |
unary_operators, useFrequency, use_custom_variable_names,
|
421 |
-
variable_names,
|
422 |
ncyclesperiteration, fractionReplaced, topn, verbosity, progress, loss,
|
423 |
weightDeleteNode, weightDoNothing, weightInsertNode, weightMutateConstant,
|
424 |
weightMutateOperator, weightRandomize, weightSimplify, weights, **kwargs):
|
@@ -483,7 +485,7 @@ mutationWeights=[
|
|
483 |
{weightRandomize:f},
|
484 |
{weightDoNothing:f}
|
485 |
],
|
486 |
-
|
487 |
useFrequency={"true" if useFrequency else "false"},
|
488 |
npop={npop:d},
|
489 |
ncyclesperiteration={ncyclesperiteration:d},
|
|
|
97 |
batching=False,
|
98 |
batchSize=50,
|
99 |
select_k_features=None,
|
100 |
+
warmupMaxsizeBy=0.0,
|
101 |
constraints={},
|
102 |
useFrequency=False,
|
103 |
tempdir=None,
|
|
|
106 |
julia_project=None,
|
107 |
user_input=True,
|
108 |
update=True,
|
109 |
+
temp_equation_file=False,
|
110 |
+
warmupMaxsize=None, #Deprecated
|
111 |
):
|
112 |
"""Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
113 |
Note: most default parameters have been tuned over several example
|
|
|
192 |
Python using random forests, before passing to the symbolic regression
|
193 |
code. None means no feature selection; an int means select that many
|
194 |
features.
|
195 |
+
:param warmupMaxsizeBy: float, whether to slowly increase max size from
|
196 |
a small number up to the maxsize (if greater than 0).
|
197 |
+
If greater than 0, says the fraction of training time at which
|
198 |
+
the current maxsize will reach the user-passed maxsize.
|
199 |
:param constraints: dict of int (unary) or 2-tuples (binary),
|
200 |
this enforces maxsize constraints on the individual
|
201 |
arguments of operators. E.g., `'pow': (-1, 1)`
|
|
|
221 |
(as strings).
|
222 |
|
223 |
"""
|
224 |
+
assert warmupMaxsize == None, "warmupMaxsize is deprecated. Use warmupMaxsizeBy and give a fraction of time."
|
225 |
if isinstance(X, pd.DataFrame):
|
226 |
variable_names = list(X.columns)
|
227 |
X = np.array(X)
|
|
|
271 |
shouldOptimizeConstants=shouldOptimizeConstants,
|
272 |
unary_operators=unary_operators, useFrequency=useFrequency,
|
273 |
use_custom_variable_names=use_custom_variable_names,
|
274 |
+
variable_names=variable_names, warmupMaxsizeBy=warmupMaxsizeBy,
|
275 |
weightAddNode=weightAddNode,
|
276 |
weightDeleteNode=weightDeleteNode,
|
277 |
weightDoNothing=weightDoNothing,
|
|
|
420 |
maxdepth, maxsize, migration, nrestarts, npop,
|
421 |
parsimony, perturbationFactor, populations, procs, shouldOptimizeConstants,
|
422 |
unary_operators, useFrequency, use_custom_variable_names,
|
423 |
+
variable_names, warmupMaxsizeBy, weightAddNode,
|
424 |
ncyclesperiteration, fractionReplaced, topn, verbosity, progress, loss,
|
425 |
weightDeleteNode, weightDoNothing, weightInsertNode, weightMutateConstant,
|
426 |
weightMutateOperator, weightRandomize, weightSimplify, weights, **kwargs):
|
|
|
485 |
{weightRandomize:f},
|
486 |
{weightDoNothing:f}
|
487 |
],
|
488 |
+
warmupMaxsizeBy={warmupMaxsizeBy:f}f0,
|
489 |
useFrequency={"true" if useFrequency else "false"},
|
490 |
npop={npop:d},
|
491 |
ncyclesperiteration={ncyclesperiteration:d},
|
setup.py
CHANGED
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5 |
|
6 |
setuptools.setup(
|
7 |
name="pysr", # Replace with your own username
|
8 |
-
version="0.5.
|
9 |
author="Miles Cranmer",
|
10 |
author_email="[email protected]",
|
11 |
description="Simple and efficient symbolic regression",
|
|
|
5 |
|
6 |
setuptools.setup(
|
7 |
name="pysr", # Replace with your own username
|
8 |
+
version="0.5.10",
|
9 |
author="Miles Cranmer",
|
10 |
author_email="[email protected]",
|
11 |
description="Simple and efficient symbolic regression",
|