Spaces:
Sleeping
Sleeping
MilesCranmer
commited on
Commit
•
e0cdb7c
1
Parent(s):
c0da614
Remove deprecated kwargs
Browse files- pysr/sr.py +10 -15
pysr/sr.py
CHANGED
@@ -100,15 +100,13 @@ def pysr(X=None, y=None, weights=None,
|
|
100 |
useFrequency=False,
|
101 |
tempdir=None,
|
102 |
delete_tempfiles=True,
|
103 |
-
limitPowComplexity=False, #deprecated
|
104 |
-
threads=None, #deprecated
|
105 |
julia_optimization=3,
|
106 |
julia_project=None,
|
107 |
user_input=True
|
108 |
):
|
109 |
"""Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
110 |
Note: most default parameters have been tuned over several example
|
111 |
-
equations, but you should adjust `
|
112 |
`binary_operators`, `unary_operators` to your requirements.
|
113 |
|
114 |
:param X: np.ndarray or pandas.DataFrame, 2D array. Rows are examples,
|
@@ -191,13 +189,15 @@ def pysr(X=None, y=None, weights=None,
|
|
191 |
:param tempdir: str or None, directory for the temporary files
|
192 |
:param delete_tempfiles: bool, whether to delete the temporary files after finishing
|
193 |
:param julia_project: str or None, a Julia environment location containing
|
194 |
-
a Project.toml (and potentially the source code for SymbolicRegression.jl)
|
|
|
|
|
|
|
|
|
195 |
:returns: pd.DataFrame, Results dataframe, giving complexity, MSE, and equations
|
196 |
(as strings).
|
197 |
|
198 |
"""
|
199 |
-
_raise_depreciation_errors(limitPowComplexity, threads)
|
200 |
-
|
201 |
if isinstance(X, pd.DataFrame):
|
202 |
variable_names = list(X.columns)
|
203 |
X = np.array(X)
|
@@ -267,9 +267,11 @@ def pysr(X=None, y=None, weights=None,
|
|
267 |
kwargs = {**_set_paths(tempdir), **kwargs}
|
268 |
|
269 |
pkg_directory = kwargs['pkg_directory']
|
|
|
270 |
if not (pkg_directory / 'Manifest.toml').is_file():
|
271 |
-
kwargs['need_install'] = _yesno("I will install Julia packages using PySR's Project.toml file. OK?")
|
272 |
-
|
|
|
273 |
|
274 |
kwargs['def_hyperparams'] = _create_inline_operators(**kwargs)
|
275 |
|
@@ -572,13 +574,6 @@ def _check_assertions(X, binary_operators, unary_operators, use_custom_variable_
|
|
572 |
assert len(variable_names) == X.shape[1]
|
573 |
|
574 |
|
575 |
-
def _raise_depreciation_errors(limitPowComplexity, threads):
|
576 |
-
if threads is not None:
|
577 |
-
raise ValueError("The threads kwarg is deprecated. Use procs.")
|
578 |
-
if limitPowComplexity:
|
579 |
-
raise ValueError("The limitPowComplexity kwarg is deprecated. Use constraints.")
|
580 |
-
|
581 |
-
|
582 |
def run_feature_selection(X, y, select_k_features):
|
583 |
"""Use a gradient boosting tree regressor as a proxy for finding
|
584 |
the k most important features in X, returning indices for those
|
|
|
100 |
useFrequency=False,
|
101 |
tempdir=None,
|
102 |
delete_tempfiles=True,
|
|
|
|
|
103 |
julia_optimization=3,
|
104 |
julia_project=None,
|
105 |
user_input=True
|
106 |
):
|
107 |
"""Run symbolic regression to fit f(X[i, :]) ~ y[i] for all i.
|
108 |
Note: most default parameters have been tuned over several example
|
109 |
+
equations, but you should adjust `niterations`,
|
110 |
`binary_operators`, `unary_operators` to your requirements.
|
111 |
|
112 |
:param X: np.ndarray or pandas.DataFrame, 2D array. Rows are examples,
|
|
|
189 |
:param tempdir: str or None, directory for the temporary files
|
190 |
:param delete_tempfiles: bool, whether to delete the temporary files after finishing
|
191 |
:param julia_project: str or None, a Julia environment location containing
|
192 |
+
a Project.toml (and potentially the source code for SymbolicRegression.jl).
|
193 |
+
Default gives the Python package directory, where a Project.toml file
|
194 |
+
should be present from the install.
|
195 |
+
:param user_input: Whether to ask for user input or not for installing (to
|
196 |
+
be used for automated scripts). Will choose to install when asked.
|
197 |
:returns: pd.DataFrame, Results dataframe, giving complexity, MSE, and equations
|
198 |
(as strings).
|
199 |
|
200 |
"""
|
|
|
|
|
201 |
if isinstance(X, pd.DataFrame):
|
202 |
variable_names = list(X.columns)
|
203 |
X = np.array(X)
|
|
|
267 |
kwargs = {**_set_paths(tempdir), **kwargs}
|
268 |
|
269 |
pkg_directory = kwargs['pkg_directory']
|
270 |
+
kwargs['need_install'] = False
|
271 |
if not (pkg_directory / 'Manifest.toml').is_file():
|
272 |
+
kwargs['need_install'] = (not user_input) or _yesno("I will install Julia packages using PySR's Project.toml file. OK?")
|
273 |
+
if kwargs['need_install']:
|
274 |
+
print("OK. I will install at launch.")
|
275 |
|
276 |
kwargs['def_hyperparams'] = _create_inline_operators(**kwargs)
|
277 |
|
|
|
574 |
assert len(variable_names) == X.shape[1]
|
575 |
|
576 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
577 |
def run_feature_selection(X, y, select_k_features):
|
578 |
"""Use a gradient boosting tree regressor as a proxy for finding
|
579 |
the k most important features in X, returning indices for those
|