multivariate statistical methods and data mining in

49
1  Glen Cowan Multivariate Statistical Methods in Particle Physics Multivariate statistical methods and data mining in particle physics Lecture 4 (19 June, 2008) Glen Cowan RHUL Physics www.pp.rhul.ac.uk/~cowan Academic Training Lectures CERN 16−19 June, 2008

Upload: others

Post on 24-May-2022

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Multivariate statistical methods and data mining in

1 Glen Cowan Multivariate Statistical Methods in Particle Physics

Multivariate statistical methods and data mining in particle physics 

Lecture 4 (19 June, 2008)Glen CowanRHUL Physicswww.pp.rhul.ac.uk/~cowan

Academic Training LecturesCERN16−19 June, 2008

Page 2: Multivariate statistical methods and data mining in

2 Glen Cowan Multivariate Statistical Methods in Particle Physics

OutlineStatement of the problemBrief review of statistical formalismSome general considerationsMultivariate classifiers:

Linear discriminant functionNeural networksNaive Bayes classifierDensity estimation methodsDecision treesSupport Vector Machines

Thursday start

Page 3: Multivariate statistical methods and data mining in

3 Glen Cowan Multivariate Statistical Methods in Particle Physics

Decision treesIn a decision tree repeated cuts are made on a single variable until some stop criterion is reached.

The decision as to which variable is used is based on  best achieved separation.

Iterate until stop criterion reached, basede.g. on purity and minimum numberof events in a node.

Classify resulting cut regions as signalor background based on the signalfraction above/below a specified value (e.g. ½) in the terminal nodes (leaves). Example by MiniBooNE experiment,

B. Roe et al., NIM 543 (2005) 577

Page 4: Multivariate statistical methods and data mining in

4 Glen Cowan Multivariate Statistical Methods in Particle Physics

Separation measureSuppose the ith event has a weight w

i.  The purity at a given node is

P=∑signal

wi

∑signalwi∑background

wi

Measure of s/b separation in a node can be taken as e.g. 

Gini=P 1−P

−P ln P−1−P ln 1−PCross entropy = 

Misclassification error = 1 – max (P, 1–P)

These are maximum for P = 0.5 and zero for P = 0 or 1. Tend to give similar results in real examples; Gini index most common.

Page 5: Multivariate statistical methods and data mining in

5 Glen Cowan Multivariate Statistical Methods in Particle Physics

What variable to cut onThe variable is found that provides the greatest increase in theseparation measure (e.g., Gini) in the two daughter nodes relativeto the parent.

Continue splitting until the number of events in a node falls belowa specified threshold (could be 1).  Terminal nodes called leaves.

The leaves are classified as signal or background depending on majority vote (or e.g. signal fraction greater than a specified threshold).

This classifies every point in input­variable space as either signalor background: a decision tree classifier.

Define a discriminant function f(x) as

f x=1 if x∈signal region ,−1otherwise

Page 6: Multivariate statistical methods and data mining in

6 Glen Cowan Multivariate Statistical Methods in Particle Physics

Decision tree sizeThe same variable may be used at several nodes; others may not be used at all.

In principle a decision tree classifier can have perfect separation between the event classes (will happen e.g.  if the terminal nodes have a single event).

This would clearly be a very over­trained classifier.

Usually one grows the tree first to a very large (e.g. maximum) size and then applies pruning.

For example one can recombine leaves based on some measure of generalization performance (e.g. using statistical error of purity estimates).

Page 7: Multivariate statistical methods and data mining in

7 Glen Cowan Multivariate Statistical Methods in Particle Physics

Decision tree stability

Decision trees tend to be very sensitive to statistical fluctuations inthe training sample.

If e.g. two variables have similar separating power, then a small fluctuation in the training data could cause either of the two variables to be chosen to split the tree; all subsequent development of the treeis thereby affected.

Methods such as boosting can be used to stabilize the tree.

Page 8: Multivariate statistical methods and data mining in

8 Glen Cowan Multivariate Statistical Methods in Particle Physics

BoostingBoosting is a general method of creating a set of classifierswhich can be combined to achieve a new classifier that is more stableand has a smaller error than any individual one.

Often applied to decision trees but, can be applied to any classifier.

Suppose we have a training sample T consisting of N events withx

1,...., x

N      event data vectors (each x multivariate)

y1,...., y

N      true class labels, +1 for signal, 1 for background

w1,...., w

N     event weights

Now define a rule to create from this an ensemble of training samples T

1, T

2, .... , derive a classifier from each and average them.

