Spaces:
Running
Running
Commit
·
51b7bbd
1
Parent(s):
f7ce7ac
Tweak docs formatting
Browse files- pysr/sr.py +2 -30
pysr/sr.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
"""
|
| 2 |
import copy
|
| 3 |
import os
|
| 4 |
import sys
|
|
@@ -777,32 +777,25 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 777 |
equation_file : str
|
| 778 |
Path to a pickle file containing a saved model, or a csv file
|
| 779 |
containing equations.
|
| 780 |
-
|
| 781 |
binary_operators : list[str]
|
| 782 |
The same binary operators used when creating the model.
|
| 783 |
Not needed if loading from a pickle file.
|
| 784 |
-
|
| 785 |
unary_operators : list[str]
|
| 786 |
The same unary operators used when creating the model.
|
| 787 |
Not needed if loading from a pickle file.
|
| 788 |
-
|
| 789 |
n_features_in : int
|
| 790 |
Number of features passed to the model.
|
| 791 |
Not needed if loading from a pickle file.
|
| 792 |
-
|
| 793 |
feature_names_in : list[str]
|
| 794 |
Names of the features passed to the model.
|
| 795 |
Not needed if loading from a pickle file.
|
| 796 |
-
|
| 797 |
selection_mask : list[bool]
|
| 798 |
If using select_k_features, you must pass `model.selection_mask_` here.
|
| 799 |
Not needed if loading from a pickle file.
|
| 800 |
-
|
| 801 |
nout : int, default=1
|
| 802 |
Number of outputs of the model.
|
| 803 |
Not needed if loading from a pickle file.
|
| 804 |
-
|
| 805 |
-
pysr_kwargs : dict
|
| 806 |
Any other keyword arguments to initialize the PySRRegressor object.
|
| 807 |
These will overwrite those stored in the pickle file.
|
| 808 |
Not needed if loading from a pickle file.
|
|
@@ -1174,18 +1167,14 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1174 |
----------
|
| 1175 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1176 |
Training data.
|
| 1177 |
-
|
| 1178 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1179 |
Target values. Will be cast to X's dtype if necessary.
|
| 1180 |
-
|
| 1181 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1182 |
(n_resampled, n_features), default=None
|
| 1183 |
Resampled training data used for denoising.
|
| 1184 |
-
|
| 1185 |
weights : {ndarray | pandas.DataFrame} of the same shape as y
|
| 1186 |
Each element is how to weight the mean-square-error loss
|
| 1187 |
for that particular element of y.
|
| 1188 |
-
|
| 1189 |
variable_names : list[str] of length n_features
|
| 1190 |
Names of each variable in the training dataset, `X`.
|
| 1191 |
|
|
@@ -1193,13 +1182,10 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1193 |
-------
|
| 1194 |
X_validated : ndarray of shape (n_samples, n_features)
|
| 1195 |
Validated training data.
|
| 1196 |
-
|
| 1197 |
y_validated : ndarray of shape (n_samples,) or (n_samples, n_targets)
|
| 1198 |
Validated target data.
|
| 1199 |
-
|
| 1200 |
Xresampled : ndarray of shape (n_resampled, n_features)
|
| 1201 |
Validated resampled training data used for denoising.
|
| 1202 |
-
|
| 1203 |
variable_names_validated : list[str] of length n_features
|
| 1204 |
Validated list of variable names for each feature in `X`.
|
| 1205 |
|
|
@@ -1260,17 +1246,13 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1260 |
----------
|
| 1261 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1262 |
Training data.
|
| 1263 |
-
|
| 1264 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1265 |
Target values. Will be cast to X's dtype if necessary.
|
| 1266 |
-
|
| 1267 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1268 |
(n_resampled, n_features), default=None
|
| 1269 |
Resampled training data used for denoising.
|
| 1270 |
-
|
| 1271 |
variable_names : list[str] of length n_features
|
| 1272 |
Names of each variable in the training dataset, `X`.
|
| 1273 |
-
|
| 1274 |
random_state : int, Numpy RandomState instance or None, default=None
|
| 1275 |
Pass an int for reproducible results across multiple function calls.
|
| 1276 |
See :term:`Glossary <random_state>`.
|
|
@@ -1284,13 +1266,11 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1284 |
equal to :param`X.shape[0]`. n_features will be equal to
|
| 1285 |
:param`self.select_k_features` if `self.select_k_features is not None`,
|
| 1286 |
otherwise it will be equal to :param`X.shape[1]`
|
| 1287 |
-
|
| 1288 |
y_transformed : ndarray of shape (n_samples,) or (n_samples, n_outputs)
|
| 1289 |
Transformed target data. n_samples will be equal to
|
| 1290 |
:param`Xresampled.shape[0]` if :param`self.denoise` is `True`,
|
| 1291 |
and :param`Xresampled is not None`, otherwise it will be
|
| 1292 |
equal to :param`X.shape[0]`.
|
| 1293 |
-
|
| 1294 |
variable_names_transformed : list[str] of length n_features
|
| 1295 |
Names of each variable in the transformed dataset,
|
| 1296 |
`X_transformed`.
|
|
@@ -1341,17 +1321,13 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1341 |
----------
|
| 1342 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1343 |
Training data.
|
| 1344 |
-
|
| 1345 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1346 |
Target values. Will be cast to X's dtype if necessary.
|
| 1347 |
-
|
| 1348 |
mutated_params : dict[str, Any]
|
| 1349 |
Dictionary of mutated versions of some parameters passed in __init__.
|
| 1350 |
-
|
| 1351 |
weights : {ndarray | pandas.DataFrame} of the same shape as y
|
| 1352 |
Each element is how to weight the mean-square-error loss
|
| 1353 |
for that particular element of y.
|
| 1354 |
-
|
| 1355 |
seed : int
|
| 1356 |
Random seed for julia backend process.
|
| 1357 |
|
|
@@ -1592,21 +1568,17 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
|
|
| 1592 |
----------
|
| 1593 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1594 |
Training data.
|
| 1595 |
-
|
| 1596 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1597 |
Target values. Will be cast to X's dtype if necessary.
|
| 1598 |
-
|
| 1599 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1600 |
(n_resampled, n_features), default=None
|
| 1601 |
Resampled training data to generate a denoised data on. This
|
| 1602 |
will be used as the training data, rather than `X`.
|
| 1603 |
-
|
| 1604 |
weights : {ndarray | pandas.DataFrame} of the same shape as y, default=None
|
| 1605 |
Each element is how to weight the mean-square-error loss
|
| 1606 |
for that particular element of `y`. Alternatively,
|
| 1607 |
if a custom `loss` was set, it will can be used
|
| 1608 |
in arbitrary ways.
|
| 1609 |
-
|
| 1610 |
variable_names : list[str], default=None
|
| 1611 |
A list of names for the variables, rather than "x0", "x1", etc.
|
| 1612 |
If :param`X` is a pandas dataframe, the column names will be used
|
|
|
|
| 1 |
+
"""Define the PySRRegressor scikit-learn interface."""
|
| 2 |
import copy
|
| 3 |
import os
|
| 4 |
import sys
|
|
|
|
| 777 |
equation_file : str
|
| 778 |
Path to a pickle file containing a saved model, or a csv file
|
| 779 |
containing equations.
|
|
|
|
| 780 |
binary_operators : list[str]
|
| 781 |
The same binary operators used when creating the model.
|
| 782 |
Not needed if loading from a pickle file.
|
|
|
|
| 783 |
unary_operators : list[str]
|
| 784 |
The same unary operators used when creating the model.
|
| 785 |
Not needed if loading from a pickle file.
|
|
|
|
| 786 |
n_features_in : int
|
| 787 |
Number of features passed to the model.
|
| 788 |
Not needed if loading from a pickle file.
|
|
|
|
| 789 |
feature_names_in : list[str]
|
| 790 |
Names of the features passed to the model.
|
| 791 |
Not needed if loading from a pickle file.
|
|
|
|
| 792 |
selection_mask : list[bool]
|
| 793 |
If using select_k_features, you must pass `model.selection_mask_` here.
|
| 794 |
Not needed if loading from a pickle file.
|
|
|
|
| 795 |
nout : int, default=1
|
| 796 |
Number of outputs of the model.
|
| 797 |
Not needed if loading from a pickle file.
|
| 798 |
+
**pysr_kwargs : dict
|
|
|
|
| 799 |
Any other keyword arguments to initialize the PySRRegressor object.
|
| 800 |
These will overwrite those stored in the pickle file.
|
| 801 |
Not needed if loading from a pickle file.
|
|
|
|
| 1167 |
----------
|
| 1168 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1169 |
Training data.
|
|
|
|
| 1170 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1171 |
Target values. Will be cast to X's dtype if necessary.
|
|
|
|
| 1172 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1173 |
(n_resampled, n_features), default=None
|
| 1174 |
Resampled training data used for denoising.
|
|
|
|
| 1175 |
weights : {ndarray | pandas.DataFrame} of the same shape as y
|
| 1176 |
Each element is how to weight the mean-square-error loss
|
| 1177 |
for that particular element of y.
|
|
|
|
| 1178 |
variable_names : list[str] of length n_features
|
| 1179 |
Names of each variable in the training dataset, `X`.
|
| 1180 |
|
|
|
|
| 1182 |
-------
|
| 1183 |
X_validated : ndarray of shape (n_samples, n_features)
|
| 1184 |
Validated training data.
|
|
|
|
| 1185 |
y_validated : ndarray of shape (n_samples,) or (n_samples, n_targets)
|
| 1186 |
Validated target data.
|
|
|
|
| 1187 |
Xresampled : ndarray of shape (n_resampled, n_features)
|
| 1188 |
Validated resampled training data used for denoising.
|
|
|
|
| 1189 |
variable_names_validated : list[str] of length n_features
|
| 1190 |
Validated list of variable names for each feature in `X`.
|
| 1191 |
|
|
|
|
| 1246 |
----------
|
| 1247 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1248 |
Training data.
|
|
|
|
| 1249 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1250 |
Target values. Will be cast to X's dtype if necessary.
|
|
|
|
| 1251 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1252 |
(n_resampled, n_features), default=None
|
| 1253 |
Resampled training data used for denoising.
|
|
|
|
| 1254 |
variable_names : list[str] of length n_features
|
| 1255 |
Names of each variable in the training dataset, `X`.
|
|
|
|
| 1256 |
random_state : int, Numpy RandomState instance or None, default=None
|
| 1257 |
Pass an int for reproducible results across multiple function calls.
|
| 1258 |
See :term:`Glossary <random_state>`.
|
|
|
|
| 1266 |
equal to :param`X.shape[0]`. n_features will be equal to
|
| 1267 |
:param`self.select_k_features` if `self.select_k_features is not None`,
|
| 1268 |
otherwise it will be equal to :param`X.shape[1]`
|
|
|
|
| 1269 |
y_transformed : ndarray of shape (n_samples,) or (n_samples, n_outputs)
|
| 1270 |
Transformed target data. n_samples will be equal to
|
| 1271 |
:param`Xresampled.shape[0]` if :param`self.denoise` is `True`,
|
| 1272 |
and :param`Xresampled is not None`, otherwise it will be
|
| 1273 |
equal to :param`X.shape[0]`.
|
|
|
|
| 1274 |
variable_names_transformed : list[str] of length n_features
|
| 1275 |
Names of each variable in the transformed dataset,
|
| 1276 |
`X_transformed`.
|
|
|
|
| 1321 |
----------
|
| 1322 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1323 |
Training data.
|
|
|
|
| 1324 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1325 |
Target values. Will be cast to X's dtype if necessary.
|
|
|
|
| 1326 |
mutated_params : dict[str, Any]
|
| 1327 |
Dictionary of mutated versions of some parameters passed in __init__.
|
|
|
|
| 1328 |
weights : {ndarray | pandas.DataFrame} of the same shape as y
|
| 1329 |
Each element is how to weight the mean-square-error loss
|
| 1330 |
for that particular element of y.
|
|
|
|
| 1331 |
seed : int
|
| 1332 |
Random seed for julia backend process.
|
| 1333 |
|
|
|
|
| 1568 |
----------
|
| 1569 |
X : {ndarray | pandas.DataFrame} of shape (n_samples, n_features)
|
| 1570 |
Training data.
|
|
|
|
| 1571 |
y : {ndarray | pandas.DataFrame} of shape (n_samples,) or (n_samples, n_targets)
|
| 1572 |
Target values. Will be cast to X's dtype if necessary.
|
|
|
|
| 1573 |
Xresampled : {ndarray | pandas.DataFrame} of shape
|
| 1574 |
(n_resampled, n_features), default=None
|
| 1575 |
Resampled training data to generate a denoised data on. This
|
| 1576 |
will be used as the training data, rather than `X`.
|
|
|
|
| 1577 |
weights : {ndarray | pandas.DataFrame} of the same shape as y, default=None
|
| 1578 |
Each element is how to weight the mean-square-error loss
|
| 1579 |
for that particular element of `y`. Alternatively,
|
| 1580 |
if a custom `loss` was set, it will can be used
|
| 1581 |
in arbitrary ways.
|
|
|
|
| 1582 |
variable_names : list[str], default=None
|
| 1583 |
A list of names for the variables, rather than "x0", "x1", etc.
|
| 1584 |
If :param`X` is a pandas dataframe, the column names will be used
|