Skip to main content

A collection sklearn transformers to encode categorical variables as numeric

Project description

A set of example problems examining different encoding methods for categorical variables for the purpose of classification. Optionally, install the library of encoders as a package and use them in your projects directly. They are all available as methods or as scikit-learn compatible transformers.

Docs [here](http://wdm0006.github.io/categorical_encoding/)

Encoding Methods

  • Ordinal

  • One-Hot

  • Binary

  • Helmert Contrast

  • Sum Contrast

  • Polynomial Contrast

  • Backward Difference Contrast

  • Hashing

Usage

Either run the examples in encoding_examples.py, or install as:

pip install 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=[…])

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 column will be encoded, so be careful with that.

Datasets

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

[datasets](https://archive.ics.uci.edu/ml/datasets)

License

BSD

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

category_encoders-1.2.0.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file category_encoders-1.2.0.tar.gz.

File metadata

File hashes

Hashes for category_encoders-1.2.0.tar.gz
Algorithm Hash digest
SHA256 0945a6b671ed443c63e7b7ad10c298e8affd3abd624b713d19bfb404a0fd1670
MD5 a4072c2a4bcb0b59bcc01ee0e5c108f5
BLAKE2b-256 dc79a727487faa1c0354024bd0192462f8c7e1d8a3b59119e09e101bc46249ac

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