1 of 25

Math for Machine Learning

Discussion Mini Lecture 1

Review of Pre-Req Material and Connection to ML

CS 189/289A, Fall 2025 @ UC Berkeley

Sara Pohland

2 of 25

Notes about Discussion Mini Lectures

  • Discussions are offset from lectures
    • E.g., Discussion 1 takes place in Week 2 and covers concepts presented in Lecture 1 during Week 1
  • You can utilize course resources in whatever way works best for you, but we recommend that you:
    1. Attend/watch lectures
    2. Watch the corresponding discussion mini lecture
    3. Attend a discussion section
    4. Review uncovered discussion problems on your own*
    5. Optionally, look at additional resources at end of slides

* We will likely not cover all of the discussion material during the 50 min discussion session! Additional problems are provided for you as a way to review concepts and get extra practice.

3 of 25

  1. ML as Function Approximation
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory

Concepts Covered

4 of 25

ML as Function Approximation

  1. ML as Function Approximation
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory

5 of 25

Supervised Learning

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

spam

$1,200,000

ML Model

ML Model

ML Model

# Bed

# Bath

Location

4

3

Berkeley

dog

6 of 25

ML as Function Approximation

 

 

 

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

spam

$1,200,000

dog

7 of 25

How do we Represent our Data?

 

flatten

 

vector of pixels

Practice with data manipulation: Discussion 1 notebook

 

vector of words

 

vector of features

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

8 of 25

ML as Function Approximation

 

vector of pixels

 

 

 

 

 

 

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

9 of 25

Linear Algebra Review

  1. ML as Function Approximation
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory

10 of 25

ML as Function Approximation

 

vector of pixels

 

 

 

 

 

 

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

11 of 25

Linear Function Approximation

 

 

 

 

vector of pixels

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

 

 

 

12 of 25

Properties of Functions

injective – every input in our domain maps to one* output in our range

* If an input maps to more than one output, we do not have a valid function.

surjective – every output in our range maps to at least one input in domain

bijective – there exists exactly one output in range for every input in domain

domain

range

domain

range

domain

range

Every image has a label within our set of labels.

Every label is associated with at least one image.

We have a perfect set of image-label pairs.

13 of 25

Properties of Linear Functions

 

 

 

 

 

 

 

 

 

 

 

vector of pixels

 

 

14 of 25

Determining Matrix Rank

 

Option 1: Python

Option 2: Inspection

How many linearly independent rows/columns?

There are two; notice that:

row3 = 2 * row1

col3 = 2 * col2 – col1

Option 3: Singular Values

How many non-zero singular values?

Practice calculating singular values: Discussion 1 problem 2b

15 of 25

Multivariate Calculus Review

  1. ML as Function Approximation
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory

16 of 25

ML as Function Approximation

 

vector of pixels

 

 

 

 

 

 

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

17 of 25

Sensitivity of Function

How sensitive is my output to my input variables?

How will my output change if I change my input by a small amount?

 

 

 

 

partial derivative!

Practice calculating partial derivatives: Discussion 1 problem 1

18 of 25

Learning New Features

 

 

 

 

 

 

Image Features

Text Features

Tabular Features

spam

$1,200,000

dog

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

19 of 25

Chain Rule

How sensitive is my output to my input variables?

How will my output change if I change my input by a small amount?

 

 

 

 

Practice with chain rule: Discussion 1 problem 1a

 

20 of 25

Probability Theory Review

  1. ML as Function Approximation
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory

21 of 25

ML as Function Approximation

 

vector of pixels

 

 

 

 

 

 

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

22 of 25

Probabilistic Interpretation of ML

 

 

 

 

vector of pixels

HI, It’s your boss. Im stuck in Nigeria with none money. Please wire to TRWIGB2LXXX SOON.

# Bed

# Bath

Location

4

3

Berkeley

 

vector of words

 

vector of features

23 of 25

Bayes’ Theorem

Practice with Bayes’ Theorem: Discussion 1 problem 3b

 

Law of total probability:

 

 

 

 

 

24 of 25

Math for Machine Learning

Discussion Mini Lecture 1

Contributors: Sara Pohland

25 of 25

Additional Resources

  1. ML as Function Approximation
    • Lecture 1 and 3
  2. Linear Algebra
  3. Multivariate Calculus
  4. Probability Theory