Page 9: Multivariate statistical methods and data mining in

9 Glen Cowan Multivariate Statistical Methods in Particle Physics

Boosting (2)The framework of a general boosting algorithm can be written:

Initialize the first training sample T1

Determine a classifier f1(x, T

1)  from T

1 and assign a weight 

1

Determine a new training sample T2 from T

1

Iterate K times, so we have:K training samples, T

1 , ...,  T

K

K classifiers f1(x, T

1), ...,  f

K(x, T

K)

K classifier weights, 1 , ...,  

K

Form the final classifier as a function of those from the individual steps, usually as a weighted sum:

y x=∑k=1

K

k f k x ,T k

Page 10: Multivariate statistical methods and data mining in

10 Glen Cowan Multivariate Statistical Methods in Particle Physics

Boosting (3)The important point is that each classifier f

k depends on a modified

version of the training sample with different event weights. 

Trick is to create modifications that give smaller error rates than those of the preceding classifiers.

A number of ways exist for doing this – a successful one is AdaBoost(Freund and Schapire, 1997); short for Adaptive Boosting.

Page 11: Multivariate statistical methods and data mining in

11 Glen Cowan Multivariate Statistical Methods in Particle Physics

AdaBoostFirst initialize the training sample T

1 using the original

x1,...., x

N      event data vectors 

y1,...., y

N      true class labels (+1 or ­1)

w1

(1),...., wN

(1)     event weightswith the weights equal and normalized such that 

∑i=1

N

wi1=1

Then train the classifier f1(x) (e.g. a decision tree)  with a method that

incorporates the event weights.

At each step k, associate a weight k with the classifier f

k.

Page 12: Multivariate statistical methods and data mining in

12 Glen Cowan Multivariate Statistical Methods in Particle Physics

Updating the event weightsDefine the training sample for step k+1 from that of k by updatingthe event weights according to

wik1=wi

k e−k f k xi yi/2

Z k

where Zk is a normalization factor defined such that the sum of the 

weights over all events is equal to one.

i = event index k = training sample index

Page 13: Multivariate statistical methods and data mining in

13 Glen Cowan Multivariate Statistical Methods in Particle Physics

Updating the event weights (2)We can use the sign of  f

k(x) as a classifier.  For an event with data xi,

fk(xi) > 0 classify as signal

fk(xi) < 0   classify as background 

Therefore the product of the classifier value fk(xi) and class label y

i is 

yi f

k(xi) > 0 if the event is classified correctly

yi f

k(xi) < 0   if the event is classified incorrectly

Therefore event weight for event i is increased in the k+1 training sampleif it was classified incorrectly in sample k.

Idea is that next time around the classifier should pay more attention tothis event and try to get it right.

Page 14: Multivariate statistical methods and data mining in

14 Glen Cowan Multivariate Statistical Methods in Particle Physics

Error rate of the kth classifierTherefore the classification error rate 

k is

k=∑i=1

N

wik I yi f k xi0

where I(X) = 1 if X is true and is zero otherwise.

Page 15: Multivariate statistical methods and data mining in

15 Glen Cowan Multivariate Statistical Methods in Particle Physics

Assigning the classifier weightDefine the classifier  f

k(x) such that it minimizes the error rate 

k.

Assign a score to the kth classifier based on its error rate,   

k=ln1−k

k

If we define the final classifier as f x=∑k=1

K

k f k x ,T k

then one can show that its error rate on the training data satisfies the bound

∏k=1

K

2k 1−k

Page 16: Multivariate statistical methods and data mining in

16 Glen Cowan Multivariate Statistical Methods in Particle Physics

AdaBoost error rateSo providing each classifier in the ensemble has 

k > ½ , i.e., better than 

random guessing, then the error rate for the final classifier on the training data (not on unseen data) drops to zero.

That is, for sufficiently large K the training data will be over fitted.

The error rate on a validation sample would reach some minimum after a certain number of steps and then could rise.

So the procedure is to monitor the error rate of the combined classifier at each step with a validation sample and to stop before it starts to rise.

Although in principle AdaBoost must overfit, in practice following this procedure overtraining is not a big problem.

Page 17: Multivariate statistical methods and data mining in

17 Glen Cowan Multivariate Statistical Methods in Particle Physics

Boosted decision tree exampleFirst use of boosted decision trees in HEP was for particle identificationfor the MiniBoone neutrino oscillation experiment.

