Label Encoding for Ordinal Variables
Data Preparation & Feature Engineering DS practice problem on Onlearn.
Difficulty: easy.
Topics: Understanding Ordinal Data Encoding, Mapping Dictionaries, List Comprehensions, Ordinal Rank Preservation, Categorical Feature Vectorization, Integer Encoding, Data Preprocessing, Feature Engineering, Supervised Learning, Categorical Data Analysis, Machine Learning Pipelines, Ordinal Encoding, Nominal vs Ordinal Variables, Data Transformation, Feature Representation, Encoding Schemes.
Given a list of categorical data that has a natural order (e.g., 'Low', 'Medium', 'High'), write a function that takes a list of these categories and a mapping dictionary, then returns a list of corresponding integer labels. Ensure the function handles the mapping efficiently.