2
$\begingroup$

I have a dataset in which it contains both numerical and categorical data. This can be done using supervised learning algorithms, but I am eager to see how this data can be clustered using some unsupervised learning algorithm (K-Means clustering algorithm is currently used).

enter image description here

For example, the Gender, None, Low, Medium, High, Breakfast, Lunch, and Dinner columns are represented in binaries. eg: Gender represents 1 for male and 0 for female. While the rest of the above-mentioned columns represents 0 for unavailability and 1 for availability. The Meal and the Exercise columns are also categorical but are not binary. For example, in the Meal, if it is breakfast then 1, lunch = 2, and dinner = 3. So how can we use this type of mixed dataset for clustering? Please ignore the Event column since it is the target column.

Further, should we need to normalize the rest of the numerical data before adding to any sort of unsupervised learning algorithm? And how can we deal with those different types of categorical data? Your guidance is greatly appreciated.

Thanks.

$\endgroup$

2 Answers 2

1
$\begingroup$

If you one hot encode when you are doing unsupervised learning, because this feature will have many more dimesions it would have much more weight in the final model than if it was read as categorical.

You can implement Kmodes. In this question which is one of the most famous of the forum you can check an answer to your problem.

And about if it is needed to scale data before clustering you can have a look at this question from stats exchange.

$\endgroup$
0
$\begingroup$

You can use one-hot-encoding for all categorical features. Then normalizing numerical features (as one-hot is 0 and 1 then maybe normalizing your numerical data to [0,1] will bean intuitive starting poit). Then apply a dimensionality reduction technique as probably you will produce a sparse matrix with maybe considerable number of dimensions. Then do your clustering (try at least two different one. I would say k-means and DBSCAN).

A nice intuitive replacement to one-hot-encoding is to replace values with their fraction. For example in column gender you have 60 male and 40 female, then replace male with 0.6 and female with 0.4. The only drawback is when the number of categories are equal in a column! You need to be careful about those.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.