# Does it make sense to “reorder” a categorical feature to make it monotonic?

Sorry for the vagueness of the title; I'll explain what I mean. I'm doing the Kaggle Titanic beginner tutorial. The label you're interested in is the "survived" rate (0 or 1), which you want to predict in the test data.

One of the first things I did was plot the average survival rate for each of the features, for each one, taking the average survival rate for that value of the feature. For example, for the "Sex" feature, you can look at the average survival rate for males and females, which gives you good info you can use.

For features like "Fare" and "Age", which are more continuous, it wouldn't really make sense to take the average in the same way, because there aren't necessarily many people with the same exact age. So, I did "banding", where I do a histogram-like thing of saying that everyone from 0-10 is one band, 10-20 another band, etc, and those bands are now categorical features that can be averaged over well (this is a good move, right? at least initially?).

This is what I get:

That's the background. Now, here's my question. I want to start with a simple model like linear regression. For some features, like Sex, or Pclass, it's clear that a linear model could fit it very well. For some however, like AgeBand, there's not really a clear, monotonic trend for increasing AgeBand...but there definitely is a difference in the survival rate between different bands!

So what you could do is, sort those "non monotonic" features by the survival rate, so it is monotonic, and then use them for linear regression. Is that a good idea or no?

For example, here's the AgeBand feature sorted by the survival rate:

The fewer assumptions (particularities) go into the choice of features, the better. It would then make more sense to me to reorder such that you pick bands alternately from the two ends (starting from the middle): 3, 4, 2, 5, 1, 6, 0, 7 (or in reverse order, starting from the ends). Or, even better, pool the age bands into coarser groups: {1,2,3}, {4,5,6,7}, {0}. I think these are justified by your exploratory data analysis.
When I look at the range of values in the AgeBand plot ($0.33$ to $0.55$), this variable does not actually explain as much as Pclass, Sex, FareBand. In the end you might end up dropping it from your variables anyway, so once again, the more attention you pay to it, the more you're at risk of overfitting.