H.J.Yang, B.P. Roe, J. Zhu, “Studies of Boosted Decision Trees for H.J.Yang, B.P. Roe, J. Zhu, “Studies of Boosted Decision Trees for MiniBooNE Particle Identification”,  Physics/0508045, Nucl. Instum. & Meth. MiniBooNE Particle Identification”,  Physics/0508045, Nucl. Instum. & Meth. A 555(2005) 370­385.A 555(2005) 370­385.

B.P. Roe, H.J. Yang, J. Zhu, Y. Liu, I. Stancu, G. McGregor, ”Boosted decision B.P. Roe, H.J. Yang, J. Zhu, Y. Liu, I. Stancu, G. McGregor, ”Boosted decision trees as an alternative to artificial neural networks for particle identification”, trees as an alternative to artificial neural networks for particle identification”, physics/0408124, NIMA 543 (2005) 577­584.physics/0408124, NIMA 543 (2005) 577­584.

Page 18: Multivariate statistical methods and data mining in

18 Glen Cowan Multivariate Statistical Methods in Particle Physics

Particle i.d. in MiniBooNE

Search for  to 

e oscillations 

required particle i.d. using information from Cherenkovdetector.

Large number (~200) input variables measured for eachevent.

H.J. Yang, MiniBooNE PID, DNP06H.J. Yang, MiniBooNE PID, DNP06

Page 19: Multivariate statistical methods and data mining in

19 Glen Cowan Multivariate Statistical Methods in Particle Physics

Boosted decision tree exampleEach individual tree is relatively weak, with a misclassification error rate ~ 0.4 – 0.45 

Page 20: Multivariate statistical methods and data mining in

20 Glen Cowan Multivariate Statistical Methods in Particle Physics

Monitoring overtraining From MiniBooNEexample

Page 21: Multivariate statistical methods and data mining in

21 Glen Cowan Multivariate Statistical Methods in Particle Physics

MiniBoone boosted decision tree

Here performance stable after a few hundred trees

Page 22: Multivariate statistical methods and data mining in

22 Glen Cowan Multivariate Statistical Methods in Particle Physics

Comparison of boosting algorithmsA number of boosting algorithms on the market; differ in theupdate rule for the tree weight.

Page 23: Multivariate statistical methods and data mining in

23 Glen Cowan Multivariate Statistical Methods in Particle Physics

Decision tree summaryAdvantage of boosted decision tree is it can handle a large numberof inputs.  Those that provide little/no separation are rarely used as tree splitters are effectively ignored.

Easy to deal with inputs of mixed types (real, integer, categorical...)If a tree has only a few leaves it is easy to visualize (butrarely work with an individual tree).

Other ways of combining weaker classifiers:  Bagging (Boostrap­Aggregating), generates the ensemble of classifiers by random samplingwith replacement from the full training sample.

Page 24: Multivariate statistical methods and data mining in

24 Glen Cowan Multivariate Statistical Methods in Particle Physics

Support Vector MachinesSupport Vector Machines (SVMs) are an example of a kernel­basedclassifier, which exploits a nonlinear mapping of the input variablesonto a higher dimensional feature space.

The SVM finds a linear decision boundary in the higher dimensional space.

But thanks to the “kernel trick” one does not every have to write down explicitly the feature space transformation.

Some references for kernel methods and SVMs:

The books mentioned on MondayC. Burges, A Tutorial on Support Vector Machines for Pattern Recognition,research.microsoft.com/~cburges/papers/SVMTutorial.pdf

N. Cristianini and J.Shawe­Taylor. An Introduction to Support Vector Machines and other kernel­based learning methods. Cambridge University Press, 2000. The TMVA manual (!)

Page 25: Multivariate statistical methods and data mining in

25 Glen Cowan Multivariate Statistical Methods in Particle Physics

Linear SVMsConsider a training data set consisting of

x1,...., x

N      event data vectors 

y1,...., y

N      true class labels (+1 or 1)

Suppose the classes can be separated by a hyperplane defined by a normal vector w and scalar offset b (the “bias”).  We have

yi xi⋅wb−10 for all i

xi⋅wb1 for all yi = +1 

xi⋅wb−1 for all yi = ­1 

or equivalently

Bishop Ch. 7

Page 26: Multivariate statistical methods and data mining in

26 Glen Cowan Multivariate Statistical Methods in Particle Physics

Margin and support vectorsThe distance between the hyperplanes defined by y(x) = 1 and y(x) = 1is called the margin, which is:

margin= 2∥w∥

If the training data are perfectly separated then this means there areno points inside the margin.

Suppose there are points on the margin (this is equivalent to definingthe scale of w).  These points are called support vectors.

Page 27: Multivariate statistical methods and data mining in

