feature selection - york university€¦ · cse 4404/5327 introduction to machine learning and...

27
J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition FEATURE SELECTION

Upload: others

Post on 22-May-2020

11 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

FEATURE SELECTION

Page 2: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

2

Outline

¨  Analyzing individual features ¤ Signal to noise ratio ¤ Null hypothesis testing

¨  Analyzing feature vectors ¤ Divergence ¤ Chernoff Bound and Bhattacharyya Distance ¤ Scatter Matrices ¤ Feature Subset Selection

Page 3: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

3

Which feature would you choose?

−10 −5 0 5 10 150

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0.5

Normalized intensity

Prob

abilit

y

FaceNon−Face

−4 −3 −2 −1 0 1 2 3 4 5 60

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

Normalized intensity

Prob

abilit

y

FaceNon−Face

Page 4: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

4

Outline

¨  Analyzing individual features ¤ Signal to noise ratio ¤ Null hypothesis testing

¨  Analyzing feature vectors ¤ Divergence ¤ Chernoff Bound and Bhattacharyya Distance ¤ Scatter Matrices ¤ Feature Subset Selection

Page 5: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

5

Signal to Noise Ratio

¨  We wish to select features that have a high signal-to-noise ratio.

¨  Typically we measure the signal strength as the difference in the class-conditional means:

¨  The noise can be characterized by the conditional standard deviation. If the class-conditional distributions can be assumed to have the same standard deviation, the signal-to-noise ratio can be expressed as:

S = µ2 ! µ1

SNR =

µ2 ! µ1

"

Page 6: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

6

Signal to Noise

¨  Why is this a meaningful number?

¨  Suppose that the class-conditional distributions are Gaussian, i.e.,

¨  Recall that for the equal variance case, the maximum likelihood classifier will select the class based upon the Mahalanobis distance. In this case, this means that

¨  wlog, suppose Then the decision rule becomes

SNR =

µ2 ! µ1

"

x1 !N µ1,!

2( ), x2 !N µ2,!2( )

x ! µ1 < x ! µ2 "#1

x ! µ1 > x ! µ2 "# 2

µ1 < µ2.

x < x0 !"1

x > x0 !" 2 where x0 =

12

µ1 + µ2( )

Page 7: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

7

Signal to Noise

¨  The probability of error is therefore:

p(error) = p x > x0 |!1( )p !1( ) + p x < x0 |! 2( )p ! 2( )

Then p(error) = 1

21! F x0;µ1,"

2( ) + F x0;µ2,"2( )( )

Let F x;µ,! 2( ) represent the cumulative normal distribution, i.e., F x;µ,! 2( ) ! 1

2"!exp #

$x # µ( )2

2! 2

%

&''

(

)**#+

x

, d $x

= 1

21! F

x0 ! µ1

";0,1

#$%

&'(+ F

x0 ! µ2

";0,1

#$%

&'(

#

$%&

'(

= 1

2F !

µ2 ! µ1

2";0,1

#$%

&'(+ F !

µ2 ! µ1

2";0,1

#$%

&'(

#

$%&

'(

= 1

2F !

x0 ! µ1

";0,1

#$%

&'(+ F

x0 ! µ2

";0,1

#$%

&'(

#

$%&

'(

= F !

µ2 ! µ1

2";0,1

#$%

&'(

Thus the probability of error depends only on the SNR,

µ2 ! µ1

".

Page 8: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

8

SNR: Unknown Parameters

¨  Thus when selecting features a good first-order rule is to select the features with maximal SNR (for minimal error).

¨  Normally, we do not know the class-conditional parameters, and must estimate them from data.

¨  We could compute an ML estimate. However, convention is to use unbiased estimates of the parameters:

SNR =x2 ! x1

swhere

xi =1Ni

xj" j =i# and s2 =

xj ! x1( )2

" j =1# + xj ! x2( )2

" j =2#

N1 +N2 ! 2.

Page 9: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

