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
    4

  • 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