Spaces:
Running
Running
Commit
·
10ff16a
1
Parent(s):
1969cde
Use old default kwargs for test
Browse files- test/test.py +12 -7
test/test.py
CHANGED
|
@@ -3,11 +3,17 @@ from pysr import pysr
|
|
| 3 |
import sympy
|
| 4 |
X = np.random.randn(100, 5)
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
print("Test 1 - defaults; simple linear relation")
|
| 7 |
y = X[:, 0]
|
| 8 |
-
equations = pysr(X, y,
|
| 9 |
-
niterations=10,
|
| 10 |
-
user_input=False)
|
| 11 |
print(equations)
|
| 12 |
assert equations.iloc[-1]['MSE'] < 1e-4
|
| 13 |
|
|
@@ -16,8 +22,7 @@ y = X[:, 0]**2
|
|
| 16 |
equations = pysr(X, y,
|
| 17 |
unary_operators=["sq(x) = x^2"], binary_operators=["plus"],
|
| 18 |
extra_sympy_mappings={'square': lambda x: x**2},
|
| 19 |
-
|
| 20 |
-
user_input=False)
|
| 21 |
print(equations)
|
| 22 |
assert equations.iloc[-1]['MSE'] < 1e-4
|
| 23 |
|
|
@@ -26,7 +31,7 @@ y = X[:, 0] + 3.0
|
|
| 26 |
print("Test 3 - empty operator list, and single dimension input")
|
| 27 |
equations = pysr(X, y,
|
| 28 |
unary_operators=[], binary_operators=["plus"],
|
| 29 |
-
|
| 30 |
-
|
| 31 |
print(equations)
|
| 32 |
assert equations.iloc[-1]['MSE'] < 1e-4
|
|
|
|
| 3 |
import sympy
|
| 4 |
X = np.random.randn(100, 5)
|
| 5 |
|
| 6 |
+
default_test_kwargs = dict(
|
| 7 |
+
niterations=10,
|
| 8 |
+
populations=4,
|
| 9 |
+
user_input=False,
|
| 10 |
+
annealing=True,
|
| 11 |
+
useFrequency=False,
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
print("Test 1 - defaults; simple linear relation")
|
| 15 |
y = X[:, 0]
|
| 16 |
+
equations = pysr(X, y, **default_test_kwargs)
|
|
|
|
|
|
|
| 17 |
print(equations)
|
| 18 |
assert equations.iloc[-1]['MSE'] < 1e-4
|
| 19 |
|
|
|
|
| 22 |
equations = pysr(X, y,
|
| 23 |
unary_operators=["sq(x) = x^2"], binary_operators=["plus"],
|
| 24 |
extra_sympy_mappings={'square': lambda x: x**2},
|
| 25 |
+
**default_test_kwargs)
|
|
|
|
| 26 |
print(equations)
|
| 27 |
assert equations.iloc[-1]['MSE'] < 1e-4
|
| 28 |
|
|
|
|
| 31 |
print("Test 3 - empty operator list, and single dimension input")
|
| 32 |
equations = pysr(X, y,
|
| 33 |
unary_operators=[], binary_operators=["plus"],
|
| 34 |
+
**default_test_kwargs)
|
| 35 |
+
|
| 36 |
print(equations)
|
| 37 |
assert equations.iloc[-1]['MSE'] < 1e-4
|