9

SNR: Unknown Parameters

¨  Note that due to sampling error, the estimated parameters will not be exactly correct.

¨  As a consequence, even if a feature is completely uninformative for the classification, the SNR estimate will still be non-zero.

¨  How can we filter out these uninformative features?

SNR =x2 ! x1

swhere

xi =1Ni

xj" j =i# and s2 =

xj ! x1( )2

" j =1# + xj ! x2( )2

" j =2#

N1 +N2 ! 2.

Page 10: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

10

Outline

¨  Analyzing individual features ¤ Signal to noise ratio ¤ Null hypothesis testing

¨  Analyzing feature vectors ¤ Divergence ¤ Chernoff Bound and Bhattacharyya Distance ¤ Scatter Matrices ¤ Feature Subset Selection

Page 11: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

11

Null Hypothesis Testing

¨  One approach is to use a null hypothesis testing (NHT) procedure.

¨  Notice that the precision of this distribution increases linearly with the number of training inputs. In particular, if we knew the variance, we could form the test statistic

Suppose that the observations x are normally distributed.Since the x i are linear functions of x, these are also normally distributed:

xi !N µi ,!

2 / Ni( ) (Lecture 1 – Topic 7.2)

Thus x2 ! x1 is also normally distributed:

x2 ! x1 !N µ2 ! µ1,

" 2

N1

+ " 2

N2

#

$%&

'(

SNR =

x2 ! x1

s.

z =x2 ! x1

" 1N1

+ 1N2

#

$%&

'(

!N (0,1) if µ1 = µ2.

Page 12: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

12

The t-statistic

¨  However, s is also a random variable, and so the SNR is not distributed as a Gaussian.

¨  Instead, under the null hypothesis (no difference in the means), the statistic

follows a student’s t distribution with N1+N2-2 degrees of freedom.

SNR =

x2 ! x1

s.

t =x2 ! x1

s1N1

+ 1N2

"

#$%

&'

Page 13: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

13

The t-test

¨  Given this statistic, one can compute the probability that a value this large (in absolute value) would be produced were there no difference in the means (the null hypothesis).

¨  In the NHT procedure, we ‘fail to reject’ the null hypothesis if this probability exceeds a pre-specified value, typically .05.

¨  In selecting features, we can choose to reject any feature that does not meet this NHT criterion.

t =x2 ! x1

s1N1

+ 1N2

"

#$%

&'

Page 14: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

14

Generalizing to Multiple Classes

¨  The NHT approach can be generalized to K>2 classes using analysis of variance (ANOVA) methods.

¨  We will not cover these here.

Page 15: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

15

Example

−10 −5 0 5 10 150

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0.5

Normalized intensity

Prob

abilit

y

FaceNon−Face

−4 −3 −2 −1 0 1 2 3 4 5 60

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

Normalized intensity

Prob

abilit

y

FaceNon−Face

N1 = 2429N2 = 4548

t = 30.4! p = 2.4 "10#190.

t = !59.6" p = very small!!

Page 16: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

16

Limitations of NHT for Feature Selection

¨  A significant t-statistic indicates that there is sufficient training data to reveal a discriminative signal in a particular feature.

¨  However, it does not guarantee that including the feature will improve your classification rate on new data.

¨  The main problem is that the discriminative information in that feature may be redundant with information in other features.

Page 17: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

17

ROC Curves

¨  As the criterion threshold is swept from right to left, p(HIT) increases, but p(FA) also increases.

¨  The resulting plot of p(HIT) vs p(FA) is called a receiver-operating characteristic (ROC).

d’ = 1

Hits = 97.5%

False alarms = 84%

Hits = 84%

False alarms = 50%

Hits = 50%

False alarms = 16%

Figure 3: Effect of shifting the criterion.

happens the subject’s choices are not so difficult as before. They can pick a criterion toget nearly a perfect hit rate with almost no false alarms. ROC curves for stronger signalsbow out further than ROC curves for weaker signals.

