-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add __repr__ method that lists selected equation
- Loading branch information
1 parent
faa83d3
commit d26d668
Showing
3 changed files
with
38 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
import numpy as np | ||
from pysr import pysr, best | ||
from pysr import PySRRegressor | ||
|
||
# Dataset | ||
X = 2 * np.random.randn(100, 5) | ||
y = 2 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2 | ||
X = 3 * np.random.randn(100, 5) | ||
y = 3 * np.cos(X[:, 3]) + X[:, 0] ** 2 - 2 | ||
|
||
# Learn equations | ||
equations = pysr( | ||
X, | ||
y, | ||
niterations=5, | ||
model = PySRRegressor( | ||
niterations=6, | ||
binary_operators=["plus", "mult"], | ||
unary_operators=[ | ||
"cos", | ||
"exp", | ||
"sin", # Pre-defined library of operators (see https://pysr.readthedocs.io/en/latest/docs/operators/) | ||
"inv(x) = 1/x", | ||
"inv(x) = 2/x", | ||
], | ||
loss="loss(x, y) = abs(x - y)", # Custom loss function | ||
) # Define your own operator! (Julia syntax) | ||
|
||
... # (you can use ctl-c to exit early) | ||
model.fit(X, y) | ||
|
||
print(best(equations)) | ||
print(model) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters