43
Linear Algebra Basics Machine Learning CS 4641 Nakul Gopalan Georgia Tech These slides are based on slides from Le Song and Andres Mendez-Vazquez, Chao Zhang, Mahdi Roozbahani, Rodrigo Valente

Lecture 02 Linear Algebra Basics - GitHub Pages

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lecture 02 Linear Algebra Basics - GitHub Pages

Linear Algebra Basics

Machine Learning CS 4641

Nakul Gopalan

Georgia Tech

These slides are based on slides from Le Song and Andres Mendez-Vazquez, Chao Zhang, Mahdi Roozbahani, Rodrigo Valente

Page 2: Lecture 02 Linear Algebra Basics - GitHub Pages

Some logistics

β€’ Creating team.

β€’ Office hours are started from next week.

β€’ First quiz out this Thursday.

β€’ First assignment out this Thursday (early release).

Page 3: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

β€’ Matrix Calculus

Page 4: Lecture 02 Linear Algebra Basics - GitHub Pages

Why Linear Algebra?

𝑛 Γ— 𝑑𝑛 𝑑

𝑑𝑑

𝑑

𝑑

1

Page 5: Lecture 02 Linear Algebra Basics - GitHub Pages

Example

Page 6: Lecture 02 Linear Algebra Basics - GitHub Pages

Linear Algebra Basics

𝑛 Γ— 𝑑 𝑑 Γ— 𝑛

𝑑 Γ— 𝑑

Page 7: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

Page 8: Lecture 02 Linear Algebra Basics - GitHub Pages

Norms

𝑑

𝑑

𝑑

𝑑

𝑑

Page 9: Lecture 02 Linear Algebra Basics - GitHub Pages

Norms

10

𝑑

𝑑𝑛

Page 10: Lecture 02 Linear Algebra Basics - GitHub Pages

Vector Norm Examples

Page 11: Lecture 02 Linear Algebra Basics - GitHub Pages

Special Matrices

𝑑 Γ— 𝑑

𝑑

𝑑 Γ— 𝑑

𝑑

Page 12: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

Page 13: Lecture 02 Linear Algebra Basics - GitHub Pages

Multiplications

𝑛 Γ— 𝑑 𝑑 Γ— 𝑝

𝑛 Γ— 𝑝 𝑑

𝑑

𝑑

𝑑 𝑛

π‘₯𝑦𝑇

π‘₯𝑇𝑦: π‘₯ βŠ— 𝑦

π‘₯𝑦𝑇

Page 14: Lecture 02 Linear Algebra Basics - GitHub Pages

Multiplications

Tπ‘₯ βŠ— 𝑦 =

Page 15: Lecture 02 Linear Algebra Basics - GitHub Pages

Inner Product Properties

Page 16: Lecture 02 Linear Algebra Basics - GitHub Pages

Inner Product Properties

Page 17: Lecture 02 Linear Algebra Basics - GitHub Pages

Inner Product Properties

Page 18: Lecture 02 Linear Algebra Basics - GitHub Pages

Example

Page 19: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix multiplication geometric meaning

Page 20: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Matrix Decomposition

Page 21: Lecture 02 Linear Algebra Basics - GitHub Pages

Linear Independence and Matrix Rank

𝑑𝑑

𝑑

𝑑

𝑛 Γ— 𝑑

Page 22: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix Rank: Examples

What are the ranks for the following matrices?

Page 23: Lecture 02 Linear Algebra Basics - GitHub Pages

Geometric meaning

Page 24: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix Inverse

𝑑 Γ— 𝑑

Page 25: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

Page 26: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix Trace

𝑑 Γ— 𝑑

𝑑 Γ— 𝑑

𝑑 Γ— 𝑑

𝑑 Γ— 𝑑

𝑑

Page 27: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix Determinant

𝑑

Page 28: Lecture 02 Linear Algebra Basics - GitHub Pages

Properties of Matrix Determinant

Page 29: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

Page 30: Lecture 02 Linear Algebra Basics - GitHub Pages

Eigenvalues and Eigenvectors

𝑑 Γ— 𝑑𝑑

Page 31: Lecture 02 Linear Algebra Basics - GitHub Pages

