Correlation

Correlation measures the strength and direction of the relationship between two numeric variables - whether they tend to increase together, move in opposite directions, or show no clear relationship at all.

The Correlation Coefficient

Correlation is typically expressed as a number between -1 and +1:

  • +1 - a perfect positive relationship (as one variable increases, so does the other)
  • -1 - a perfect negative relationship (as one variable increases, the other decreases)
  • 0 - no linear relationship between the two variables

Calculating Correlation in Pandas

import pandas as pd

df = pd.DataFrame({
    "StudyHours": [1, 2, 3, 4, 5],
    "Score": [50, 55, 65, 70, 85]
})

print(df["StudyHours"].corr(df["Score"]))   # close to +1

print(df.corr())   # full correlation matrix for all numeric columns

Correlation is Not Causation

A strong correlation between two variables doesn't necessarily mean one causes the other - both could be influenced by a third, unseen factor. For example, ice cream sales and drowning incidents are correlated, but the real cause behind both is simply hot weather.

Before acting on any correlation you find, always ask whether there's a plausible causal explanation, or whether a hidden third variable might be driving both trends independently.

You've Completed This Section

You've now covered the core foundations of Analytics and Exploratory Data Analysis - from the stages of analytics and the CRISP-DM life cycle, through data types, EDA, the four business moment decisions, and correlation. These concepts form the statistical backbone for everything that follows in Data Science.

Ready to Master Data Science?

Join Uncodemy's Data Science Course and build real, job-ready skills with expert mentors.

Explore Course