Learn/Data Science/Chapter 18

Chapter 18 of 30

Keep learning and build your Data Science skills.

60%
Chapter 18

Correlation

Learn how correlation measures the relationship between numerical variables.

Theory

Correlation measures the strength and direction of association between variables. The Pearson correlation coefficient ranges from -1 to +1. A positive value indicates a positive linear association. A negative value indicates a negative linear association. A value close to zero indicates little or no linear association. Correlation does not by itself establish causation.

Example

import pandas as pd

df = pd.DataFrame({
    "Hours": [1, 2, 3, 4, 5],
    "Score": [20, 35, 50, 65, 80]
})

print(df.corr())

Output

The correlation between the numerical variables is calculated.

Practice

Calculate correlations between numerical columns in a dataset.

Interview Questions

1

What is correlation?

2

What is the range of Pearson correlation?

3

Does correlation imply causation?

Quick Quiz

Which option best describes this chapter?

A.Strength and direction of association
B.Database size
C.Web page structure
D.CPU speed