From f92f99150733f555035184411419d7df795135fd Mon Sep 17 00:00:00 2001 From: Vassilis Minadakis <56068291+vassilismin@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:02:29 +0200 Subject: [PATCH] fix: bug with feature selection and excluded features (#137) * fix: include excluded from feature_selection features into the final set of selected features * fix: set self.selected_features as list --- jaqpotpy/datasets/jaqpotpy_dataset.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jaqpotpy/datasets/jaqpotpy_dataset.py b/jaqpotpy/datasets/jaqpotpy_dataset.py index d4da3f7..57e77fe 100644 --- a/jaqpotpy/datasets/jaqpotpy_dataset.py +++ b/jaqpotpy/datasets/jaqpotpy_dataset.py @@ -319,7 +319,7 @@ 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), @@ -327,13 +327,14 @@ def select_features( ], 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): """