I have a data set with ~ 85 labels and a target (house price)

I wish to explore the correlation between the labels and the effect it has on the target.

I have some features that number and others that are letters that go along with no particular order and therefore I can not encode them into numbers.

such as : Feature: Heating. With unique entries such as "Floor", "GasA","Grav","Wall". another example Garage type. Unique entires such as "2Types", "Attched", "BuiltIn", "Detached".

How should I go about exploring the effect of these on the sales price of the property?


1 Answer 1


Remember that we can square correlation, and the squared Pearson correlation between two variables is equal to the $R^2$ of the ordinary least squares simple linear regression of either variable on the other.

With this in mind, I think you can one-hot encode your categorical feature and run a OLS linear regression on the bundle of one-hot encoded variables. Then you consider the $R^2$ from that regression. Since you want to look at the correlation, take the square root. The sign no longer makes sense, so you can feel free to take either the positive or negative square root.

Keep in mind that screening candidate features for correlation with the outcome is problematic, even if common, as it can distort your downstream inferences, cause you to miss important effects of variables that have an effect when other variables are present in the model, and inflate your sense of predictive ability (even if you use adjusted $R^2$ or standard evaluation on a holdout set). Both of these are discussed on the statistics Stack, Cross Validated.


Your Answer

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

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