1 of 107

Statistics for Machine Learning

2 of 107

Statistics and Probability

  • Probability
    • Probability deals with predicting the likelihood of future outcomes based on known conditions or assumptions
    • Focus: Probability starts with a known model (e.g., theoretical distribution) and aims to predict possible outcomes.

  • Statistics
    • Statistics involves analyzing existing data to infer properties of the population or predict future outcomes
    • Focus: Statistics starts with observed data and attempts to build models or draw conclusions about the underlying distribution.

2

Data

Model

Statistics

Probability

3 of 107

Populations and Samples

  •  

3

4 of 107

Multivariate Statistics

  •  

4

5 of 107

Correlation of Two Random Variables

  •  

5

6 of 107

Correlation Coefficient

  • Interpretation

  • Indicate how close to a linear line, but
  • No information on slope

  • Correlation does not imply causation
  • Even if two variables are strongly correlated, it doesn't necessarily mean one causes the other

6

close to a straight line,

positive correlation

close to a straight line,

negative correlation

no linear line,

uncorrelated

7 of 107

Correlation Coefficient Plot

  • Plots correlation coefficients among pairs of variables
  • http://rpsychologist.com/d3/correlation/

7

8 of 107

Unsupervised Learning:�Dimension Reduction

9 of 107

Dimension

9

 

Dynamics/Robot kinematics

- Degree of freedom

- Generalized coordinate

10 of 107

Dimension Reduction

  • Motivation:
    • Can we describe high-dimensional data in a “simpler” way? 

  • Dimension reduction without losing too much information

  • Find a low-dimensional, yet useful representation of the data

10

11 of 107

Dimension Reduction

  •  

11

12 of 107

Example of Dimension Reduction

  • Change variables

    • Total amount of water

    • Difference in height

  • De-coupled

  • Physical insights
  • Data/statistics

12

13 of 107

Example of Dimension Reduction

  •  

13

14 of 107

Highly Correlated Data

  • Idea: highly correlated data contains redundant features

14

Low redundancy

High redundancy

15 of 107

Principal Component Analysis (PCA)

  •  

15

16 of 107

Principal Component Analysis (PCA)

  •  

16

17 of 107

Principal Component Analysis (PCA)

  •  

17

18 of 107

Principal Component Analysis (PCA)

  •  

18

19 of 107

Principal Component Analysis (PCA)

  •  

19

20 of 107

Principal Component Analysis (PCA)

  •  

20

21 of 107

Principal Component Analysis (PCA)

  •  

21

22 of 107

Principal Component Analysis (PCA)

  •  

22

23 of 107

Principal Component Analysis (PCA)

  •  

23

24 of 107

Principal Component Analysis (PCA)

  • HOW?
    • 1. Maximize variance (most separable)
    • 2. Minimize the sum-of-squares (minimum squared error)

24

25 of 107

PCA Algorithm: Pre-processing

  • Given data

  • Shifting (zero mean) and rescaling (unit variance)
    • 1) Shift to zero mean

    • 2) [optional] Rescaling (unit variance)

25

26 of 107

PCA Algorithm: Maximize Variance

  •  

26

27 of 107

Maximize Variance

  • In an optimization form

27

28 of 107

Minimize the Sum-of-Squared Error

28

29 of 107

Minimize the Sum-of-Squared Error

  • In an optimization form

29

30 of 107

 

  •  

30

31 of 107

Linear Regression vs. PCA

31

Linear Regression

PCA

32 of 107

Linear Regression vs. PCA

32

Linear Regression

PCA

33 of 107

Linear Regression vs. PCA

33

Linear Regression

PCA

34 of 107

Python Codes

34

35 of 107

Python Codes

35

36 of 107

Scikit-learn

36

37 of 107

PCA Example

  • Multiple video camera records of spring and mass system
  • Optimal data representation
    • Find the most informative point of view

37

38 of 107

Multivariate Time Series

  • System order can be inferred from
    • Laws of physics or
    • Data

38

Measured observations

39 of 107

Multivariate Time Series

39

40 of 107

Eigenvalues

40

41 of 107

Projection onto Principal Components

41

42 of 107

Singular Value Decomposition (SVD)

43 of 107

Geometry of Linear Maps

  •  

43

44 of 107

Geometry of Linear Maps

  • An extremely important fact:

44

45 of 107

Singular Values and Singular Vectors

  •  

45

46 of 107

Thin Singular Value Decomposition

46

47 of 107

Full Singular Value Decomposition

  •  

47

48 of 107

Interpretation of SVD

  •  

48

49 of 107

SVD: Matrix factorization

  •  

49

50 of 107

PCA and SVD

  •  

50

51 of 107

PCA and SVD

  •  

51

52 of 107

Low Rank Approximation: Dimension Reduction

52

53 of 107

Full SVD

53

54 of 107

Economy SVD

54

55 of 107

Truncated SVD (Low Rank Approximation)

55

56 of 107

Expansion of SVD

56

 

