Skip to content

Commit

Permalink
feat: add dimensionless_constants_only with new backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MilesCranmer committed Apr 28, 2024
1 parent df788e5 commit fe186d6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ a constant `"2.6353e-22[m s⁻²]"`.

Note that this expression has a large dynamic range so may be difficult to find. Consider searching with a larger `niterations` if needed.

Note that you can also search for exclusively dimensionless constants by settings
`dimensionless_constants_only` to `true`.

## 11. Additional features

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pysr"
version = "0.18.3"
version = "0.18.4"
authors = [
{name = "Miles Cranmer", email = "miles.cranmer@gmail.com"},
]
Expand Down
2 changes: 1 addition & 1 deletion pysr/juliapkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"packages": {
"SymbolicRegression": {
"uuid": "8254be44-1295-4e6a-a16d-46603ac705cb",
"version": "=0.24.3"
"version": "=0.24.4"
},
"Serialization": {
"uuid": "9e88b42a-f829-5b0c-bbe9-9e923198166b",
Expand Down
1 change: 1 addition & 0 deletions pysr/param_groupings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- loss_function
- model_selection
- dimensional_constraint_penalty
- dimensionless_constants_only
- Working with Complexities:
- parsimony
- constraints
Expand Down
6 changes: 6 additions & 0 deletions pysr/sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
dimensional_constraint_penalty : float
Additive penalty for if dimensional analysis of an expression fails.
By default, this is `1000.0`.
dimensionless_constants_only : bool
Whether to only search for dimensionless constants, if using units.
Default is `False`.
use_frequency : bool
Whether to measure the frequency of complexities, and use that
instead of parsimony to explore equation space. Will naturally
Expand Down Expand Up @@ -688,6 +691,7 @@ def __init__(
complexity_of_variables: Union[int, float] = 1,
parsimony: float = 0.0032,
dimensional_constraint_penalty: Optional[float] = None,
dimensionless_constants_only: bool = False,
use_frequency: bool = True,
use_frequency_in_tournament: bool = True,
adaptive_parsimony_scaling: float = 20.0,
Expand Down Expand Up @@ -783,6 +787,7 @@ def __init__(
self.complexity_of_variables = complexity_of_variables
self.parsimony = parsimony
self.dimensional_constraint_penalty = dimensional_constraint_penalty
self.dimensionless_constants_only = dimensionless_constants_only
self.use_frequency = use_frequency
self.use_frequency_in_tournament = use_frequency_in_tournament
self.adaptive_parsimony_scaling = adaptive_parsimony_scaling
Expand Down Expand Up @@ -1654,6 +1659,7 @@ def _run(self, X, y, mutated_params, weights, seed):
# These have the same name:
parsimony=self.parsimony,
dimensional_constraint_penalty=self.dimensional_constraint_penalty,
dimensionless_constants_only=self.dimensionless_constants_only,
alpha=self.alpha,
maxdepth=maxdepth,
fast_cycle=self.fast_cycle,
Expand Down

0 comments on commit fe186d6

Please sign in to comment.