Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap swap operands for binary ops #512

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions benchmarks/hyperparamopt.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def run_trial(args):
weight_mutate_constant=10.0,
# weight_mutate_operator=1,
weight_mutate_operator=1.0,
# weight_swap_operands=1,
weight_swap_operands=1.0,
# weight_randomize=1,
weight_randomize=1.0,
# weight_simplify=0.002,
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
weight_mutate_operator=hp.loguniform(
"weight_mutate_operator", np.log(0.0001), np.log(100)
),
# weight_swap_operands=1,
weight_swap_operands=hp.loguniform(
"weight_swap_operands", np.log(0.0001), np.log(100)
),
# weight_randomize=1,
weight_randomize=hp.loguniform("weight_randomize", np.log(0.0001), np.log(100)),
# weight_simplify=0.002,
Expand Down
1 change: 1 addition & 0 deletions pysr/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def make_deprecated_kwargs_for_pysr_regressor():
weightInsertNode => weight_insert_node
weightMutateConstant => weight_mutate_constant
weightMutateOperator => weight_mutate_operator
weightSwapOperands => weight_swap_operands
weightRandomize => weight_randomize
weightSimplify => weight_simplify
crossoverProbability => crossover_probability
Expand Down
1 change: 1 addition & 0 deletions pysr/param_groupings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- weight_do_nothing
- weight_mutate_constant
- weight_mutate_operator
- weight_swap_operands
- weight_randomize
- weight_simplify
- weight_optimize
Expand Down
6 changes: 6 additions & 0 deletions pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,9 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
weight_mutate_operator : float
Relative likelihood for mutation to swap an operator.
Default is `0.47`.
weight_swap_operands : float
Relative likehood for swapping operands in binary operators.
Default is `0.0`.
weight_randomize : float
Relative likelihood for mutation to completely delete and then
randomly generate the equation
Expand Down Expand Up @@ -700,6 +703,7 @@ def __init__(
weight_do_nothing: float = 0.21,
weight_mutate_constant: float = 0.048,
weight_mutate_operator: float = 0.47,
weight_swap_operands: float = 0.0,
weight_randomize: float = 0.00023,
weight_simplify: float = 0.0020,
weight_optimize: float = 0.0,
Expand Down Expand Up @@ -793,6 +797,7 @@ def __init__(
self.weight_do_nothing = weight_do_nothing
self.weight_mutate_constant = weight_mutate_constant
self.weight_mutate_operator = weight_mutate_operator
self.weight_swap_operands = weight_swap_operands
self.weight_randomize = weight_randomize
self.weight_simplify = weight_simplify
self.weight_optimize = weight_optimize
Expand Down Expand Up @@ -1609,6 +1614,7 @@ def _run(self, X, y, mutated_params, weights, seed):
mutation_weights = SymbolicRegression.MutationWeights(
mutate_constant=self.weight_mutate_constant,
mutate_operator=self.weight_mutate_operator,
swap_operands=self.weight_swap_operands,
add_node=self.weight_add_node,
insert_node=self.weight_insert_node,
delete_node=self.weight_delete_node,
Expand Down
4 changes: 2 additions & 2 deletions pysr/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.16.8"
__symbolic_regression_jl_version__ = "0.23.0"
__version__ = "0.16.9"
__symbolic_regression_jl_version__ = "0.23.1"