Varying the noise. There is another aspect of the probability densities that also deter-mines detectability: the spread of the curves. For example, consider the two sets of proba-bility densities in Figure 5. The separation between the peaks is the same but the secondset of curves are much skinnier. Clearly, the signal is much more discriminable whenthere is less spread (less noise) in the probability densities. So the subject would have aneasier time setting their criterion in order to be right nearly all the time.

In our example, we have assumed Poisson noise so the absorption count variance isproportional to the mean absorption count. However, one can easily imagine situationsin which the response variance depends on factors that are independent of the meanresponse.

Discriminability index ( ). Thus, the discriminability of a signal depends both on theseparation and the spread of the noise-alone and signal-plus-noise curves. To write downa full description of how discriminable the signal is from no-signal, we want a formulathat captures both the separation and the spread. The most widely used measure is calledd-prime ( ), and its formula is simply:

where the separation corresponds to the difference between the means, and the spreadcorresponds to the standard deviation of the probability densities. This number, , is

5

0 4 8 12 16 200

0.05

0.1

0.15

0.2

0.25

0 4 8 12 16 200

0.05

0.1

0.15

0.2

0.25

0 0.2 0.4 0.6 0.8 10

0.2

0.4

0.6

0.8

1

False Alarm Rate

Hit

Rat

e

Prob

abilit

y

Prob

abilit

y

Response Response

noise alone

signal plusnoise

A B

C

Figure 4: Internal response probability density functions and ROC curves for differentsignal strengths. When the signal is stronger there is less overlap in the probability ofoccurrence curves, and the ROC curve becomes more bowed. A: Probability density func-tions when the signal evokes an average of 2 photon absorptions per trial. B: Probabilitydensity functions when the signal evokes an average of 5 photon absorptions per trial.C: ROC curves for a series of signal strengths that evoke an average ofphoton absorptions per trial. In all cases the dark noise (average number of spontaneousisomerizations per trial) was 3.

a complete characterization of the detectability of the signal assuming that the noisefollows a normal (Gaussian) distribution with a fixed variance, independent of the sig-nal strength. This assumption of IID (independent and identically distributed) Gaussiannoise is often reasonable approximations. However, if you have more information aboutthe noise distribution (e.g., that it follows the Poisson distribution), you might as well usethat information rather than assuming IID Gaussian noise.

The primary virtue of , and the reason that it is so widely used, is that its value doesnot depend upon the criterion the subject is adopting, but instead it is a true measure ofthe internal response.

Comparing neural responses with behavioral performance. Let’s say that we carefullymeasure, in a separate experiment, the average number of spontaneous (thermal) isomer-izations per trial. Then we can compute a series of ROC curves each corresponding toa different number of photon absorptions. Figure 4 shows such a family of ROC curves.Exactly how to compute these curves is illustrated in assignment3Tutorial.m.

Now we do our detection experiment in which we ask our subject to run 1000 trials.On half the trials, the flash is absent (noise-only trials) and on half the trials the light is

6

SNR = 0

Increasing SNR

Page 18: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

End of Lecture

Page 19: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

19

Outline

¨  Analyzing individual features ¤ Signal to noise ratio ¤ Null hypothesis testing

¨  Analyzing feature vectors ¤ Divergence ¤ Chernoff Bound and Bhattacharyya Distance ¤ Scatter Matrices ¤ Feature Subset Selection

Page 20: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

20

Divergence

¨  The divergence between two class-conditional distributions is a symmetrization of the Kullback-Leibler distance between the two distributions:

¨  The separability of M classes can then be defined as

Divergence dij= D

ij+ D

ji

where Dij+ D

ji are the Kullback-Leibler divergences:

Dij= p x | !

i( ) logp x | !

i( )p x | !

j( )dx

"#

#

$

Dji= p x | !

j( ) logp x | !

j( )p x | !

i( )dx

"#

#

$

P !

i( )

