I want to implement PCA on a dataset(retail) but the data is categorical. One-hot encoding on some columns like Gender, Fabric, Brand makes sense but on other features like price range, size, I would like the encoded values to have some numeric significance, i.e. higher value actually means something. Any suggestions on implementing both these encodings together for PCA?
1 Answer
There is a method that can handle multiple types of data simulataneously called Generalized Low Rank Models - actually one paper that deals with it is called PCA on a Data Frame. GLRMs in Python (and not only Python) are implemented in H2O.
Other than that you could try encoding your categorical data as numeric. There are multiple approaches to this. One example is mean encoding - see this answer for details. For implementation see Category Encoders. BTW if your task is totally unsupervised (you don't have any target) you can choose any continuous feature you have for mean encoding (so you can produce many columns from each categorical column).