Home » Data Science Resources » Best Categorical Variable Encoding Techniques

Best Categorical Variable Encoding Techniques

What is Feature Encoding?

Feature Encoding is a technique from the Feature engineering or Data preprocessing pipeline. It is applied to categorical features to convert them into numerical equivalent, as the machine learning algorithm cannot understand the string type of data. There are many encoding techniques used for feature engineering, let’s explore some of them

Best categorical variable encoding techniques
  • Label Encoding:

It is the encoding technique that works on the alphabets present in the label. It will assign male as 1 and female as 2 as in alphabet order f comes before m.

[male,female] [1,0]
[blue,orange,red] [0,1,2]
  • Ordinal encoding:

Ordinal encoding is the technique to encode ordinal features i.e which follows a certain order.

[cold,warm,hot] [0,1,2]
[poor,fair,good,very good,excellent] [0,1,2,3,4]
[bearable pain,moderate pain,unbearable pain] [0,1,2]
  • Frequency encoding:

Frequency encoding is an encoding technique to transform an original categorical variable to a numerical variable by considering the frequency distribution of the data getting value counts. It can be useful for nominal features. Nominal features don’t have any order

  • Binary encoding:

It is an encoding technique which first converts the categorical data to numerical using label encoding and then employs one hot encoding on the label encoded feature.

  • One hot encoding:

One hot encoding technique creates new features using the labels which are
Present and wherever the label is present it will mark that feature as 1 and rest other features as 0.

These are generally used encoding techniques however based on data and domain we can have more ways to convert the categorical data.Do apply to your data and see the performance of each technique.

Keep Learning.

About DataMites Team

DataMites Team will publish articles on various topics like data science, machine learning, artificial intelligence, deep learning, python programming, statistics, DataMites® press releases and career guidance.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

x

Check Also

AI or Data Science Learn In Detail

AI or Data Science Learn In Detail

Technology has turned our existence upside down. Modern technology has advanced our lives in multitudinous ways – restructuring the way we live, work, think, and ...

The Ultimate Guide to Become a Machine Learning Engineer

The Ultimate Guide to Become a Machine Learning Engineer

Introduction: Machine learning is facilitating computers to equip and address all the tasks that have been until then performed by man. Machine learning has been ...