Correlation Analysis in Data Mining

Ma Mahalakshmi V Updated 14 Nov 2026
6 min read ·Lesson 71 of 140

Two variables can move together in a way that's obvious once pointed out but easy to miss otherwise: advertising spend and sales, temperature and ice cream sales, years of experience and salary. Correlation analysis is the technique for measuring exactly how strongly two variables move together, expressed as a single number — the correlation coefficient — that ranges from -1 to +1. A value near +1 means the variables tend to rise and fall together (positive correlation); a value near -1 means one tends to rise as the other falls (negative correlation); a value near 0 means no consistent linear relationship exists between them at all.

The Four Correlation Methods, and Why More Than One Exists

It might seem like one formula should be enough to measure "how related are two variables," but different kinds of data and different kinds of relationships call for genuinely different measures — using the wrong one can produce a misleading answer even when the calculation itself is done correctly.

Pearson correlation (r) is the standard, most commonly used method. It measures the strength of a linear relationship and works best with numerical data that doesn't contain extreme outliers, since it operates directly on the raw values.

Spearman rank correlation converts both variables to ranks before measuring their relationship, rather than using the raw values directly. Because it works on ranks, it doesn't require the data to follow any particular distribution and it captures any consistently increasing or decreasing relationship, not just a straight-line one.

Kendall's rank correlation (tau) also works on ranks, measuring how often the two variables agree in their relative ordering across all pairs of observations. It tends to be preferred for smaller datasets and is generally more robust to certain kinds of ties in the data than Spearman.

Point-biserial correlation handles a specific, common situation the other three don't: one variable is continuous (like an exam score) and the other is binary (like whether a student attended tutoring, coded 0 or 1).

Where the Choice Actually Matters: Pearson vs. Spearman Under an Outlier

The difference between Pearson and Spearman is not just theoretical — it's worth seeing exactly how differently the two behave on identical data once an outlier enters the picture. Starting with a clean, strongly linear dataset:

import numpy as np
from scipy import stats

x = np.arange(1, 21)
y = 2*x + np.random.normal(0, 2, 20)
r_pearson, _ = stats.pearsonr(x, y)
r_spearman, _ = stats.spearmanr(x, y)

Output:

Pearson r = 0.994   Spearman rho = 0.998

Both methods agree closely on clean data — no surprise there. Now inject a single extreme outlier into the last data point, changing nothing else:

y[-1] = 500  # one wild outlier
r_pearson2, _ = stats.pearsonr(x, y)
r_spearman2, _ = stats.spearmanr(x, y)

Output:

Pearson r = 0.476   Spearman rho = 0.998

One bad value cut Pearson's correlation roughly in half — from 0.994 down to 0.476 — because Pearson operates on the raw values, and a single extreme number pulls the calculation dramatically off course, exactly the way a mean is distorted by an outlier. Spearman's rank-based correlation barely moved at all (0.998, virtually unchanged), because converting to ranks means one absurdly large value just becomes "the largest rank" — its exact magnitude no longer matters. This is precisely why the choice between Pearson and a rank-based method is a real, consequential decision and not just a stylistic preference: data with outliers or an unknown, non-normal distribution calls for Spearman or Kendall specifically because they don't inherit this sensitivity.

A Worked Point-Biserial Example

Point-biserial correlation is worth grounding in a real comparison: exam scores for 30 students who attended tutoring versus 30 who did not.

r_pb, p_value = stats.pointbiserialr(attended, scores)

Output:

r_pb = 0.444   p-value = 0.0004
mean score, no tutoring: 69.0   mean score, tutoring: 77.3

A point-biserial correlation of 0.444, with a very small p-value, quantifies what the raw group averages already suggest — tutoring attendance and exam score are meaningfully associated in this data. This is exactly the same underlying idea as Pearson correlation, applied to the specific case where one of the two variables only ever takes two values.

Choosing a Method: Parametric vs. Non-Parametric

Pearson correlation is a parametric method — it assumes the data is numerical and reasonably close to normally distributed, and it gives the most precise answer when those conditions genuinely hold. Spearman and Kendall are non-parametric methods — they make no assumption about the data's distribution, handle ordinal (ranked) data naturally, and are noticeably more robust to outliers, as demonstrated above, at some cost in statistical precision when the data actually is well-behaved and Pearson's assumptions would have held.

Interpreting the Coefficient

As a rough guide, a coefficient between +0.5 and +1 indicates a strong positive correlation, between -0.5 and -1 a strong negative correlation, and values clustered around 0 indicate a weak or absent linear relationship. A scatter plot is the standard way to visualize this directly: an upward-sloping cloud of points suggests positive correlation, a downward slope suggests negative correlation, and a shapeless scatter suggests none — and plotting the data is also how an analyst would actually notice the kind of single-point outlier that distorted the Pearson calculation above, before it quietly skews a reported result.

Why This Matters Beyond a Single Number

Correlation analysis pays off directly in several practical ways: it speeds up problem detection by surfacing which variables move together before a person has to inspect each one individually; it reduces alert overload in monitoring systems by grouping genuinely related signals (several alerts that all spike together are more likely one underlying issue than several independent ones); and it saves analytical effort by directing attention toward variable pairs that are actually related rather than treating every possible pair as equally worth investigating. This shows up directly in marketing (relating campaign spend to customer response), finance (relating asset price movements to assess risk), and IT operations (grouping correlated system alerts instead of treating each one as a separate incident).

Correlation Is Not Causation

The single most important caution in correlation analysis is that a strong correlation between two variables never, by itself, establishes that one causes the other. A classic illustration makes the mechanism concrete rather than just asserting the warning: simulating 100 days where temperature independently drives both ice cream sales and (separately) drowning incidents produces this result:

