Skip to content

Commit e9c2b70

Browse files
authored
Merge pull request #217 from MilesCranmer/update-backend
Add optimization-as-mutation, and adaptive parsimony
2 parents 5276a81 + f041de4 commit e9c2b70

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

docs/param_groupings.yml

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- warmup_maxsize_by
2323
- use_frequency
2424
- use_frequency_in_tournament
25+
- adaptive_parsimony_scaling
2526
- Mutations:
2627
- weight_add_node
2728
- weight_insert_node
@@ -31,6 +32,7 @@
3132
- weight_mutate_operator
3233
- weight_randomize
3334
- weight_simplify
35+
- weight_optimize
3436
- crossover_probability
3537
- annealing
3638
- alpha

pysr/sr.py

+19
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,13 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
359359
Whether to use the frequency mentioned above in the tournament,
360360
rather than just the simulated annealing.
361361
Default is `True`.
362+
adaptive_parsimony_scaling : float
363+
If the adaptive parsimony strategy (`use_frequency` and
364+
`use_frequency_in_tournament`), this is how much to (exponentially)
365+
weight the contribution. If you find that the search is only optimizing
366+
the most complex expressions while the simpler expressions remain stagnant,
367+
you should increase this value.
368+
Default is `20.0`.
362369
alpha : float
363370
Initial temperature for simulated annealing
364371
(requires `annealing` to be `True`).
@@ -408,6 +415,12 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
408415
weight_simplify : float
409416
Relative likelihood for mutation to simplify constant parts by evaluation
410417
Default is `0.0020`.
418+
weight_optimize: float
419+
Constant optimization can also be performed as a mutation, in addition to
420+
the normal strategy controlled by `optimize_probability` which happens
421+
every iteration. Using it as a mutation is useful if you want to use
422+
a large `ncyclesperiteration`, and may not optimize very often.
423+
Default is `0.0`.
411424
crossover_probability : float
412425
Absolute probability of crossover-type genetic operation, instead of a mutation.
413426
Default is `0.066`.
@@ -664,6 +677,7 @@ def __init__(
664677
parsimony=0.0032,
665678
use_frequency=True,
666679
use_frequency_in_tournament=True,
680+
adaptive_parsimony_scaling=20.0,
667681
alpha=0.1,
668682
annealing=False,
669683
early_stop_condition=None,
@@ -678,6 +692,7 @@ def __init__(
678692
weight_mutate_operator=0.47,
679693
weight_randomize=0.00023,
680694
weight_simplify=0.0020,
695+
weight_optimize=0.0,
681696
crossover_probability=0.066,
682697
skip_mutation_failures=True,
683698
migration=True,
@@ -748,6 +763,7 @@ def __init__(
748763
self.parsimony = parsimony
749764
self.use_frequency = use_frequency
750765
self.use_frequency_in_tournament = use_frequency_in_tournament
766+
self.adaptive_parsimony_scaling = adaptive_parsimony_scaling
751767
self.alpha = alpha
752768
self.annealing = annealing
753769
# - Evolutionary search parameters
@@ -760,6 +776,7 @@ def __init__(
760776
self.weight_mutate_operator = weight_mutate_operator
761777
self.weight_randomize = weight_randomize
762778
self.weight_simplify = weight_simplify
779+
self.weight_optimize = weight_optimize
763780
self.crossover_probability = crossover_probability
764781
self.skip_mutation_failures = skip_mutation_failures
765782
# -- Migration parameters
@@ -1534,6 +1551,7 @@ def _run(self, X, y, mutated_params, weights, seed):
15341551
simplify=self.weight_simplify,
15351552
randomize=self.weight_randomize,
15361553
do_nothing=self.weight_do_nothing,
1554+
optimize=self.weight_optimize,
15371555
)
15381556

15391557
# Call to Julia backend.
@@ -1569,6 +1587,7 @@ def _run(self, X, y, mutated_params, weights, seed):
15691587
warmup_maxsize_by=self.warmup_maxsize_by,
15701588
use_frequency=self.use_frequency,
15711589
use_frequency_in_tournament=self.use_frequency_in_tournament,
1590+
adaptive_parsimony_scaling=self.adaptive_parsimony_scaling,
15721591
npop=self.population_size,
15731592
ncycles_per_iteration=self.ncyclesperiteration,
15741593
fraction_replaced=self.fraction_replaced,

pysr/version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.11.6"
2-
__symbolic_regression_jl_version__ = "0.14.0"
1+
__version__ = "0.11.7"
2+
__symbolic_regression_jl_version__ = "0.14.2"

0 commit comments

Comments
 (0)