1. Home
  2. Data Science
  3. Scikit-learn
  4. Why is LabelEncoder unsuitable for encoding a categorical…

Added 30 Nov -0001

Why is LabelEncoder unsuitable for encoding a categorical feature column before fitting a linear model?

  1. It imposes an arbitrary ordinal order, which the model then treats as numeric distance Correct answer
  2. It fails on columns that contain more than two distinct categories at once
  3. It returns one-hot columns, which cause perfect multicollinearity in the design matrix
  4. It only works on the target vector, so calling it on a feature column raises an error

Correct answer

A. It imposes an arbitrary ordinal order, which the model then treats as numeric distance

17 views

MCQSEXAM

Explanation

LabelEncoder maps categories to integers 0 to n-1, which a linear model reads as a magnitude, so one city could dominate another purely because of the assigned code. OneHotEncoder or pd.get_dummies creates indicator columns that carry no false ordering. LabelEncoder remains appropriate for the target of a classification problem, where labels are categories with no distance.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Scikit-learn MCQs

Practise all Scikit-learn MCQs

Similar MCQs