How to make the most out of sklearn’s OrdinalEncoder() function
Ordinal encoding is a technique to transform categorical features into a numerical format. In ordinal encoding, labels are translated into numbers based on their ordinal relationship to one another. For example, the values of ‘high, medium, low’ will be transformed to the numeric values of perhaps ‘2, 1, 0’ when it is ordinally encoded.
Ordinal encoding is a technique that is used to transform categorical variables into a numerical format by assigning a unique value to each of its categories.
Ordinal encoding assume that categories in categorical variables have clear, natural and intrinsic ordering to their categories.
Ordinal encoding of object variables is an essential task that needs to be performed before training a machine learning model because many machine learning models do not support categorical data directly.
Python’s library that contains voluminous functions to provide machine learning functionality if scikit learn, or sklearn. The function in sklearn that performs ordinal encoding is the OrdinalEncoder() function, which encodes categorical features into an integer array.
It is important to tune the parameters of sklearn’s OrdinalEncoder() function, otherwise it will not work optimally.