Spaces:
Sleeping
Sleeping
tttc3
commited on
Commit
•
4b56660
1
Parent(s):
19d80b0
Supress progress output for tests
Browse files- test/test.py +2 -2
- test/test_jax.py +6 -2
- test/test_torch.py +4 -0
test/test.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import inspect
|
2 |
import unittest
|
3 |
-
from unittest.mock import patch
|
4 |
import numpy as np
|
5 |
from pysr import PySRRegressor
|
6 |
from pysr.sr import run_feature_selection, _handle_feature_selection
|
7 |
from sklearn.utils.estimator_checks import check_estimator
|
8 |
import sympy
|
9 |
-
from sympy import lambdify
|
10 |
import pandas as pd
|
11 |
import warnings
|
12 |
|
@@ -22,6 +20,7 @@ class TestPipeline(unittest.TestCase):
|
|
22 |
inspect.signature(PySRRegressor.__init__).parameters["populations"].default
|
23 |
)
|
24 |
self.default_test_kwargs = dict(
|
|
|
25 |
model_selection="accuracy",
|
26 |
niterations=default_niterations * 2,
|
27 |
populations=default_populations * 2,
|
@@ -235,6 +234,7 @@ class TestBest(unittest.TestCase):
|
|
235 |
self.X = self.rstate.randn(10, 2)
|
236 |
self.y = np.cos(self.X[:, 0]) ** 2
|
237 |
self.model = PySRRegressor(
|
|
|
238 |
niterations=1,
|
239 |
extra_sympy_mappings={},
|
240 |
output_jax_format=False,
|
|
|
1 |
import inspect
|
2 |
import unittest
|
|
|
3 |
import numpy as np
|
4 |
from pysr import PySRRegressor
|
5 |
from pysr.sr import run_feature_selection, _handle_feature_selection
|
6 |
from sklearn.utils.estimator_checks import check_estimator
|
7 |
import sympy
|
|
|
8 |
import pandas as pd
|
9 |
import warnings
|
10 |
|
|
|
20 |
inspect.signature(PySRRegressor.__init__).parameters["populations"].default
|
21 |
)
|
22 |
self.default_test_kwargs = dict(
|
23 |
+
progress=False,
|
24 |
model_selection="accuracy",
|
25 |
niterations=default_niterations * 2,
|
26 |
populations=default_populations * 2,
|
|
|
234 |
self.X = self.rstate.randn(10, 2)
|
235 |
self.y = np.cos(self.X[:, 0]) ** 2
|
236 |
self.model = PySRRegressor(
|
237 |
+
progress=False,
|
238 |
niterations=1,
|
239 |
extra_sympy_mappings={},
|
240 |
output_jax_format=False,
|
test/test_jax.py
CHANGED
@@ -25,6 +25,7 @@ class TestJAX(unittest.TestCase):
|
|
25 |
X = pd.DataFrame(np.random.randn(100, 10))
|
26 |
y = np.ones(X.shape[0])
|
27 |
model = PySRRegressor(
|
|
|
28 |
max_evals=10000,
|
29 |
output_jax_format=True,
|
30 |
)
|
@@ -54,7 +55,7 @@ class TestJAX(unittest.TestCase):
|
|
54 |
def test_pipeline(self):
|
55 |
X = np.random.randn(100, 10)
|
56 |
y = np.ones(X.shape[0])
|
57 |
-
model = PySRRegressor(max_evals=10000, output_jax_format=True)
|
58 |
model.fit(X, y)
|
59 |
|
60 |
equations = pd.DataFrame(
|
@@ -83,7 +84,10 @@ class TestJAX(unittest.TestCase):
|
|
83 |
y = X["k15"] ** 2 + np.cos(X["k20"])
|
84 |
|
85 |
model = PySRRegressor(
|
86 |
-
|
|
|
|
|
|
|
87 |
)
|
88 |
model.fit(X.values, y.values)
|
89 |
f, parameters = model.jax().values()
|
|
|
25 |
X = pd.DataFrame(np.random.randn(100, 10))
|
26 |
y = np.ones(X.shape[0])
|
27 |
model = PySRRegressor(
|
28 |
+
progress=False,
|
29 |
max_evals=10000,
|
30 |
output_jax_format=True,
|
31 |
)
|
|
|
55 |
def test_pipeline(self):
|
56 |
X = np.random.randn(100, 10)
|
57 |
y = np.ones(X.shape[0])
|
58 |
+
model = PySRRegressor(progress=False, max_evals=10000, output_jax_format=True)
|
59 |
model.fit(X, y)
|
60 |
|
61 |
equations = pd.DataFrame(
|
|
|
84 |
y = X["k15"] ** 2 + np.cos(X["k20"])
|
85 |
|
86 |
model = PySRRegressor(
|
87 |
+
progress=False,
|
88 |
+
unary_operators=["cos"],
|
89 |
+
select_k_features=3,
|
90 |
+
early_stop_condition=1e-5,
|
91 |
)
|
92 |
model.fit(X.values, y.values)
|
93 |
f, parameters = model.jax().values()
|
test/test_torch.py
CHANGED
@@ -26,6 +26,7 @@ class TestTorch(unittest.TestCase):
|
|
26 |
X = pd.DataFrame(np.random.randn(100, 10))
|
27 |
y = np.ones(X.shape[0])
|
28 |
model = PySRRegressor(
|
|
|
29 |
max_evals=10000,
|
30 |
model_selection="accuracy",
|
31 |
extra_sympy_mappings={},
|
@@ -60,6 +61,7 @@ class TestTorch(unittest.TestCase):
|
|
60 |
X = np.random.randn(100, 10)
|
61 |
y = np.ones(X.shape[0])
|
62 |
model = PySRRegressor(
|
|
|
63 |
max_evals=10000,
|
64 |
model_selection="accuracy",
|
65 |
output_torch_format=True,
|
@@ -114,6 +116,7 @@ class TestTorch(unittest.TestCase):
|
|
114 |
X = np.random.randn(100, 3)
|
115 |
y = np.ones(X.shape[0])
|
116 |
model = PySRRegressor(
|
|
|
117 |
max_evals=10000,
|
118 |
model_selection="accuracy",
|
119 |
output_torch_format=True,
|
@@ -156,6 +159,7 @@ class TestTorch(unittest.TestCase):
|
|
156 |
y = X["k15"] ** 2 + np.cos(X["k20"])
|
157 |
|
158 |
model = PySRRegressor(
|
|
|
159 |
unary_operators=["cos"],
|
160 |
select_k_features=3,
|
161 |
early_stop_condition=1e-5,
|
|
|
26 |
X = pd.DataFrame(np.random.randn(100, 10))
|
27 |
y = np.ones(X.shape[0])
|
28 |
model = PySRRegressor(
|
29 |
+
progress=False,
|
30 |
max_evals=10000,
|
31 |
model_selection="accuracy",
|
32 |
extra_sympy_mappings={},
|
|
|
61 |
X = np.random.randn(100, 10)
|
62 |
y = np.ones(X.shape[0])
|
63 |
model = PySRRegressor(
|
64 |
+
progress=False,
|
65 |
max_evals=10000,
|
66 |
model_selection="accuracy",
|
67 |
output_torch_format=True,
|
|
|
116 |
X = np.random.randn(100, 3)
|
117 |
y = np.ones(X.shape[0])
|
118 |
model = PySRRegressor(
|
119 |
+
progress=False,
|
120 |
max_evals=10000,
|
121 |
model_selection="accuracy",
|
122 |
output_torch_format=True,
|
|
|
159 |
y = X["k15"] ** 2 + np.cos(X["k20"])
|
160 |
|
161 |
model = PySRRegressor(
|
162 |
+
progress=False,
|
163 |
unary_operators=["cos"],
|
164 |
select_k_features=3,
|
165 |
early_stop_condition=1e-5,
|