d = d

ijP !

i( )P !j( )

j =1

M

"i =1

M

"

Page 21: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

21

Properties of the Divergence

¨  If the components of the feature vectors are conditionally independent, then

¨  The divergence is general in the sense that it can be non-zero even if the class-conditional means are the same.

¨  However, for multivariate normal distributions with equal covariance matrices, the divergence reduces to the Mahalanobis distance between the means:

where dij= D

ij+ D

ji

and

Dij= p x | !

i( ) logp x | !

i( )p x | !

j( )dx

"#

#

$

Dji= p x | !

j( ) logp x | !

j( )p x | !

i( )dx

"#

#

$

d = d

ijP !

i( )P !j( )

j =1

M

"i =1

M

"

d

ijx( ) = d

ijx

m( )m=1

M

!

d

ij= µ

i! µ

j( )t

"!1 µ

i! µ

j( )

Page 22: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

22

Chernoff Bound

¨  The minimum classification error Pe attainable by a Bayes classifier for two classes is given by

¨  Using the inequality

yields the Chernoff bound:

¨  Since this must apply for all s between 0 and 1, one can (in theory) find the tightest bound by constrained minimization with respect to s.

P

e= min P !

i( ) p x | !i( ) , P !

j( ) p x | !j( )( )dx

"#

#

$ .

min(a,b) ! asb1"s for a,b # 0 and 0 ! s ! 1

P

e! P "

i( )sP "

j( )1#s

p x | "i( )

sp x | "

j( )1#s

dx#$

$

%

Page 23: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

23

Bhattacharyya Distance

¨  Using s = 1/2, and assuming multivariate normal distributions, a specific form of the Chernoff distance known as the Bhattacharyya distance can be derived.

¨  Again, if the covariances are equal, the Bhattacharyya distance is proportional to the Mahalanobis distance.

Page 24: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

24

Scatter Matrices

¨  The divergence and Chernoff bound are only readily computed for normal distributions.

¨  A more easily computed measure of class separability is based upon scatter matrices.

¨  The within-class scatter matrix Sw is defined as:

¨  The between-class scatter matrix Sb is defined as:

¨  The mixture scatter matrix Sm is defined as:

Sw= P

i!

ii =1

M

" ,

where Pi=

ni

N is the empirical estimate of the prior for Class #

i

and !i is the covariance matrix for Class #

i

Sb= P

i! µ

0( ) µi! µ

0( )t

i =1

M

" ,

where µi is the mean for Class #

i and µ

0 is the pooled mean.

S

m= E x ! µ

0( ) x ! µ0( )

t"

#$%

&'.

Page 25: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

25

Scatter Matrices

¨  Measures of separability can be formed from these scatter matrices. Recalling that: ¤ The trace of the covariance matrix is equal to the sum

of the eigenalues and is a measure of the total variance in the data

¤ The determinant of the covariance matrix can also be used as a measure of the total variability and is sometimes called the generalized variance

¨  We have the following measures of separability:

J1=

trace Sm( )

trace Sw( )

J2=

Sm

Sw

J3=

Sb

Sw

Page 26: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

26

Example

J

3= 164.7

J

3= 12.5

J

3= 620.9

Page 27: FEATURE SELECTION - York University€¦ · CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition J. Elder 16 Limitations of NHT for Feature Selection ! A significant

Probability & Bayesian Inference

J. Elder CSE 4404/5327 Introduction to Machine Learning and Pattern Recognition

27

Selecting Feature Vectors

¨  The methods we have discussed provide a means for selecting a single feature.

¨  One can use any of these to select a subset of features based upon their individual merits.

¨  However, this does not take into account the statistical redundancy between these features.

¨  Ch 5.7.2 of the textbook discusses some heuristics for reducing this redundancy when selecting feature subsets. We will not discuss these here.

¨  We will discuss more powerful and principled methods for selecting feature subsets (dimensionality reduction, boosting) in coming lectures.