# Using Correlation to calculate features strength in multi class classification

I have 4 categorical features to describe text documents [x1, x2, x3, x4]. And I need to classify each document into one of given classes y.

Given a certain skewed dataset, I have a feeling that feature x1 is highly correlating with y (i.e. depending solely on x1 for classification will yield very high false accuracy). and the rest of the feature are useless.

What would be a useful normalized metric to prove that two categorical variables are highly correlating, so i can end up with a table like that. and plot the same for other datasets to prove that this is not a common distribution of correlation.

+----+-------+------+------+------+
|    |   X1  |  X2  |  X3  |  X4  |
+----+-------+------+------+------+
| Y  |  0.99 |  0.1 | 0.05 |  0.1 |
+----+-------+------+------+------+


## 1 Answer

Note: The answer I am providing below is applicable in python only.

• Pandas, a powerful data analysis library in python, provides two ways to check the correlation between various features present in your data. The first method is to use the the pandas.DataFrame.corr method in order to get a correlation matrix. The values in the matrix gives you the estimate how strongly(positively/negatively) are the features related to each other. Suppose your dataframe is represented by data containing n number of columns represting the features in the dataset. Then you can find the correlation between different features just by calling the pandas method as: data.corr(). This will output a n X n matrix of correlation values. You can read it about more here.

• The second method is to plot a scatter matrix using the pandas scatter_matrix() method. This method gives you a nice view of the correlation between different features such as shown below:

You can read about this more here

• You can also make use of seaborn heatmap (seaborn is another high level visualization library in python). A heatmap can be used to represent the correlation between different features. This will give you a nice plot as shown below:

You can read about it more in detail here.