## Is there an encoder which can automatically detect the intrinsic order of an ordinal variable and assign values accordingly?

3

1

Given data with an ordinal variable, says "house quality" with values ex (excellent), gd (good), fa (fair) and bd (bad), we obviously cannot just throw data into sklearn's LabelEncoder as the resulting labels can be in wrong order, e.g. {bd: 3, gd: 2, fa: 1, ex:0}. Instead, we need to manually specify an order, right? However, if we do not have domain knowledge, how can we specify the order? Also a manual way is usually prone to error. Thus, I am curious if there is any encoder which can auto detect the correct order in an ordinal variable?

1For me it would beg the question, how without domain knowledge one would even know whether a categorical variable is ordinal or nominal. – Fnguyen – 2020-07-16T07:46:45.447

Point taken @Fnguyen . Let me re-frame my question, i) we know the variable is ordinal e.g. based on its name, ii) we may have partial or full domain knowledge, but we want to avoid the manual process of providing the order, especially when we have lots of categories, says 10-100. – Victor Luu – 2020-07-16T18:09:57.460