SAP interview Questions | Label Encoding

Question

We know that one hot encoding increases the dimensionality of a dataset, but label encoding doesn’t. How?

in progress 0
Dhruv2301 55 years 2 Answers 949 views Great Grand Master 0

Answers ( 2 )

  1. LabelEncoder encode labels with a value between 0 and n_classes-1 where n is the number of distinct labels. If a label repeats it assigns the same value to as assigned earlier, and this is restricted to a single column (the variable)

    Whereas,

    What one hot encoding does is, it takes a column which has categorical data, which has been label encoded and then splits the column into multiple columns. The numbers are replaced by 1s and 0s, depending on which column has what value.

  2. In one-hot encoding, the categories that exist in one column are converted into a different
    feature and they are represented as 1’s and 0’s. So, it leads to an increase in the no of columns.
    Label encoding will simply represent your categories as numerical code. Suppose, you have 3
    categories, it will represent it as 0,1,2 in the same column. So, it does not lead to increase in the
    dimension.

Leave an answer

Browse
Browse