Pearson Correlation

Learn to calculate and plot the Pearson correlation.

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:

Get hands-on with 1200+ tech skills courses.