MilesCranmer commited on
Commit
ad6d652
1 Parent(s): e5a9067

Fix custom variable names

Browse files
Files changed (1) hide show
  1. pysr/sr.py +11 -10
pysr/sr.py CHANGED
@@ -997,10 +997,10 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
997
  model.n_features_in_ = n_features_in
998
 
999
  if feature_names_in is None:
1000
- model.feature_names_in_ = [f"x{i}" for i in range(n_features_in)]
1001
- model.pretty_feature_names_in_ = [
1002
- f"x{_subscriptify(i)}" for i in range(n_features_in)
1003
- ]
1004
  else:
1005
  assert len(feature_names_in) == n_features_in
1006
  model.feature_names_in_ = feature_names_in
@@ -1395,10 +1395,10 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
1395
  )
1396
 
1397
  if self.feature_names_in_ is None:
1398
- self.feature_names_in_ = [f"x{i}" for i in range(X.shape[1])]
1399
- self.pretty_feature_names_in_ = [
1400
- f"x{_subscriptify(i)}" for i in range(X.shape[1])
1401
- ]
1402
  else:
1403
  self.pretty_feature_names_in_ = None
1404
 
@@ -1474,6 +1474,7 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
1474
  X, y = self._validate_data(X=X, y=y, reset=True, multi_output=True)
1475
  # Update feature names with selected variable names
1476
  self.feature_names_in_ = _check_feature_names_in(self, variable_names)
 
1477
  print(f"Using features {self.feature_names_in_}")
1478
 
1479
  # Denoising transformation
@@ -1724,9 +1725,9 @@ class PySRRegressor(MultiOutputMixin, RegressorMixin, BaseEstimator):
1724
  weights=Main.weights,
1725
  niterations=int(self.niterations),
1726
  variable_names=(
1727
- self.pretty_feature_names_in_
1728
  if self.pretty_feature_names_in_ is not None
1729
- else self.feature_names_in_
1730
  ),
1731
  options=options,
1732
  numprocs=cprocs,
 
997
  model.n_features_in_ = n_features_in
998
 
999
  if feature_names_in is None:
1000
+ model.feature_names_in_ = np.array([f"x{i}" for i in range(n_features_in)])
1001
+ model.pretty_feature_names_in_ = np.array(
1002
+ [f"x{_subscriptify(i)}" for i in range(n_features_in)]
1003
+ )
1004
  else:
1005
  assert len(feature_names_in) == n_features_in
1006
  model.feature_names_in_ = feature_names_in
 
1395
  )
1396
 
1397
  if self.feature_names_in_ is None:
1398
+ self.feature_names_in_ = np.array([f"x{i}" for i in range(X.shape[1])])
1399
+ self.pretty_feature_names_in_ = np.array(
1400
+ [f"x{_subscriptify(i)}" for i in range(X.shape[1])]
1401
+ )
1402
  else:
1403
  self.pretty_feature_names_in_ = None
1404
 
 
1474
  X, y = self._validate_data(X=X, y=y, reset=True, multi_output=True)
1475
  # Update feature names with selected variable names
1476
  self.feature_names_in_ = _check_feature_names_in(self, variable_names)
1477
+ self.pretty_feature_names_in_ = None
1478
  print(f"Using features {self.feature_names_in_}")
1479
 
1480
  # Denoising transformation
 
1725
  weights=Main.weights,
1726
  niterations=int(self.niterations),
1727
  variable_names=(
1728
+ self.pretty_feature_names_in_.tolist()
1729
  if self.pretty_feature_names_in_ is not None
1730
+ else self.feature_names_in_.tolist()
1731
  ),
1732
  options=options,
1733
  numprocs=cprocs,