I have a column in my dataset which contains both number and strings as the value. I want to encode the string variable so to use it for predicting. What is the best way to do this?
Encoding is a way to transform categories to numerical variables, there are a lot of techniques.
The best technique depends on what is the information you want to encode and what is the model that you are going to use. Some models benefit more of one techniques than others.
You should ask yourself the following questions to try to find the best solution: - Why do you have numerical and categorical values in a column? - Does it make sense to have them? - Which model am I using? - What is the best way to feed them to this model?
From the bit that I get I would reccomend that either you do target encoding with everything or that you split that feature into two. And then you do target encoding in the categorical and even in the numerical. Just check which works better.