27 Glen Cowan Multivariate Statistical Methods in Particle Physics

Linear SVM classifier

The best classifier should have a large margin, so to maximize

margin= 2∥w∥

we can minimize  ∥w∥2 subject to the constraints

yi xi⋅wb−10 for all i

We can define the classifier using

y x=signx⋅wb

which is +1 for points on one side of the hyperplane and 1 on the other.

Page 28: Multivariate statistical methods and data mining in

28 Glen Cowan Multivariate Statistical Methods in Particle Physics

Lagrangian formulationThis constrained minimization problem can be reformulated usinga Lagrangian 

L=12∥w∥2−∑

i=1

N

i yi xi⋅wb−1

positive Lagrange multipliers i

We need to minimize L with respect to w and b and maximizewith respect to 

i.

There is an i for every training point.  Those that lie on the margin

(the support vectors) have i > 0, all others have 

i  = 0.  The solution 

can be writtenw=∑

ii yi xi

(sum only contains support vectors)

Page 29: Multivariate statistical methods and data mining in

29 Glen Cowan Multivariate Statistical Methods in Particle Physics

Dual formulation

It can be shown that one finds the same solution a by minimizingthe dual Lagrangian

LD=∑ii−

12∑i , j

i j yi y j xi⋅x j

So this means that both the classifier function and the Lagrangian only involve dot products of vectors in the input variable space.

The classifier function is thus

y x=sign x⋅wb=sign∑ii yi x⋅xib

Page 30: Multivariate statistical methods and data mining in

30 Glen Cowan Multivariate Statistical Methods in Particle Physics

Nonseparable dataIf the training data points cannot be separated by a hyperplane, one can redefine the constraints by adding slack variables 

i:

yi xi⋅wbi−10 withi0 for all i

Thus the training point xi is allowed to 

be up to a distance i on the wrong side 

of the boundary, and i = 0 at or on the 

right side of the boundary.

For an error to occur we have i > 1, so 

∑ii

is an upper bound on the number of training errors.

Page 31: Multivariate statistical methods and data mining in

31 Glen Cowan Multivariate Statistical Methods in Particle Physics

Cost function for nonseparable caseTo limit the magnitudes of the 

i we can define the error function that

we minimize to determine w to be

E w=12∥w∥2

C ∑ii

k

where C is a cost parameter we must choose that limits the amount of misclassification.  It turns out that for k=1 or 2 this is a quadratic

programming problem and furthermore for k=1 it corresponds to

minimizing the same dual Lagrangian 

LD=∑ii−

12∑i , j

i j yi y j xi⋅x j

where the constraints on the i become 0iC .

Page 32: Multivariate statistical methods and data mining in

32 Glen Cowan Multivariate Statistical Methods in Particle Physics

Nonlinear SVMSo far we have only reformulated a way to determine a linear classifier, which we know is useful only in limited circumstances.

But the important extension to nonlinear classifiers comes from firsttransforming the input variables to feature space:

x=1 x , ,m x

These will behave just as our new “input variables”.  Everythingabout the mathematical formulation of the SVM will look the same as before except with (x) appearing in the place of x.

Page 33: Multivariate statistical methods and data mining in

33 Glen Cowan Multivariate Statistical Methods in Particle Physics

Only dot productsRecall the SVM problem was formulated entirely in terms of dot products of the input variables, e.g., the classifier is

y x=sign∑ii yi x⋅xib

y x=sign∑ii yi x⋅ xib

so in the feature space this becomes 

Page 34: Multivariate statistical methods and data mining in

34 Glen Cowan Multivariate Statistical Methods in Particle Physics

The Kernel trickHow do the dot products help?  It turns on that a broad class ofkernel functions can be written in the form:

K x , x ' =x⋅ x '

Functions having this property must satisfy Mercer's condition

∫K x , x ' g xg x ' d x d x '0

for any function g where  ∫ g2 xd x is finite.

So we don't even need to find explicitly the feature space transformation(x), we only need a kernel.

Page 35: Multivariate statistical methods and data mining in

35 Glen Cowan Multivariate Statistical Methods in Particle Physics

Finding kernelsThere are a number of techniques for finding kernels, e.g., constructingnew ones from known ones according to certain rules (cf. Bishop Ch 6).

Frequently used kernels to construct classifiers are e.g.

K x , x ' = x⋅x 'p

K x , x ' =exp−∥x−x '∥2

22 K x , x ' =tanh x⋅x '

polynomial

Gaussian

sigmoidal

Page 36: Multivariate statistical methods and data mining in

