Skip to content

Commit

Permalink
Add early_stop_condition to stop earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed May 8, 2022
1 parent ab66141 commit 73aff8b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pysr/sr.py
Expand Up @@ -420,6 +420,7 @@ def __init__(
cluster_manager=None,
skip_mutation_failures=True,
max_evals=None,
early_stop_condition=None,
# To support deprecated kwargs:
**kwargs,
):
Expand Down Expand Up @@ -562,6 +563,8 @@ def __init__(
:type skip_mutation_failures: bool
:param max_evals: Limits the total number of evaluations of expressions to this number.
:type max_evals: int
:param early_stop_condition: Stop the search early if this loss is reached.
:type early_stop_condition: float
:param kwargs: Supports deprecated keyword arguments. Other arguments will result
in an error
:type kwargs: dict
Expand Down Expand Up @@ -749,6 +752,7 @@ def __init__(
cluster_manager=cluster_manager,
skip_mutation_failures=skip_mutation_failures,
max_evals=max_evals,
early_stop_condition=early_stop_condition,
),
}

Expand Down Expand Up @@ -1313,8 +1317,9 @@ def _run(self, X, y, weights, variable_names):
progress=self.params["progress"],
timeout_in_seconds=self.params["timeout_in_seconds"],
crossoverProbability=self.params["crossover_probability"],
max_evals=self.params["max_evals"],
skip_mutation_failures=self.params["skip_mutation_failures"],
max_evals=self.params["max_evals"],
earlyStopCondition=self.params["early_stop_condition"],
)

np_dtype = {16: np.float16, 32: np.float32, 64: np.float64}[
Expand Down

0 comments on commit 73aff8b

Please sign in to comment.