Pearson Correlation
Explore how to calculate the Pearson correlation matrix using pandas and visualize it with Seaborn heatmaps. Understand how correlations reveal the strength and direction of linear relationships between features and the response, helping identify key predictive variables for logistic regression models.
We'll cover the following...
Calculating the Pearson correlation using pandas
Now we are ready to create our correlation plot. Underlying a correlation plot is a correlation matrix, which we must calculate first. Pandas makes this easy. We just need to select our columns of features and response values using the list we just created and call the corr() method on these columns. As we calculate this, note that the type of correlation available to us in pandas is linear correlation, also known as Pearson correlation. Pearson correlation is used to measure the strength and direction (that is, positive or negative) of the linear relationship between two variables:
After creating the correlation matrix, notice that the row and column ...