r_ic_temp, _ = stats.pearsonr(ice_cream_sales, temperature)
r_drown_temp, _ = stats.pearsonr(drowning_incidents, temperature)
r_ic_drown, _ = stats.pearsonr(ice_cream_sales, drownings)

Output:

corr(ice cream sales, temperature) = 0.944
corr(drownings, temperature) = 0.962
corr(ice cream sales, drownings) = 0.908

Ice cream sales and drowning incidents end up strongly correlated with each other (0.908) purely because both are driven by the same third variable — temperature — even though this simulation was built with absolutely no direct connection between ice cream and drowning at all. This is what's called a confounding variable: a hidden third factor that creates the appearance of a direct relationship between two things that don't actually influence each other. Any correlation found through data mining should prompt the same next question: is this a direct relationship, a confounded one like this example, or simply coincidence in a particular dataset — a distinction correlation analysis on its own can never answer, no matter how strong the coefficient looks.

0 Comments

Reviewed before they appear

No comments yet.

Data Mining
Introduction to Data Mining Data Mining Techniques Data Mining Implementation Process Data Mining Architecture KDD: Knowledge Discovery in Databases History of Data Mining Data Mining Tools Data Mining vs. Machine Learning Facebook Data Mining Social Media Data Mining Methods Clustering in Data Mining Text Data Mining Bagging vs Boosting Data Mining vs Data Warehousing Social Media Data Mining Data Mining: Bayesian Classifiers Data Mining: World Wide Web Different Types of Clustering Bitcoin Mining and Blockchain Data Mining Orange Data Mining Data Mining vs Big Data Decision Tree Induction Educational Data Mining Data Mining in Healthcare Apriori Algorithm Data Integration in Data Mining Difference Between Data Mining and Text Mining Discretization in Data Mining Redundancy and Correlation in Data Mining Classification of Data Mining Systems Data Mining Models Difference Between Data Mining and Data Science Difference Between Data Mining and Statistics Difference Between Data Mining and Web Mining Difference Between Data Mining and Data Analysis Difference Between Business Intelligence and Data Mining Difference Between Data Mining and Data Visualization Data Mining vs Data Analytics Types of Data Mining Difference Between Data Profiling and Data Mining Predictive Analytics vs Data Mining Difference Between Data Mining and OLAP Descriptive and Predictive Data Mining Difference Between Spatial and Temporal Data Mining Difference Between Classification and Clustering in Data Min Hierarchical Clustering in Data Mining Density-Based Clustering in Data Mining What Is Aggregation in Data Mining? Regression in Data Mining What Is an Outlier in Data Mining? Data Cleaning in Data Mining Data Processing in Data Mining Classification and Prediction in Data Mining Data Mining Task Primitives Web Content Mining, Web Structure Mining, and Web Usage Mini Binning in Data Mining KDD vs. Data Mining Noise in Data Mining BIRCH in Data Mining Stemming in Data Mining Feature Transformation in Data Mining Visual and Audio Data Mining Class Comparison Methods in Data Mining Data Selection in Data Mining Tasks and Functionalities of Data Mining Ubiquitous and Invisible Data Mining Entity Identification Problem in Data Mining Numerosity Reduction in Data Mining Market Basket Analysis in Data Mining Multimedia Data Mining Correlation Analysis in Data Mining Data Mining Services Trends in Data Mining Data Harvesting vs Data Mining Data Mining vs Artificial Intelligence Data Mining vs Data Exploration Data Mining vs Process Mining Web Scraping vs Data Mining Data Wrangling Boosting in Data Mining What Is Forecasting in Data Mining? What Is CRISP in Data Mining? FP-Growth Algorithm in Data Mining Weka Data Mining Association Rule Mining in Data Mining Characteristics of Data Mining Classification by Backpropagation in Data Mining Data Mining Applications Challenges of Data Mining What "Data Mining" Actually Means Data Mining Operators Data Mining Query Language (DMQL) Data Preprocessing Techniques in Data Mining Data Stream Mining Grid-Based Methods in Data Mining Categories of Functions in Data Mining Interestingness of Patterns in Data Mining Strategic Value of Data Mining Data Mining for Business Intelligence Data Mining Projects Evaluation of Clustering in Data Mining Major Issues in Data Mining Partition Algorithm in Data Mining Partitioning Methods in Data Mining Rule-Based Classification in Data Mining Types of Attributes in Data Mining Use of Data Mining What is Association in Data Mining? What is the Goal of Data Mining? Data Mining Algorithms Data Mining: Concepts and Techniques Data Mining Examples The Data Mining Process: From Raw Data to Deployed Model Normalization in Data Mining Preprocessing in Data Mining: Data Quality and Feature Selec Association Analysis in Data Mining Attribute Selection Measures in Data Mining Support and Confidence in Data Mining Tree Pruning in Data Mining Classification Algorithms in Data Mining Data Generalization in Data Mining Importance of Data Mining Data Quality in Data Mining Mining Frequent Patterns in Data Mining Data Warehouse and OLAP Technology for Data Mining Need for Data Mining Pattern Evaluation Methods in Data Mining Logarithms and Exponents in Complexity Analysis Time Series Clustering What is the C4.5 Algorithm and How Does It Work? Expanding Contractions in Text Mining Cosine Similarity in Data Mining Lazy Learning in Data Mining Neural Networks in Data Mining Building a Text Normalizer Shallow Parsing Data Pipeline Orchestration Big Data vs Small Data Myths of Data Mining Data Reduction in Data Mining
Ask about this post
AI Ask about this post

Ask questions about Correlation Analysis in Data Mining and get answers drawn from it.

Signed-in readers only.