Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random subsampling for feature selection #47 #650

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion mlxtend/feature_selection/sequential_feature_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ def fit(self, X, y, custom_feature_names=None, groups=None, **fit_params):

else:
select_in_range = False
k_to_select = self.k_features
k_to_select = int(len(X[1])**.5)
np.take(X, np.random.permutation(X.shape[1]), axis=1, out=X)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Lareina, thanks for the PR. I don't quite understand how the value is chosen k_to_select = int(len(X[1])**.5). So this means that the random subset is always sqrt of the original number of features?

There are two problems with that.

  1. We want to add the random feature subset size as an optional thing
  2. I think we should let the user allow to choose the subset size

There could be a new parameter

use_random_feature_subset for the SequentialFeatureSelector class which either accepts a function like f = lambda x: int(np.sqrt(x) or None.

Let me know if you have questions.


orig_set = set(range(X_.shape[1]))
n_features = X_.shape[1]
Expand Down