Spaces:
Running
Running
Commit
·
cdf9a75
1
Parent(s):
3307575
Make tests always choose most accurate equation
Browse files- This is because choosing "best" equation is sometimes problematic in
cases where there is a large score at an innaccurate equation. This
can happen randomly.
- test/test.py +2 -5
test/test.py
CHANGED
|
@@ -20,6 +20,7 @@ class TestPipeline(unittest.TestCase):
|
|
| 20 |
inspect.signature(PySRRegressor.__init__).parameters["populations"].default
|
| 21 |
)
|
| 22 |
self.default_test_kwargs = dict(
|
|
|
|
| 23 |
niterations=default_niterations * 2,
|
| 24 |
populations=default_populations * 2,
|
| 25 |
)
|
|
@@ -30,7 +31,6 @@ class TestPipeline(unittest.TestCase):
|
|
| 30 |
y = self.X[:, 0]
|
| 31 |
model = PySRRegressor(**self.default_test_kwargs)
|
| 32 |
model.fit(self.X, y)
|
| 33 |
-
model.set_params(model_selection="accuracy")
|
| 34 |
print(model.equations)
|
| 35 |
self.assertLessEqual(model.get_best()["loss"], 1e-4)
|
| 36 |
|
|
@@ -103,7 +103,6 @@ class TestPipeline(unittest.TestCase):
|
|
| 103 |
X = np.random.randn(100, 1)
|
| 104 |
y = X[:, 0] + 3.0
|
| 105 |
regressor = PySRRegressor(
|
| 106 |
-
model_selection="accuracy",
|
| 107 |
unary_operators=[],
|
| 108 |
binary_operators=["plus"],
|
| 109 |
**self.default_test_kwargs,
|
|
@@ -129,9 +128,6 @@ class TestPipeline(unittest.TestCase):
|
|
| 129 |
self.assertTrue("None" not in regressor.__repr__())
|
| 130 |
self.assertTrue(">>>>" in regressor.__repr__())
|
| 131 |
|
| 132 |
-
# "best" model_selection should also give a decent loss:
|
| 133 |
-
np.testing.assert_almost_equal(regressor.predict(X), y, decimal=1)
|
| 134 |
-
|
| 135 |
def test_noisy(self):
|
| 136 |
|
| 137 |
np.random.seed(1)
|
|
@@ -217,6 +213,7 @@ class TestBest(unittest.TestCase):
|
|
| 217 |
variable_names="x0 x1".split(" "),
|
| 218 |
extra_sympy_mappings={},
|
| 219 |
output_jax_format=False,
|
|
|
|
| 220 |
)
|
| 221 |
self.model.n_features = 2
|
| 222 |
self.model.refresh()
|
|
|
|
| 20 |
inspect.signature(PySRRegressor.__init__).parameters["populations"].default
|
| 21 |
)
|
| 22 |
self.default_test_kwargs = dict(
|
| 23 |
+
model_selection="accuracy",
|
| 24 |
niterations=default_niterations * 2,
|
| 25 |
populations=default_populations * 2,
|
| 26 |
)
|
|
|
|
| 31 |
y = self.X[:, 0]
|
| 32 |
model = PySRRegressor(**self.default_test_kwargs)
|
| 33 |
model.fit(self.X, y)
|
|
|
|
| 34 |
print(model.equations)
|
| 35 |
self.assertLessEqual(model.get_best()["loss"], 1e-4)
|
| 36 |
|
|
|
|
| 103 |
X = np.random.randn(100, 1)
|
| 104 |
y = X[:, 0] + 3.0
|
| 105 |
regressor = PySRRegressor(
|
|
|
|
| 106 |
unary_operators=[],
|
| 107 |
binary_operators=["plus"],
|
| 108 |
**self.default_test_kwargs,
|
|
|
|
| 128 |
self.assertTrue("None" not in regressor.__repr__())
|
| 129 |
self.assertTrue(">>>>" in regressor.__repr__())
|
| 130 |
|
|
|
|
|
|
|
|
|
|
| 131 |
def test_noisy(self):
|
| 132 |
|
| 133 |
np.random.seed(1)
|
|
|
|
| 213 |
variable_names="x0 x1".split(" "),
|
| 214 |
extra_sympy_mappings={},
|
| 215 |
output_jax_format=False,
|
| 216 |
+
model_selection="accuracy",
|
| 217 |
)
|
| 218 |
self.model.n_features = 2
|
| 219 |
self.model.refresh()
|