I am working on a dataset in which a variable has following levels
Levels: 0 1 2 3 4 5 8
Frequency: 608 209 28 16 18 5 7
The target variable is binary. To combine levels in a factor variable while the target variable is continuous, I learned that levels which have an approximately equal mean of the target variable should be combined. This can be found by plotting the boxplot (factor variable vs target variable).
But on what basis can one combine levels of the factor variable when the target variable is binary (i.e., in a classification problem)?