57 of 107

Expansion of SVD

57

 

58 of 107

Expansion of SVD

58

 

59 of 107

Truncated SVD (Low Rank Approximation)

59

 

 

 

+

+

+

60 of 107

Example: Image Approximation

  •  

60

61 of 107

Example: Image Approximation

  •  

61

62 of 107

A Video of People Walking, Captured by a Surveillance Camera

  • A set of sequential frames taken from a video of people walking

62

63 of 107

To Get Rid of People in the Pictures

  • A set of sequential 20 pictures (or frames) taken from a video of people walking
  • Only extract background from pictures

63

64 of 107

To Get Rid of People in the Pictures

  • A set of sequential 20 pictures (or frames) taken from a video of people walking
  • Only extract background from pictures

64

65 of 107

Question: How to Build a Matrix (Sequence of Images)

65

time

66 of 107

Question: How to Build a Matrix (Sequence of Images)

66

time

time

 

time

67 of 107

Eigenfaces: A SVD-Based Facial Recognition Technique

  • Eigenfaces is a well-known technique in computer vision that applies PCA or SVD for facial recognition.

  • The method is based on the idea that faces can be represented as combinations of key facial features, called eigenfaces.

  • By leveraging SVD, Eigenfaces effectively reduces the dimensionality of face images while retaining the most important features for identification.

67

68 of 107

Eigenface

68

69 of 107

Eigenface

69

Eigenface or eigenmode from U

70 of 107

Data Compression

  •  

70

71 of 107

Face Recognition Using Eigenfaces

  • The Eigenfaces method is a classical yet effective technique for face recognition

  • Step 1: Project Image onto the Eigenface Subspace

  • Step 2: Face Identification Using Distance Metrics

  • Step 3: Classification Decision

71

72 of 107

Recognition and Reconstruction of Disguised Face

  • Here, I present an interesting scenario: President John F. Kennedy is wearing sunglasses when he enters the White House

72

73 of 107

Recognition and Reconstruction of Disguised Face

  •  

73

74 of 107

Proper Orthogonal Decomposition (POD)

74

75 of 107

Proper Orthogonal Decomposition (POD)

  •  

75

76 of 107

Arrangement of Data

  •  

76

time

space

77 of 107

Full SVD

77

78 of 107

Economy SVD

78

79 of 107

Truncated SVD

79

80 of 107

Expansion of SVD

80

81 of 107

Expansion of SVD

81

82 of 107

POD

  •  

82

83 of 107

POD Example 1

  • Consider data generated from the function

83

The Method of Snapshot, Sirovich (1987)

84 of 107

POD Example 1

  • Consider data generated from the function

84

85 of 107

POD Example 1

  • The leading two POD modes capture all of the energy/dynamics of the data,

85

86 of 107

POD Example 1

  • The leading two POD modes capture all of the energy/dynamics of the data,

86

87 of 107

Fluid Flow Past a Circular Cylinder at Low Reynolds Number

87

88 of 107

Question: How to Build a Matrix (2D + time)

88

89 of 107

Singular Values and POD Modes

89

90 of 107

Low Rank Approximation (K = 30)

90

Ground Truth

K = 30

91 of 107

Low Rank Approximation (K = 10)

91

Ground Truth

K = 10

92 of 107

Low Rank Approximation (K = 5)

92

Ground Truth

K = 5

93 of 107

Where We Are At?

  • Coordinate transformation
    • With physical intuition
    • Or data-driven approach

  • Data-driven coordinate transformation
    • Linear coordinate transformation

    • Natural to think about nonlinear coordinate transformation
      • Autoencoder

93

Idea from Prof. Steve Brunton, “Deep Learning to Discover Coordinates for Dynamics: Autoencoders & Physics Informed Machine Learning”

Heliocentrism

Geocentrism

94 of 107

Fisher Discriminant Analysis (FDA)

95 of 107

Dimensionality Reduction with Label

  • Dimensionality reduction with label information (when the ultimate goal is classification/regression)
  • PCA ignores label information even if it is available
    • Only chooses directions of maximum variance

  • Fisher Discriminant Analysis (FDA) takes into account the label information
    • It is also called Linear Discriminant Analysis (LDA)

  • FDA/LDA projects data while preserving class separation
    • Examples from same class are put closely together by the projection
    • Examples from different classes are placed far apart by the projection

95

96 of 107

Projection onto Line ω

  •  

96

97 of 107

Projection onto Line ω

97

98 of 107

Sample Statistics in Projected Space

98

99 of 107

Fisher Discriminant Analysis

  •  

99

100 of 107

Fisher Discriminant Analysis

100

101 of 107

Fisher Discriminant Analysis

101

102 of 107

Fisher Discriminant Analysis

  • Why?
    • Dot product of a unit vector and another vector is maximum when the two have the same direction.

102

103 of 107

Python Code

103

104 of 107

Histogram

104

105 of 107

 

105

106 of 107

 

106

107 of 107

Scikit-learn

107