Transforming categorical variables Can someone explain in which cases it is a good idea to convert a categorical variable to numerical in order to use it in our model (either regression or classification)? I have seen cases where even the male/female gender category has been converted to 0/1 ... Also, what's the measure to confirm that this transformation must be included to our model i.e., is a good feature.
 A: Consider a linear regression model with response $Y_i$. Further, say that we only have one predictor here, being either male or female, as you mentioned. Then this simple model is clearly
$$
Y_i = \beta_0 + \beta_1I_{MALE} + \epsilon_i
$$
It is necessary to encode this categorical variable as being either 0 or 1 in order to obtain the least squares estimates of our coefficients $\hat{\beta_i}$. In this way, if a particular observation is a female then the indicator is 0 and the response is simply $\hat{Y}_i=\hat\beta_0$. In short, it's necessary in order for the math to make sense.
Also, to confirm that this variable is significant to our model, we can perform a Wald test of significance for the coefficient in question (in the example $\hat \beta_1$).
A: The question has two possible interpretations depending on what exactly is meant by "convert to numerical".
When we have a categorical variable we have to parameterize it somehow. For a dichotomous variable this is easy: Call one option 1 and the other 0. So, if you have two choices for "sex" (but be careful, you may want more) then you could change the variable from "sex" to "male" and then code Yes as 1 and No as 0.
If the variable has more choices then you can use dummy coding, effect coding, Helmert coding, etc. All those involve using 0's and 1's. 
But, while 0 and 1 are clearly numbers, I'm not sure I'd say that is "converting to numerical" and I worry that the OP or other readers (especially people new to statistics) may get the wrong notion.
If, say, we have a variable:  "What was your major in college?" then one of the above methods could be used. But it would not be right to (say) make math = 1, history = 2, English = 3 and so on. And that sort of thing is what comes to my mind on reading the question.
