Skip to main content

Automatic Feature Engineering and Selection Linear Prediction Model

Project description

autofeat library

Linear Prediction Models with Automated Feature Engineering and Selection

This library contains the AutoFeatRegressor and AutoFeatClassifier models with a similar interface as scikit-learn models:

  • fit() function to fit the model parameters
  • predict() function to predict the target variable given the input
  • score() function to calculate the goodness of the fit (R^2/accuracy)
  • fit_transform() and transform() functions, which extend the given data by the additional features that were engineered and selected by the model

When calling the fit() function, internally the fit_transform() function will be called, so if you're planing to call transform() on the same data anyways, just call fit_transform() right away. transform() is mostly useful if you've split your data into training and test data and did not call fit_transform() on your whole dataset. The predict() and score() functions can either be given data in the format of the original dataframe that was used when calling fit()/fit_transform() or they can be given an already transformed dataframe.

In addition, only the feature selection part is also available in the FeatureSelector model.

Furthermore (as of version 2.0.0), minimal feature selection (removing zero variance and redundant features), engineering (simple product and ratio of features), and scaling (power transform to make features more normally distributed) is also available in the AutoFeatLight model.

The AutoFeatRegressor, AutoFeatClassifier, and FeatureSelector models need to be fit on data without NaNs, as they internally call the sklearn LassoLarsCV model, which can not handle NaNs. When calling transform(), NaNs (but not np.inf) are okay.

The autofeat examples notebook contains a simple usage example - try it out! :) Additional examples can be found in the autofeat benchmark notebooks for regression (which also contains the code to reproduce the results from the paper mentioned below) and classification, as well as the testing scripts.

Please keep in mind that since the AutoFeatRegressor and AutoFeatClassifier models can generate very complex features, they might overfit on noise in the dataset, i.e., find some new features that lead to good prediction on the training set but result in a poor performance on new test samples. While this usually only happens for datasets with very few samples, we suggest you carefully inspect the features found by autofeat and use those that make sense to you to train your own models.

Depending on the number of feateng_steps (default 2) and the number of input features, autofeat can generate a very huge feature matrix (before selecting the most appropriate features from this large feature pool). By specifying in feateng_cols those columns that you expect to be most valuable in the feature engineering part, the number of features can be greatly reduced. Additionally, transformations can be limited to only those feature transformations that make sense for your data. Last but not least, you can subsample the data used for training the model to limit the memory requirements. After the model was fit, you can call transform() on your whole dataset to generate only those few features that were selected during fit()/fit_transform().

Installation

You can either download the code from here and include the autofeat folder in your $PYTHONPATH or install (the library components only) via pip:

$ pip install autofeat

The library requires Python 3! Other dependencies: numpy, pandas, scikit-learn, sympy, joblib, and pint

Paper

For further details on the model and implementation please refer to the paper - and of course if any of this code was helpful for your research, please consider citing it:

@inproceedings{horn2019autofeat,
  title={The autofeat Python Library for Automated Feature Engineering and Selection},
  author={Horn, Franziska and Pack, Robert and Rieger, Michael},
  booktitle={Joint European Conference on Machine Learning and Knowledge Discovery in Databases},
  pages={111--120},
  year={2019},
  organization={Springer}
}

If you don't like reading, you can also watch a video of my talk at the PyData conference about automated feature engineering and selection with autofeat.

The code is intended for research purposes.

If you have any questions please don't hesitate to send me an email and of course if you should find any bugs or want to contribute other improvements, pull requests are very welcome!

Acknowledgments

This project was made possible thanks to support by BASF.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autofeat-2.0.3.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autofeat-2.0.3-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file autofeat-2.0.3.tar.gz.

File metadata

  • Download URL: autofeat-2.0.3.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.3

File hashes

Hashes for autofeat-2.0.3.tar.gz
Algorithm Hash digest
SHA256 a07212bc87e75ec1be161c1c3c940d0061a15f32224e1c2f5b151ba376064183
MD5 97d9d273a7b839c3539586028c1db498
BLAKE2b-256 9b40c70c93e5c0729eae2cb9e54d8c4129875df9b06bb0905fb0e475e3c5cbc2

See more details on using hashes here.

File details

Details for the file autofeat-2.0.3-py3-none-any.whl.

File metadata

  • Download URL: autofeat-2.0.3-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0.post20201006 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.3

File hashes

Hashes for autofeat-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8206bf65e42a548d91942569818c2242e5d43a4e95027e9bcfba341040ecc630
MD5 a2aaf661acac3ac431da759ec9112ce6
BLAKE2b-256 f1f52133502cbcbbf59b3ab382331d3372237c771c7cb60c398a3d1471c7ff79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page