Skip to content

Commit

Permalink
fix: bug with feature selection and excluded features (#137)
Browse files Browse the repository at this point in the history
* fix: include excluded from feature_selection features into the final set of selected features

* fix: set self.selected_features as list
  • Loading branch information
vassilismin authored Dec 17, 2024
1 parent 8a754fb commit f92f991
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions jaqpotpy/datasets/jaqpotpy_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,21 +319,22 @@ def select_features(
)
transformed_X = FeatureSelector.fit_transform(X_filtered)
selected_columns_mask = FeatureSelector.get_support()
self.selected_features = X_filtered.columns[selected_columns_mask]
self.selected_features = X_filtered.columns[selected_columns_mask].tolist()
self.X = pd.concat(
[
pd.DataFrame(data=transformed_X, columns=self.selected_features),
X_excluded,
],
axis=1,
)
self.selected_features += X_excluded.columns.tolist()

elif SelectColumns is not None:
if not all(item in self.X.columns for item in SelectColumns):
raise ValueError("Provided features not in dataset features")
else:
self.X = self.X[SelectColumns]
self.selected_features = SelectColumns
self.selected_features = SelectColumns + X_excluded.columns.tolist()

def copy(self):
"""
Expand Down

0 comments on commit f92f991

Please sign in to comment.