I want to use sklearn OrdinalEncoder in a pipeline while making sure the right ordering of categories is made. How can I do that?
I have for example the features "Education_Level" and "Income_Category" I want to encode as follows:
"Education_Level": {
"Uneducated": 1,
"High School": 2,
"College": 3,
"Graduate": 4,
"Post-Graduate": 5,
"Doctorate": 6
},
"Income_Category": {
"Less than $40K": 1,
"$40K - $60K": 2,
"$60K - $80K": 3,
"$80K - $120K": 4,
"$120K +": 5
}
Can someone help me on how to do that? I remind that I want to use OrdinalEncoder in a pipeline to perform the task. I can do it 'manually' with replace(), but since I am creating a pipeline, I need the encoder object (at least I guess).