1
$\begingroup$

I have a dataset containing a categorical variable and multiple continuous variables. The categorical variables are coded as discrete integers, whereas the continuous variables are just a range of floats. I believe that the variance in my dataset can be almost entirely described by the single categorical variable and one of the many continuous variables. To justify this, I would be interested in using PCA, but I'm not sure the best approach to use when I am considering categorical data. Any suggestions?

$\endgroup$
  • $\begingroup$ PCA requires you to be able to define meaningful distances between categories. $\endgroup$ – oW_ Dec 21 '18 at 18:42
1
$\begingroup$

I'm not aware of any the dimensionality reduction algorithms (like PCA) that can work with categorical values.

However, an approach that could help you with that is to make a one-hot encoding of your categorical variables (if the number of possible values is manageable. Otherwise, try to pick only the most frequent values and assign the rest to a single variable).

If you are using Pandas DataFrames, get_dummies can be helpful.

$\endgroup$
0
$\begingroup$

How many values can the categorical value take?

Maybe make a column for each possible value and have 1 if the column name matches the categorical value, 0 otherwise.

I think that will show up in PCA.

$\endgroup$
0
$\begingroup$

There are several discussions on this in the stats SE. As a starting point: https://stats.stackexchange.com/q/5774/232706

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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