Skill-Lite

Practical tutorials & tools for modern developers.

Home/Math for ML/Introduction

Introduction to Math for ML

Every machine learning model is built on three branches of math: linear algebra to represent and transform data, probability & statistics to reason about uncertainty and evaluate models, and calculus to optimize model parameters. You don't need a math degree — you need working intuition for how these show up in code you already write.

Why this matters

Where you see itMath underneath
A batch of training data, shape (N, features)Linear algebra — matrices
A dense/linear layer: output = W @ x + bLinear algebra — matrix multiplication
model.fit() minimizing a loss functionCalculus — gradients & optimization
Backpropagation computing dL/dWCalculus — chain rule
A softmax output, a confidence scoreProbability — distributions
Train/test split, cross-validation, p-valuesStatistics — sampling & inference
Naive Bayes, Gaussian Mixture ModelsProbability — Bayes' theorem

The three pillars

Linear Algebra

  • Vectors & matrices
  • Dot products, transforms
  • Represents data & weights

Probability & Statistics

  • Distributions
  • Bayes' theorem
  • Reasons under uncertainty

Calculus

  • Derivatives & gradients
  • Chain rule
  • Optimizes model parameters

How a model actually uses all three

import numpy as np

# LINEAR ALGEBRA — data and weights are matrices/vectors
X = np.array([[1.0, 2.0], [3.0, 4.0]])   # 2 samples, 2 features
w = np.array([0.5, -0.2])                 # weight vector
b = 0.1

# Forward pass: a linear transform (linear algebra)
z = X @ w + b                              # matrix-vector product

# PROBABILITY — squash to a probability with sigmoid
p = 1 / (1 + np.exp(-z))                    # P(y=1 | x)

# CALCULUS — the loss and its gradient drive learning
y_true = np.array([1, 0])
loss = -np.mean(y_true * np.log(p) + (1 - y_true) * np.log(1 - p))   # binary cross-entropy

# dL/dw computed via the chain rule (what autograd/backprop does for you)
grad_w = X.T @ (p - y_true) / len(y_true)
w -= 0.1 * grad_w                             # gradient descent step

Every line in that snippet maps directly onto one of the three pillars — that mapping is what the next three pages build intuition for.

How to use this section: Each page pairs a compact explanation with runnable NumPy code, because the fastest way to build intuition for these ideas is to see them computed, not just stated as formulas.
Next up: Linear Algebra — vectors, matrices, and the operations (dot products, matrix multiplication, transforms) that represent data and model weights.