36 Glen Cowan Multivariate Statistical Methods in Particle Physics

Using an SVMTo use an SVM the user must as a minimum choose

a kernel function (e.g. Gaussian)any free parameters in the kernel (e.g. the  of the Gaussian)the cost parameter C (plays role of regularization parameter)

The training is relatively straightforward because, in contrast to neuralnetworks, the function to be minimized has a single global minimum.

Furthermore evaluating the classifier only requires that one retainand sum over the support vectors, a relatively small number of points.

Page 37: Multivariate statistical methods and data mining in

37 Glen Cowan Multivariate Statistical Methods in Particle Physics

SVM in HEPSVMs are very popular in the Machine Learning community but haveyet to find wide application in HEP.  Here is an early example froma CDF top quark anlaysis (A. Vaiciulis, contribution to PHYSTAT02).

signaleff.

Page 38: Multivariate statistical methods and data mining in

38 Glen Cowan Multivariate Statistical Methods in Particle Physics

Page 39: Multivariate statistical methods and data mining in

39 Glen Cowan Multivariate Statistical Methods in Particle Physics

Page 40: Multivariate statistical methods and data mining in

40 Glen Cowan Multivariate Statistical Methods in Particle Physics

Page 41: Multivariate statistical methods and data mining in

41 Glen Cowan Multivariate Statistical Methods in Particle Physics

Lecture 4 summaryBoosted Decision Trees and Support Vector Machines are two examplesof relatively modern developments in Machine Learning that are onlyrecently attracting attention in HEP.

There are now many multivariate methods on the market and it is difficult to make general statements about performance; this is oftenvery specific to the problem.

Expect advanced multivariate methods to have a major impact in areaswhere one struggles for statistical significance, not in precisionmeasurements.

Fortunately tools to investigate these methods are now widely available.

Page 42: Multivariate statistical methods and data mining in

42 Glen Cowan Multivariate Statistical Methods in Particle Physics

Extra slides

Page 43: Multivariate statistical methods and data mining in

43 Glen Cowan Multivariate Statistical Methods in Particle Physics

Imperfect pdf estimationWhat if the approximation we use (e.g., parametric form, assumptionof variable independence, etc.) to estimate p(x) is wrong?

If we use poor estimates to construct the test variable 

y x =p x∣H 0

p x∣H 1

then the discrimination between the event classes will not be optimal.

But can this cause us e.g. to make a false discovery?

Even if the estimate of p(x) used in the discriminating variable areimperfect, this will not affect the accuracy of the distributions f(y|H

0), 

f(y|H1); this only depends on the reliability of the training data.

Page 44: Multivariate statistical methods and data mining in

44 Glen Cowan Multivariate Statistical Methods in Particle Physics

Using the classifier output for discovery

y

f(y)

y

N(y)

Normalized to unity Normalized to expected number of events

excess?

signal

background background

searchregion

Discovery = number of events found in search region incompatiblewith background­only hypothesis.   Maximize the probability of this happening by setting y

cut for maximum s/√b (roughly true).

ycut

Page 45: Multivariate statistical methods and data mining in

45 Glen Cowan Multivariate Statistical Methods in Particle Physics

Controlling false discoverySo for a reliable discovery what we depend on is an accurate estimateof the expected number of background events, and this accuracy onlydepends on the quality of the training data; works for any function y(x).

But we do not blindly rely on the MC model for the training data forbackground; we need to test it by comparing to real data in control samples where no signal is expected.

The ability to perform these tests will depend on on the complexity ofthe analysis methods.

Page 46: Multivariate statistical methods and data mining in

46 Glen Cowan Multivariate Statistical Methods in Particle Physics

AdaBoost study with linear classifierJ. Sochman, J. Matas, cmp.felk.cvut.cz

Start with a problem for which a linear classifier is weak:

Page 47: Multivariate statistical methods and data mining in

47 Glen Cowan Multivariate Statistical Methods in Particle Physics

AdaBoost study with linear classifierJ. Sochman, J. Matas, cmp.felk.cvut.cz

Page 48: Multivariate statistical methods and data mining in

48 Glen Cowan Multivariate Statistical Methods in Particle Physics

MiniBooNE Decision tree performance

~ b / 

b

Page 49: Multivariate statistical methods and data mining in

49 Glen Cowan Multivariate Statistical Methods in Particle Physics

Quotes I like

“Keep it simple.As simple as possible.Not any simpler.”

 – A. Einstein

“If you believe in something you don't understand, you suffer,..”

 – Stevie Wonder