LabelEncoding
LabelEncoding is a data preprocessing technique that assigns each distinct category in a categorical variable a unique integer. It is commonly used to convert the target variable in supervised learning tasks, and, less commonly, to transform categorical features when the machine learning model can interpret ordinal relationships.
How it works: Each category is mapped to a numeric label, typically starting at 0. For example,
Usage and limitations: Label encoding is most appropriate for the target variable in classification or regression
Implementation notes: In scikit-learn, LabelEncoder operates on 1D arrays and provides fit, transform, fit_transform, and inverse_transform.
Alternatives: One-Hot Encoding (OneHotEncoder) avoids implying ordinal relationships; other approaches include target encoding or binary encoding,