0Pricing
Learn AI with Python · Lesson

Correlation and Covariance

Pearson/Spearman correlation, covariance matrix, interpreting correlation in ML context.

Measuring Relationships

Covariance and correlation quantify how two variables move together. They are the basis for feature selection, portfolio theory, and exploratory analysis.

Covariance

Covariance is positive when variables rise together, negative when one rises as the other falls. Its magnitude depends on units, making raw covariance hard to interpret.

import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.array([2, 4, 5, 4, 6])
print(np.cov(x, y, ddof=1))   # 2x2 covariance matrix

All lessons in this course

  1. Descriptive Statistics and Distributions
  2. Probability and Bayes Theorem
  3. Hypothesis Testing
  4. Correlation and Covariance
← Back to Learn AI with Python