1
$\begingroup$

I am working with kaggle dataset that has over 130 features composed of 116 categorical and 14 continuous features. I plotted the heatmap for the 14 continuous variables and found that most of them are weakly correlated with the response variable but highly correlated with each other. I am trying to apply PCA to this part of the data and glue them back together as columns with the categorical variables. Is it ok to do so? Or should I one-hot-encoding / label encoding the categorical variables and do pca to the entire dataset?

$\endgroup$
2
$\begingroup$

I plotted the heatmap for the 14 continuous variables and found that most of them are weakly correlated with the response variable but highly correlated with each other

You absolutely can select specific columns [continous data] from your original data and apply PCA on them, PCA1, PCA2 eigenvectors will show you the amount of correlation between each feature. However, you should use all of the data points or rows when applying PCA as PCA calculates the maximal variance between data points and its best to use all of them for accurate results.

So in short, you should select column[feature] wise but not row[data points] wise.

Is it ok to do so? Or should I one-hot-encoding / label encoding the categorical variables and do PCA to the entire dataset?

No need to do this, and it doesn't make sense in case of PCA as it only works on continuous data points.

| improve this answer | |
$\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.