I have a really large data set with mixed variables. I have converted categorical variables to numerical using OneHotEncoding and it has resulted in more than a couple of thousand different features, combined that is.

Is it possible to apply dimensionality reduction algorithms on OneHotEncoded data which looks like [[1. 0. 1. 0.]...[0. 0. 0. 0.]] or should it be done by merging with the original data set?

  • 1
    $\begingroup$ By the way: Have you performed your one-hot encoding with pd.get_dummies from the pandas package with drop_first=True? That saves you one column per categorical feature without removing any information. $\endgroup$ Commented Feb 19, 2018 at 14:58
  • $\begingroup$ No @EliasStrehle I haven't. I must try that. Thanks for the tip. $\endgroup$
    – moirK
    Commented Feb 20, 2018 at 17:33

2 Answers 2


Following your example, you have different points in a 4-dimensional space. So, yes! you can use any dimensionality reduction technique, from PCA to UMAP.

In general, if your data is in a numeric format (and one-hot actually is), all the elements have the same dimensionality, and you don't have undefined values (NAN, inf), you can always use dimensionality reduction.


It is definitely not a good idea to do PCA to one hot encoded variables, at the end PCA algorithm calculates eigenvalues for you dataTdata matrix so if you do it for one hot encoded variables you will lose the information from less important variables instead of being aggregating it on one of your principal components


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.