[FEATURE] Categorical Feature Embedding via MLP

Open
#432 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale

Research direction

The request is to add a categorical encoder built on sklearn's MLPClassifier or MLPRegressor, using the hidden layer output as the encoding. Start from the existing categorical encoders in feature_engine/encoding and their shared base class to match the fit/transform API. The proposal lives in an external repository, and the issue thread has no maintainer decision, so confirm scope before writing code. Done means an encoder class with tests and docs that follows the library's conventions.

Written by the indexing model from the issue text.

Description

Using an Embeddinglayer of a deep neural network to encode categorical variables is a common practice also known as "entity embedding". One problem is, that you have to install a deeplearning library like pytroch or tensorflow to implement the neural network with an embedding layer and they are heavy libraries.

One alternative approach could be to use the MLPClassifier, MLPRegressor class from sklearn.neural_network build a neural network of your choice and use the last layer before the classification head to encode categorical variables. One could encode each variable alone or input more variable at once to encode so that the interactions can be found by the neural network.

I have coded this feature and you can take a look at mlpencoder. I would implement this feature in feature engine if you agree.

Examples: https://github.com/Pacman1984/mlpencoder/blob/master/mlpencoder/test.ipynb

Dominant language
Python
Stars
2.3k
Forks
391
Avg merge
11h 34m
Merged PRs (30d)
11

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from feature-engine/feature_engine

All issues in feature-engine/feature_engine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.