Giter Site home page Giter Site logo

gustavocarita / categorical-encoding Goto Github PK

View Code? Open in Web Editor NEW

This project forked from scikit-learn-contrib/category_encoders

0.0 1.0 0.0 3.23 MB

A library of sklearn compatible categorical variable encoders

Home Page: http://contrib.scikit-learn.org/categorical-encoding/

License: BSD 3-Clause "New" or "Revised" License

Python 96.31% Shell 3.69%

categorical-encoding's Introduction

Categorical Encoding Methods

Travis Status Coveralls Status CircleCI Status

A set of scikit-learn-style transformers for encoding categorical variables into numeric by means of different techniques.

Important Links

Documentation: http://contrib.scikit-learn.org/categorical-encoding/

Encoding Methods

  • Ordinal [2][3]
  • One-Hot [2][3]
  • Binary [5]
  • Helmert Contrast [2][3]
  • Sum Contrast [2][3]
  • Polynomial Contrast [2][3]
  • Backward Difference Contrast [2][3]
  • Hashing [1]
  • BaseN [6]
  • LeaveOneOut [4]

Usage

The package by itself comes with a single module and an estimator. Before installing the module you will need numpy, statsmodels, and scipy.

To install the module execute:

$ python setup.py install

or

pip install category_encoders

or

conda install -c conda-forge category_encoders

To use:

import category_encoders as ce

encoder = ce.BackwardDifferenceEncoder(cols=[...])
encoder = ce.BinaryEncoder(cols=[...])
encoder = ce.HashingEncoder(cols=[...])
encoder = ce.HelmertEncoder(cols=[...])
encoder = ce.OneHotEncoder(cols=[...])
encoder = ce.OrdinalEncoder(cols=[...])
encoder = ce.SumEncoder(cols=[...])
encoder = ce.PolynomialEncoder(cols=[...])
encoder = ce.BaseNEncoder(cols=[...])
encoder = ce.LeaveOneOutEncoder(cols=[...])

All of these are fully compatible sklearn transformers, so they can be used in pipelines or in your existing scripts. If the cols parameter isn't passed, every non-numeric column will be encoded. Please see the docs for transformer-specific configuration options.

Examples

In the examples directory, there is an example script used to benchmark different encoding techniques on various datasets.

The datasets used in the examples are car, mushroom, and splice datasets from the UCI dataset repository, found here:

datasets

License

BSD 3-Clause

References:

  1. Kilian Weinberger; Anirban Dasgupta; John Langford; Alex Smola; Josh Attenberg (2009). Feature Hashing for Large Scale Multitask Learning. Proc. ICML.
  2. Contrast Coding Systems for categorical variables. UCLA: Statistical Consulting Group. from https://stats.idre.ucla.edu/r/library/r-library-contrast-coding-systems-for-categorical-variables/.
  3. Gregory Carey (2003). Coding Categorical Variables, from http://psych.colorado.edu/~carey/Courses/PSYC5741/handouts/Coding%20Categorical%20Variables%202006-03-03.pdf
  4. Strategies to encode categorical variables with many categories. from https://www.kaggle.com/c/caterpillar-tube-pricing/discussion/15748#143154.
  5. Beyond One-Hot: an exploration of categorical variables. from http://www.willmcginnis.com/2015/11/29/beyond-one-hot-an-exploration-of-categorical-variables/
  6. BaseN Encoding and Grid Search in categorical variables. from http://www.willmcginnis.com/2016/12/18/basen-encoding-grid-search-category_encoders/

categorical-encoding's People

Contributors

bollwyvl avatar camerondavison avatar hbghhy avatar wdm0006 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.