Correlation Calculator
Calculate the Pearson correlation coefficient between two features in a dataset.
Inputs
Pearson Correlation (r)
0.975953
R² (Coefficient of Determination)
0.952484
Direction
Positive
Relationship Strength
Very strong
Step by step
cov(X,Y)
= 21.0000
std(X), std(Y)
= 3.1623, 6.8044
r = cov(X,Y) ÷ (std_x × std_y)
21.0000 ÷ (3.1623 × 6.8044)
= 0.975953
How it works
The Pearson correlation coefficient measures the strength and direction of a linear relationship between two variables: r = cov(X,Y) / (std_x × std_y), always in the range [-1, 1]. r = 1 means a perfect positive linear relationship, r = -1 means a perfect negative linear relationship, and r = 0 means no linear relationship. In ML, correlation is widely used for feature selection (dropping one of a pair of highly correlated features to reduce redundancy/multicollinearity) and for exploratory data analysis.
Formula
r = cov(X, Y) / (std_x × std_y)
- cov(X, Y)
- Sample covariance of X and Y
- std_x
- Standard deviation of X
- std_y
- Standard deviation of Y
Frequently Asked Questions
What does R² tell me beyond r?
R² (r squared) represents the proportion of variance in one variable that is explained by a linear relationship with the other — e.g. r = 0.8 gives R² = 0.64, meaning 64% of the variance is 'explained' by the linear relationship.
Why might two features have high correlation but low usefulness for ML?
Pearson correlation only captures linear relationships — two variables can have a strong nonlinear relationship (e.g. quadratic) and still show low or zero Pearson correlation, so it should be complemented with visualization or nonlinear correlation measures like Spearman's rank correlation.
How is correlation used for feature selection?
Highly correlated feature pairs (e.g. |r| > 0.9) often carry redundant information; removing one of the pair can reduce multicollinearity in linear models and slightly simplify the model without losing much predictive power.
Does correlation imply causation?
No — a strong correlation between two variables does not establish that one causes the other; both could be driven by a third confounding variable, or the relationship could be coincidental in a small sample.