I would definitely checkout this question first: K-Means clustering for mixed numeric and categorical data
In case it doesn't help, here is my explanation:
In the case where you have mixed data types (i.e. numerical and categorical), you have several options:
- turn numerical data into categorical data
You can do that by using binning. If you want to use K-Means for categorical data, you can use hamming distance instead of Euclidean distance.
- turn categorical data into numerical
Categorical data can be ordered or not. Let's say that you have 'one', 'two', and 'three' as categorical data. Of course, you could transpose them as 1, 2, and 3.
But in most cases, categorical data cannot be ordered nicely. So you can transform into numerical data by using one-hot encoding
- Combine both using K-prototypes
K-prototypes computes the distance between instances by combining the Euclidean distance between the numerical features and the hamming distance between the categorical features.