6. Analysis of Credit Card Defaulters
Activity 6.01: Evaluating the Correlation between Columns Using a Heatmap
- Plot the heatmap for all the columns in the DataFrame (other than the
ID
column) by usingsns.heatmap
and keep the figure size as30,10
for better visibility:sns.set(rc={'figure.figsize':(30,10)}) sns.set_context("talk", font_scale=0.7)
- Use
Spearman
as the method parameter to compute Spearman's rank correlation coefficient:sns.heatmap(df.iloc[:,1:].corr(method='spearman'), \ cmap='rainbow_r', annot=True)
The output of the heatmap is as follows:
- In order to get the exact correlation coefficients of each column with the
DEFAULT
column, apply the.corr()
function on each column with respect to theDEFAULT
column:df.drop("DEFAULT", axis=1)\ .apply(lambda x: x.corr(df.DEFAULT...