1 of 66

Machine Learning

Prof. Seungchul Lee

Industrial AI Lab.

2 of 66

Contents

  • Regression

  • Classification
    • Linear Classification
      • Perceptron
      • Logistic Regression
    • Non-linear Classification

2

3 of 66

Regression

3

4 of 66

Linear Model

  •  

4

5 of 66

Linear Model

  •  

5

6 of 66

Linear Regression as Optimization

  •  

6

7 of 66

Linear Regression as Optimization

  •  

7

8 of 66

Re-cast Problem as Least Squares

  •  

8

9 of 66

Optimization

  •  

9

10 of 66

Optimization: Orthogonal Projection

10

the same principle in a higher dimension

11 of 66

Solve using Linear Algebra

  • known as least square

11

12 of 66

Solve using Linear Algebra

  • known as least square

12

13 of 66

Scikit-Learn

  • Machine Learning in Python
  • Simple and efficient tools for data mining and data analysis
  • Accessible to everybody, and reusable in various contexts
  • Built on NumPy, SciPy, and matplotlib
  • Open source, commercially usable - BSD license
  • https://scikit-learn.org/stable/index.html#

13

14 of 66

Scikit-Learn: Regression

14

15 of 66

Classification: Perceptron

16 of 66

Classification

  • Categorizing data into predefined classes or categories based on input features

  • Examples
    • Spam detection: Classifying emails as either spam or not spam
    • Image recognition: Identifying objects, animals, or faces in images
    • Medical diagnosis: Predicting whether a patient has a particular condition based on diagnostic data

16

17 of 66

Classification

  •  

17

18 of 66

Classification

  • We will learn
    • Perceptron
    • Logistic regression

  • To find a classification boundary

18

19 of 66

Classification

  • We will learn
    • Perceptron
    • Logistic regression

  • To find a classification boundary

19

20 of 66

Classification

  • We will learn
    • Perceptron
    • Logistic regression

  • To find a classification boundary

20

21 of 66

Perceptron

  •  

21

22 of 66

Perceptron

  •  

22

23 of 66

Classification Boundary

  •  

23

24 of 66

Learning a Hyperplane for Classification

  •  

24

25 of 66

Learning a Hyperplane for Classification

  •  

25

26 of 66

Learning a Hyperplane for Classification

  •  

26

27 of 66

Perceptron Algorithm

  • The perceptron implements

  • Given the training set

  1. pick a misclassified point

  • and update the weight vector

27

28 of 66

Perceptron Algorithm: Illustration

28

29 of 66

Perceptron Algorithm: Illustration

29

30 of 66

Perceptron Algorithm: Illustration

30

31 of 66

Perceptron Algorithm: Illustration

31

32 of 66

Perceptron Algorithm: Illustration

32

33 of 66

Perceptron Algorithm: Illustration

33

34 of 66

Why Perceptron Updates Work ?

  •  

34

35 of 66

Diagram of Perceptron

  • Perceptron can be viewed as a simple neuron in an Artificial Neural Network (ANN)

  • Perceptron Update Rule (discrete version):

  • Gradient Descent Update Rule (continuous version):

35

36 of 66

Perceptron in Python

36

37 of 66

Perceptron in Python

  •  

37

38 of 66

Perceptron in Python

38

 

39 of 66

Perceptron in Python

39

40 of 66

Scikit-Learn for Perceptron

40

41 of 66

The Best Hyperplane Separator?

  • Limitations
    • The Perceptron identifies a separating hyperplane if the data is linearly separable
    • However, it merely finds one of the possible solutions

41

42 of 66

The Best Hyperplane Separator?

  • Improvements
    • Identifying the best hyperplane requires an optimization framework

  • Utilize distance information
    • Support Vector Machines (SVM) and Logistic Regression

42

43 of 66

Classification: Logistic Regression

44 of 66

Linear Classification: Logistic Regression

  • Logistic regression is a classification algorithm
    • don't be confused

  • Perceptron: make use of sign of data

  • We want to use distance information of all the data points
    • logistic regression

44

45 of 66

Using Distances

45

46 of 66

Using Distances

46

47 of 66

Using Distances

47

48 of 66

Using Distances

48

49 of 66

Using all Distances

  •  

49

50 of 66

Using all Distances

  •  

50

51 of 66

Sigmoid Function

  •  

51

Perceptron

Logistic regression

52 of 66

Sigmoid Function

  •  

52

53 of 66

Distance

  •  

53

54 of 66

Distance

  • Perceptron
    • Distance is now measured in the mapped feature space

54

55 of 66

Distance

  • Logistic Regression
    • Distance is now measured in the mapped feature space

55

56 of 66

Logistic Regression using Scikit-Learn

56

57 of 66

Non-linear Classification

57

58 of 66

Classifying Non-linearly Separable Data

  •  

58

59 of 66

Classifying Non-linearly Separable Data

  •  

59

60 of 66

Classifying Non-linearly Separable Data

  •  

60

61 of 66

Nonlinear Classification

61

62 of 66

Kernel

  • Motivation
    • We often need to capture nonlinear patterns in the data
      • Nonlinear regression: the input-output relationship may not be linear
      • Nonlinear classification: the classes may not be separable by a linear boundary
    • Linear models (e.g., linear regression, logistic regression) are simply not rich enough

  • Idea
    • Map the data into a higher-dimensional space where it exhibits linear patterns
    • Apply a linear model in the new feature space
    • Mapping = changing the feature representation

  • Kernel
    • A mapping function that takes nonlinearly distributed data into a higher-dimensional space where it becomes linearly separable
    • With the right kernel, a linear classifier can handle nonlinearly distributed data

62

63 of 66

Non-linear Classification

63

64 of 66

Explicit Kernel

64

65 of 66

Non-linear Classification

65

66 of 66

A Remark on Kernel Selection

  • So far we have assumed that the kernel function is given

  • Choosing a suitable kernel for a given dataset is a nontrivial problem, but we will not pursue it further

  • The reason is that deep learning learns the feature transformation directly from the data.

  • Unlike kernel methods, a neural network discovers the mapping automatically, so no kernel has to be designed by hand

66