K-means clustering: ValueError: could not convert string to float
K-means clustering is going to need numbers in order to compute the centers of the clusters in the space defined by the variables. You can just decide to define M as 0 and F as 1, or the opposite.
Here M being greater than F or the opposite doesn't really matter as long as it gives the opportunity for the algorithm to separate the different data points in space in order to cluster them.
However, if the clusters that are being looked for are not supposed to be subgroups of the different genders, there are going to be some problems with the fact of trying to use this feature and I would advise to only use continuous variables in that case.
I'm trying to do some clustering using the alghorithm k-means but I'm getting this error:ValueError: could not convert string to float: 'M'.
I think this happens because my variable is categorical one and clustering only allows continuous variables.
What should I do to the variable to make it continuous. Converting it using a dictionary is not a good idea because it makes no sense to say that M>F for example.