Computing Eigenvalues and Eigenvectors

𝑑.

𝑑 𝑑

(𝐴 βˆ’ πœ†πΌ)

(𝐴 βˆ’ πœ†πΌ) (𝐴 βˆ’ πœ†πΌ)

(𝐴 βˆ’ πœ†πΌ)

Page 32: Lecture 02 Linear Algebra Basics - GitHub Pages

Eigenvalue Example

Slide credit: Shubham Kumbhar

Page 33: Lecture 02 Linear Algebra Basics - GitHub Pages

Matrix Eigen Decomposition

columns

𝑑

𝑑

Page 34: Lecture 02 Linear Algebra Basics - GitHub Pages

Outline

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition

Page 35: Lecture 02 Linear Algebra Basics - GitHub Pages

Covariance matrix

Page 36: Lecture 02 Linear Algebra Basics - GitHub Pages

Covariance matrix

Page 37: Lecture 02 Linear Algebra Basics - GitHub Pages

Correlation matrix

Page 38: Lecture 02 Linear Algebra Basics - GitHub Pages

Correlation matrix

Page 39: Lecture 02 Linear Algebra Basics - GitHub Pages

Singular Value Decomposition

43

𝑋𝑛×𝑑n: instancesd: dimensionsX is a centered matrix

𝑋 = π‘ˆΞ£π‘‰π‘‡

π‘ˆπ‘›Γ—π‘› β†’ π‘’π‘›π‘–π‘‘π‘Žπ‘Ÿπ‘¦ π‘šπ‘Žπ‘‘π‘Ÿπ‘–π‘₯ β†’ π‘ˆ Γ— π‘ˆπ‘‡ = 𝐼

Σ𝑛×𝑑 β†’ π‘‘π‘–π‘Žπ‘”π‘œπ‘›π‘Žπ‘™ π‘šπ‘Žπ‘‘π‘Ÿπ‘–π‘₯

V𝑑×𝑑 β†’ π‘’π‘›π‘–π‘‘π‘Žπ‘Ÿπ‘¦ π‘šπ‘Žπ‘‘π‘Ÿπ‘–π‘₯ β†’ 𝑉 Γ— 𝑉𝑇 = 𝐼

=

ddd

d

dd

nn

n

vv

vv

uu

uu

X

.........

...

...

......

.........

000

000

00

00

00

.........

...

...

......

.........

1

11111

11

111

π‘ˆ Ξ£ 𝑉𝑇

𝑑 < 𝑛

Page 40: Lecture 02 Linear Algebra Basics - GitHub Pages

𝐢𝑑×𝑑 =𝑋𝑇𝑋

𝑛

𝑋 = π‘ˆΞ£π‘‰π‘‡

𝐢 =𝑋𝑇𝑋

𝑛

𝐢 =π‘‰Ξ£π‘‡π‘ˆπ‘‡π‘ˆΞ£π‘‰π‘‡

𝑛=𝑉Σ2𝑉𝑇

𝑛

Covariance matrix:

Page 41: Lecture 02 Linear Algebra Basics - GitHub Pages

𝐢 =𝑉Σ2𝑉𝑇

𝑛= 𝑉

Ξ£2

𝑛𝑉𝑇

So, we can directly calculate eigenvalue of a covariance matrix by having the singular value of matrix X directly

πœ†π‘– =Σ𝑖2

π‘›βž” The eigenvalues of covariance matrix

According to Eigen-decomposition definition βž”πΆπ‘‰ = VΞ›

𝐢𝑉 = 𝑉Σ2

𝑛𝑉𝑇𝑉 = 𝑉

Ξ£2

𝑛

πœ†π‘–: Eigenvalue of 𝐢 or covariance matrix

Σ𝑖: Singular value of 𝑋 matrix

Page 42: Lecture 02 Linear Algebra Basics - GitHub Pages

Geometric Meaning of SVD

Image Credit: Kevin Binz

Page 43: Lecture 02 Linear Algebra Basics - GitHub Pages

Summary

β€’ Linear Algebra Basics

β€’ Norms

β€’ Multiplications

β€’ Matrix Inversion

β€’ Trace and Determinant

β€’ Eigen Values and Eigen Vectors

β€’ Singular Value Decomposition