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

[WIP] Support pandas DataFrames and feature names in SequentialFeatureSelector #379

Merged
merged 2 commits into from
May 6, 2018

Conversation

rasbt
Copy link
Owner

@rasbt rasbt commented May 5, 2018

Description

Adds support for a feature names and pandas DataFrames in the SequentialFeatureSelector. In particular, the SFS methods (fit, transform, etc.) now support pandas DataFrames in addition to NumPy(-like) arrays. Also, the feature names will be recorded in self.k_feature_names_ as well as self.subsets_['feature_names']. If a pandas DataFrame is provided as input, these feature names are correspond to the column names. Otherwise, the column indices as string representation will be used as a placeholder.

Finally, an optional feature_names parameter is added to the SequentialFeatureSelector constructor, which allows users to pass custom feature names corresponding to column indices to improve the interpretability of the selected feature subsets via self.subsets_['feature_names'] and self.k_feature_names_. Note that user-provided feature names have precedence over feature names based on column indices or pandas DataFrame columns but are only used for labeling purposes.

Related issues or pull requests

Fixes #311

Pull Request Checklist

  • Added a note about the modification or contribution to the ./docs/sources/CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./mlxtend/*/tests directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under mlxtend/docs/sources/ (if applicable)
  • Ran nosetests ./mlxtend -sv and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., nosetests ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv)
  • Checked for style issues by running flake8 ./mlxtend

@rasbt rasbt changed the title Support pandas DataFrames and feature names in SequentialFeatureSelector Support pandas DataFrames and feature names in SequentialFeatureSelector [WIP] May 5, 2018
@rasbt rasbt changed the title Support pandas DataFrames and feature names in SequentialFeatureSelector [WIP] [WIP] Support pandas DataFrames and feature names in SequentialFeatureSelector May 5, 2018
@coveralls
Copy link

coveralls commented May 5, 2018

Coverage Status

Coverage increased (+0.08%) to 91.063% when pulling b1a3b36 on featsele-pandas into 9722b43 on master.

@rasbt rasbt merged commit 3b9dfa9 into master May 6, 2018
@jrbourbeau
Copy link
Contributor

This is a nice new feature, good idea @rasbt!

@rasbt rasbt deleted the featsele-pandas branch May 9, 2018 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants