• 沒有找到結果。

© Deng Cai, College of Computer Science, Zhejiang University

N/A
N/A
Protected

Academic year: 2021

Share "© Deng Cai, College of Computer Science, Zhejiang University"

Copied!
39
0
0

加載中.... (立即查看全文)

全文

(1)

© Deng Cai, College of Computer Science, Zhejiang University 

So Far…

Our goal (supervised learning):

 To learn a set of discriminant functions

Bayesian framework

 We could design an optimal classifier if we knew:

P(i) : priors and P(x | i) : class‐conditional densities

Using training data to estimate P(i) and P(x | i)

Directly learning discriminant functions from the training data

 We only know the form of the discriminant functions

 Linear Methods for Regression

(2)

2

Linear Methods for Classification

Deng Cai (蔡登)

College of Computer Science Zhejiang University

[email protected]

(3)

© Deng Cai, College of Computer Science, Zhejiang University 

Discriminant Functions and Classifiers

Set of discriminant functions:  , 1, ⋯ ,

Classifier assigns a feature vector  to class  if:

, ∀

Classification

(4)

© Deng Cai, College of Computer Science, Zhejiang University 

Linear Regression of an Indicator Matrix

One VS. Rest

(5)

 Cai, College of Computer Science, Zhejiang University 

Sigmoid function

σ t

1 1

1

It is the cumulative distribution function (CDF) of the standard  logistic distribution.

While the input can have any value from  ∞ to  ∞, the output takes  only values between 0 and 1, and hence is interpretable as probability

σ:R → 0,1 S‐shaped

(logistic function)

(6)

© Deng Cai, College of Computer Science, Zhejiang University 

Logistic Regression

Logistic Regression (LR) is a classification model used to describe  the relationship between a categorical dependent variable and one or  several independent variables  by estimating probabilities using 

sigmoid function.

1 , 1

1

1 , 1 1 1

1

1 1

1 , 1

1

(7)

 Cai, College of Computer Science, Zhejiang University 

Maximum Likelihood Estimation for  Logistic Regression

Logistic Regression:

 : a convex function of  ?

1 , 1

1

log

log 1

log 1

Homework

(8)

© Deng Cai, College of Computer Science, Zhejiang University 

Objective Function of Logistic Regression:

Objective Function of Linear Regression:

Gradient Descent

Minimize a Differentiable Function

log 1

(9)

© Deng Cai, College of Computer Science, Zhejiang University 

Gradient Descent

(10)

© Deng Cai, College of Computer Science, Zhejiang University 

Gradient Descent

A first‐order optimization algorithm. 

Can find a local minimum of a function 

One takes steps proportional to the negative of the gradient (or of the  approximate gradient) of the function at the current point. 

If instead one takes steps proportional to the positive of the gradient,  one approaches a local maximum of that function; 

Another name: steepest descent

(11)

© Deng Cai, College of Computer Science, Zhejiang University 

Gradient Descent

If the multivariable function  is defined and differentiable in a  neighborhood of a point  , then  decreases fastest if one goes  from  in the direction of the negative gradient of  at  ,  . 

If  , for  small enough, then  .

With this observation in mind, one starts with a guess  for a local  minimum of  , and considers the sequence  , , , ⋯ such that

, 0

We have

so hopefully the sequence  converges to the desired local  minimum. 

Note that the value of the step size  is allowed to change at every  iteration. 

(12)

© Deng Cai, College of Computer Science, Zhejiang University 

Gradient Descent Algorithm

L(a)

a a4 a3 a2 a1

(13)

© Deng Cai, College of Computer Science, Zhejiang University 

Minimize a Differentiable Function

If the multivariable function  is defined and differentiable in a  neighborhood of a point  , then  decreases fastest if one goes  from  in the direction of the negative gradient of  at  ,  . 

If  , for  small enough, then  .

Taylor series for evaluating a function

If we use a linear approximation 

The ʺZig‐Zaggingʺ nature of Gradient Decent

Why?

2!

3!

(14)

© Deng Cai, College of Computer Science, Zhejiang University 

Minimize a Differentiable Function

If we use a linear approximation, then Gradient Decent

If we use a quadratic approximation, then  Newton’s Method

Quasi‐Newton

 DFP, BFGS, L‐BFGS, OWL‐QN

2!

3!

Choose ∆ that  ! is minimum

0

(15)

 Cai, College of Computer Science, Zhejiang University 

Regularized Logistic Regression

L2‐regularizer

L1‐regularizer (Sparse Logistic Regression) log 1

(16)

© Deng Cai, College of Computer Science, Zhejiang University 

Software

LIBLINEAR

 http://www.csie.ntu.edu.tw/~cjlin/liblinear/

(17)

 Cai, College of Computer Science, Zhejiang University 

Support Vector Machine

(18)

© Deng Cai, College of Computer Science, Zhejiang University 

Two‐category Linearly Separable Case

If

 0 for examples from the positive class.

 0 for examples from the negative class.

Such a weight vector  is called a separating vector or a  solution vector

 Does solution vector unique?

(19)

 Cai, College of Computer Science, Zhejiang University 

Non‐uniqueness of hyperplane

classifier

(20)

© Deng Cai, College of Computer Science, Zhejiang University 

Which one is better?

(21)

 Cai, College of Computer Science, Zhejiang University 

Binary Classification

Equation for hyperplane:

0 Negative class:

0

Positive class:

0

(22)

© Deng Cai, College of Computer Science, Zhejiang University 

Geometrical Margin

Define  as the distance from  to the hyperplane

 Computation: let the projection of  into the  hyperplane be  , then we have

0

: geometrical margin

(23)

 Cai, College of Computer Science, Zhejiang University 

Geometrical Margin

Small 

Large  If the hyperplane moves a little, 

points with small 

will be affected, but 

points with large 

(24)

© Deng Cai, College of Computer Science, Zhejiang University 

Maximum Margin Classifier

Define the margin of a dataset be the minimum margin of each data  point

Maximum margin classifier tries to achieve the maximum possible  margin for a given dataset

 Thus maximize the confidence of classifying the dataset

Goal: Find the hyperplane with the largest margin

(25)

 Cai, College of Computer Science, Zhejiang University 

Why Maximum Margin?

Intuitively this feels safest

If we’ve made a small error in the location of the boundary, this gives  us least chance of causing misclassification

There’s some theory (using VC dimension) that is related to the  proposition that this is a good thing.

Empirically it works very, very well.

(26)

© Deng Cai, College of Computer Science, Zhejiang University 

Maximum Margin Classifier

Geometrical margin is a value uniquely determined by the position  of the hyperplane

If we scale  ,  will not change as long as the hyperplane is kept  fixed

Geometrical  Margin

Margin  maximized

(27)

 Cai, College of Computer Science, Zhejiang University 

Maximum Margin Classifier

We know  can be made arbitrarily large 

without changing the hyperplane, so we simply fix 

(28)

© Deng Cai, College of Computer Science, Zhejiang University 

Maximum Margin Classifier

,

,

,

(29)

 Cai, College of Computer Science, Zhejiang University 

Maximum Margin Classifier

Square and a coefficient  are added for the 

convenience of the derivation of optimization,  and the minimizer of  and  is 

obviously the same.

(30)

© Deng Cai, College of Computer Science, Zhejiang University 

Support Vector Machine

Hyper plane of 

maximum margin is  supported by those 

points (vectors) on the  margin. Those are called  Support Vectors. Non‐

support vectors can  move freely without 

affecting the position of 

the hyperplane as long 

as they don’t exceed the 

margin.

(31)

© Deng Cai, College of Computer Science, Zhejiang University 

History of SVM

SVM is related to statistical learning theory [3]

SVM was first introduced in 1992 [1] 

SVM becomes popular because of its success in handwritten digit  recognition 

 1.1% test error rate for SVM. This is the same as the  error rates of a carefully constructed neural network,  LeNet 4.

See Section 5.11 in [2] or the discussion in [3] for details

SVM is now regarded as an important example of “kernel methods”,  one of the key area in machine learning

[1] Bernhard E. Boser , Isabelle M. Guyon , Vladimir N. Vapnik, A Training Algorithm for Optimal Margin Classifiers.

Proceedings of the Fifth Annual Workshop on Computational Learning Theory 5 144-152, Pittsburgh, 1992.

[2] L. Bottou et al. Comparison of classifier methods: a case study in handwritten digit recognition. Proceedings of the 12th

(32)

© Deng Cai, College of Computer Science, Zhejiang University 

Weakness of the Original Model

When an outlier appear, the optimal  hyperplane may be pushed far away  from its original/correct place. The  resultant margin will also be smaller  than before.

Red Solid: the original hyperplane

Dark dashed: the new hyperplane

,

(33)

© Deng Cai, College of Computer Science, Zhejiang University 

Slack Variables

Assign a slack variable  to each data point. 

That means we allow  the point to deviate 

from the correct margin  by a distance of 

(Actually  when 

considering geometrical 

(34)

© Deng Cai, College of Computer Science, Zhejiang University 

New Objective Function

Slack variables can’t be arbitrarily large, we want to  minimize the sum of all slack variables

,

(35)

 Cai, College of Computer Science, Zhejiang University 

New Objective Function

,

We would pay a cost of the objective function being increased by . The parameter controls the relative weighting

between the twin goals of making the small (makes the margin large) and of ensuring that most examples have

functional margin at least 1.

(36)

© Deng Cai, College of Computer Science, Zhejiang University 

Software

Lots of SVM software:

LibSVM (C++)

 http://www.csie.ntu.edu.tw/~cjlin/libsvm/

SVMLight (C)

(37)

© Deng Cai, College of Computer Science, Zhejiang University 

Unconstrained Optimization Problem of SVM

min,

1 2

1 0

1 max 1 , 0

min, max 1 , 0 1

2

Loss function Regularizer

max 1 , 0 Hinge loss

1

Linear regression: 

Loss  function

Square loss Logistic regression:  log 1

Loss function

(38)

© Deng Cai, College of Computer Science, Zhejiang University 

A General formulation of classifiers

38

min

Loss function Regularizer

Hinge loss: ℓ max 1 , 0 Square loss: ℓ 1

Logistic loss: ℓ log 1

Ordinary regression Logistic regression SVM

L2‐regularizer L1‐regularizer

(39)

 Cai, College of Computer Science, Zhejiang University 

Loss Function

參考文獻

相關文件

Torrance CA Public Library、Science Library - UC, Irvine、San Diego State University Libray, SDSU、Center for the Study of Religion Freedom Virginia Wesleyan College、Learning Resource

Department of Computer Science and Information Engineering, Chaoyang University of

• elearning pilot scheme (Four True Light Schools): WIFI construction, iPad procurement, elearning school visit and teacher training, English starts the elearning lesson.. 2012 •

• Children from this parenting style are more responsive, able to recover quickly from stress; they also have better emotional responsiveness and self- control; they can notice

DVDs, Podcasts, language teaching software, video games, and even foreign- language music and music videos can provide positive and fun associations with the language for

Proceedings of the 19th Annual International ACM SIGIR Conference on Research and Development in Information Retrieval pp.298-306.. Automatic Classification Using Supervised

Shang-Yu Su, Chao-Wei Huang, and Yun-Nung Chen, “Dual Supervised Learning for Natural Language Understanding and Generation,” in Proceedings of The 57th Annual Meeting of

Lu, Linear-time compression of bounded-genus graphs into information-theoretically optimal number of bits, in Proceedings of the Thirteenth Annual ACM-SIAM Symposium on