Cleaning a certain feature to predict salary using Machine Learning
There are two ways to handle this:

Aggregating values and feature engineering

Instead of simply inputting the individual city, you could try to aggregate this value into a new variable &quot;JobCitySize&quot; to cluster cities by inhabitant size or a variable &quot;Region&quot; to cluster by geographic region. This will increase cases and also help solve the question of how to deal with unseen data.

Defining NA or unseen values

With any model and categorical encoding you have to think ahead what you want to do with &quot;unseen data&quot; in your case cities that aren't present in your training data set. Do you want to set them as NA, give a standard value (&quot;Other&quot;), etc.? Whatever process you use for these values you could also use for any value in your data set that falls below a threshold of &quot;usefulness&quot;.