Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright  2004 limsoon wong A Practical Introduction to Bioinformatics Limsoon Wong Institute for Infocomm Research Lecture 1, May 2004 For written notes.

Similar presentations


Presentation on theme: "Copyright  2004 limsoon wong A Practical Introduction to Bioinformatics Limsoon Wong Institute for Infocomm Research Lecture 1, May 2004 For written notes."— Presentation transcript:

1 Copyright  2004 limsoon wong A Practical Introduction to Bioinformatics Limsoon Wong Institute for Infocomm Research Lecture 1, May 2004 For written notes on this lecture, please read chapter 3 of The Practical Bioinformatician, http://www.wspc.com/books/lifesci/5547.html

2 Copyright  2004 limsoon wong Course Plan How to do experiment and feature generation DNA feature recognition Microarray analysis Sequence homology interpretation

3 Copyright  2004 limsoon wong Essence of Bioinformatics

4 Copyright  2004 limsoon wong What is Bioinformatics?

5 Copyright  2004 limsoon wong Themes of Bioinformatics Bioinformatics = Data Mgmt + Knowledge Discovery + Sequence Analysis + Physical Modelling + …. Knowledge Discovery = Statistics + Algorithms + Databases

6 Copyright  2004 limsoon wong Benefits of Bioinformatics To the patient: Better drug, better treatment To the pharma: Save time, save cost, make more $ To the scientist: Better science

7 Copyright  2004 limsoon wong Essence of Knowledge Discovery

8 Copyright  2004 limsoon wong Jonathan’s rules: Blue or Circle Jessica’s rules: All the rest What is Knowledge Discovery? Whose block is this? Jonathan’s blocks Jessica’s blocks

9 Copyright  2004 limsoon wong What is Knowledge Discovery? Question: Can you explain how?

10 Copyright  2004 limsoon wong The Steps of Knowledge Discovery Training data gathering Feature generation  k-grams, colour, texture, domain know-how,... Feature selection  Entropy,  2, CFS, t-test, domain know-how... Feature integration  SVM, ANN, PCL, CART, C4.5, kNN,... Some classifier/ methods

11 Copyright  2004 limsoon wong What is Accuracy?

12 Copyright  2004 limsoon wong What is Accuracy? Accuracy = No. of correct predictions No. of predictions = TP + TN TP + TN + FP + FN

13 Copyright  2004 limsoon wong Examples (Balanced Population) Clearly, B, C, D are all better than A Is B better than C, D? Is C better than B, D? Is D better than B, C? Accuracy may not tell the whole story

14 Copyright  2004 limsoon wong Examples (Unbalanced Population) Clearly, D is better than A Is B better than A, C, D? high accuracy is meaningless if population is unbalanced

15 Copyright  2004 limsoon wong What is Sensitivity (aka Recall)? Sensitivity = No. of correct positive predictions No. of positives = TP TP + FN wrt positives Sometimes sensitivity wrt negatives is termed specificity

16 Copyright  2004 limsoon wong What is Precision? Precision = No. of correct positive predictions No. of positives predictions = TP TP + FP wrt positives

17 Copyright  2004 limsoon wong Abstract Model of a Classifier Given a test sample S Compute scores p(S), n(S) Predict S as negative if p(S) < t * n(s) Predict S as positive if p(S)  t * n(s) t is the decision threshold of the classifier changing t affects the recall and precision, and hence accuracy, of the classifier

18 Copyright  2004 limsoon wong Precision-Recall Trade-off A predicts better than B if A has better recall and precision than B There is a trade-off between recall and precision In some applications, once you reach a satisfactory precision, you optimize for recall In some applications, once you reach a satisfactory recall, you optimize for precision recall precision

19 Copyright  2004 limsoon wong Comparing Prediction Performance Accuracy is the obvious measure –But it conveys the right intuition only when the positive and negative populations are roughly equal in size Recall and precision together form a better measure –But what do you do when A has better recall than B and B has better precision than A? So let us look at some alternate measures ….

20 Copyright  2004 limsoon wong F-Measure ( Used By Info Extraction Folks ) Take the harmonic mean of recall and precision F = 2 * recall * precision recall + precision (wrt positives) Does not accord with intuition

21 Copyright  2004 limsoon wong Adjusted Accuracy Weigh by the importance of the classes Adjusted accuracy =  * Sensitivity  * Specificity+ where  +  = 1 typically,  =  = 0.5 But people can’t always agree on values for , 

22 Copyright  2004 limsoon wong ROC Curves By changing t, we get a range of sensitivities and specificities of a classifier A predicts better than B if A has better sensitivities than B at most specificities Leads to ROC curve that plots sensitivity vs. (1 – specificity) Then the larger the area under the ROC curve, the better sensitivity 1 – specificity

23 Copyright  2004 limsoon wong What is Cross Validation?

24 Copyright  2004 limsoon wong Construction of a Classifier Build Classifier Training samples Classifier Apply Classifier Test instance Prediction

25 Copyright  2004 limsoon wong Estimate Accuracy: Wrong Way Apply Classifier Predictions Build Classifier Training samples Classifier Estimate Accuracy Why is this way of estimating accuracy wrong?

26 Copyright  2004 limsoon wong Recall... Given a test sample S Compute scores p(S), n(S) Predict S as negative if p(S) < t * n(s) Predict S as positive if p(S)  t * n(s) t is the decision threshold of the classifier …the abstract model of a classifier

27 Copyright  2004 limsoon wong K-Nearest Neighbour Classifier (k-NN) Given a sample S, find the k observations S i in the known data that are “closest” to it, and average their responses. Assume S is well approximated by its neighbours p(S) =  1 S i  N k (S)  D P n(S) =  1 S i  N k (S)  D N where N k (S) is the neighbourhood of S defined by the k nearest samples to it. Assume distance between samples is Euclidean distance for now

28 Copyright  2004 limsoon wong Estimate Accuracy: Wrong Way Apply 1-NN Predictions Build 1-NN Training samples 1-NN Estimate Accuracy 100% Accuracy For sure k-NN (k = 1) has 100% accuracy in the “accuracy estimation” procedure above. But does this accuracy generalize to new test instances?

29 Copyright  2004 limsoon wong Estimate Accuracy: Right Way Testing samples are NOT to be used during “Build Classifier” Apply Classifier Predictions Build Classifier Training samples Classifier Estimate Accuracy Testing samples

30 Copyright  2004 limsoon wong How Many Training and Testing Samples? No fixed ratio between training and testing samples; but typically 2:1 ratio Proportion of instances of different classes in testing samples should be similar to proportion in training samples What if there are insufficient samples to reserve 1/3 for testing? Ans: Cross validation

31 Copyright  2004 limsoon wong Cross Validation 2.Train3.Train4.Train5.Train1.Test Divide samples into k roughly equal parts Each part has similar proportion of samples from different classes Use each part to testing other parts Total up accuracy 2.Test3.Train4.Train5.Train1.Train2.Train3.Test4.Train5.Train1.Train2.Train3.Train4.Test5.Train1.Train2.Train3.Train4.Train5.Test1.Train

32 Copyright  2004 limsoon wong How Many Fold? If samples are divided into k parts, we call this k-fold cross validation Choose k so that –the k-fold cross validation accuracy does not change much from k-1 fold –each part within the k- fold cross validation has similar accuracy k = 5 or 10 are popular choices for k. Size of training set Accuracy

33 Copyright  2004 limsoon wong Bias-Variance Decomposition Suppose classifiers C j and C k were trained on different sets S j and S k of 1000 samples each Then C j and C k might have different accuracy What is the expected accuracy of a classifier C trained this way? Let Y = f(X) be what C is trying to predict The expected squared error at a test instance x, averaging over all such training samples, is E[f(x) – C(x)] 2 = E[C(x) – E[C(x)]] 2 + [E[C(x)] - f(x)] 2 variance bias

34 Copyright  2004 limsoon wong Bias-Variance Trade-Off In k-fold cross validation, –small k tends to under estimate accuracy (i.e., large bias downwards) –Large k has smaller bias, but can have high variance Size of training set Accuracy

35 Copyright  2004 limsoon wong Curse of Dimensionality

36 Copyright  2004 limsoon wong Recall... Given a test sample S Compute scores p(S), n(S) Predict S as negative if p(S) < t * n(s) Predict S as positive if p(S)  t * n(s) t is the decision threshold of the classifier …the abstract model of a classifier

37 Copyright  2004 limsoon wong K-Nearest Neighbour Classifier (k-NN) Given a sample S, find the k observations S i in the known data that are “closest” to it, and average their responses. Assume S is well approximated by its neighbours p(S) =  1 S i  N k (S)  D P n(S) =  1 S i  N k (S)  D N where N k (S) is the neighbourhood of S defined by the k nearest samples to it. Assume distance between samples is Euclidean distance for now

38 Copyright  2004 limsoon wong Curse of Dimensionality How much of each dimension is needed to cover a proportion r of total sample space? Calculate by e p (r) = r 1/p So, to cover 1% of a 15-D space, need 85% of each dimension!

39 Copyright  2004 limsoon wong Consequence of the Curse Suppose the number of samples given to us in the total sample space is fixed Let the dimension increase Then the distance of the k nearest neighbours of any point increases Then the k nearest neighbours are less and less useful for prediction, and can confuse the k-NN classifier

40 Copyright  2004 limsoon wong What is Feature Selection?

41 Copyright  2004 limsoon wong Tackling the Curse Given a sample space of p dimensions It is possible that some dimensions are irrelevant Need to find ways to separate those dimensions (aka features) that are relevant (aka signals) from those that are irrelevant (aka noise)

42 Copyright  2004 limsoon wong Signal Selection (Basic Idea) Choose a feature w/ low intra-class distance Choose a feature w/ high inter-class distance

43 Copyright  2004 limsoon wong Signal Selection (eg., t-statistics)

44 Copyright  2004 limsoon wong Self-fulfilling Oracle Construct artificial dataset with 100 samples, each with 100,000 randomly generated features and randomly assigned class labels select 20 features with the best t-statistics (or other methods) Evaluate accuracy by cross validation using only the 20 selected features The resultant estimated accuracy can be ~90% But the true accuracy should be 50%, as the data were derived randomly

45 Copyright  2004 limsoon wong What Went Wrong? The 20 features were selected from the whole dataset Information in the held-out testing samples has thus been “leaked” to the training process The correct way is to re-select the 20 features at each fold; better still, use a totally new set of samples for testing

46 Copyright  2004 limsoon wong A Popular classifier: C4.5 Based on the slides of Ozge Guler

47 Copyright  2004 limsoon wong What is C4.5?

48 Copyright  2004 limsoon wong What is C4.5? C4.5 was introduced by Quinlan for inducing classification models (viz. decision trees) from data C4.5 builds a decision tree using a top-down induction of decision trees approach, recursively partitioning the data into smaller subsets, based on the value of an attribute At each step in the construction of the decision tree, C4.5 selects the attribute that maximizes the information gain ratio

49 Copyright  2004 limsoon wong Rules of C4.5 Splitting rule: –A combination of information gain and gain ratio criteria –Select the maximum gain ratio split while maintaining a higher than average information gain

50 Copyright  2004 limsoon wong Rules of C4.5 Stopping rule: –Stop when node is pure –Stop when no more splits can be found Pruning rule –Pessimistic pruning –Default confidence limit is 25%

51 Copyright  2004 limsoon wong Golfing Example Given records on weather for playing golf Decides to play or not to play The non-goal attributes are: The goal attribute is:

52 Copyright  2004 limsoon wong Traning Data

53 Copyright  2004 limsoon wong Golfing Example In the decision tree each node corresponds to a non-goal attribute and each arc to a possible value of that attribute In the decision tree at each node should be associated the non-goal attribute which is most informative among the attributes not yet considered in the path from the root Entropy is used to measure how informative is a node

54 Copyright  2004 limsoon wong Entropy If we are given a probability distribution P = (p 1, p 2,.., p n ) then the Information conveyed by this distribution, also called the Entropy of P, is: I(P)=-(p 1 *log(p 1 )+p 2 *log(p 2 )+..+p n *log(p n ))

55 Copyright  2004 limsoon wong Information If a set T of records is partitioned into disjoint exhaustive classes C 1, C 2,.., C k on basis of value of the goal attribute, then info needed to identify the class of an element of T is Info(T) = I(P), where P is the probability distribution of the partition (C 1, C 2,.., C k ): P = (|C 1 |/|T|, |C 2 |/|T|,..., |C k |/|T|) In our golfing example, Info(T) = I(9/14, 5/14) = 0.94

56 Copyright  2004 limsoon wong Information of an attribute If we partition T on basis of value of a non-goal attribute X into sets T 1, T 2,.., T n then info needed to identify class of an element of T is weighted ave of info needed to identify the class of an element of T i, Info(X,T) = Σ(|T i |/|T|) * Info(T i ) In our golfing example, for attribute Outlook Info(Outlook,T)=5/14*I(2/5,3/5)+ 4/14*I(4/4,0)+ 5/14*I(3/5,2/5) = 0.694

57 Copyright  2004 limsoon wong Information Gain Consider the quantity Gain(X,T) defined as Gain(X,T) = Info(T) – Info(X,T) which is the diff betw info needed to identify an element of T and info needed to identify an element of T after value of attribute X has been obtained, i.e., this is the gain in information due to attribute X In our golfing example, for Outlook attribute Gain(Outlook,T) = Info(T) – Info(Outlook,T) =0.94 – 0.694 = 0.246

58 Copyright  2004 limsoon wong Information Gain If we instead consider the attribute Windy Info(Windy,T) = 0.892 Gain(Windy,T) = 0.94 – 0.892 = 0.048 So Outlook offers more info gain than Windy  Use this notion of gain to rank attributes and to build decision trees where at each node is located the attribute with greatest gain among the attributes not yet considered in the path from the root

59 Copyright  2004 limsoon wong Decision Tree

60 Copyright  2004 limsoon wong Using Gain Ratios The notion of Gain introduced earlier tends to favor attributes that have a large number of values. For example, if we have an attribute D that has a distinct value for each record, then Info(D,T) is 0, thus Gain(D,T) is maximal.

61 Copyright  2004 limsoon wong Using Gain Ratios To compensate for this Quinlan suggested using the following ratio: GainRatio(D,T) = Gain(D,T)/SplitInfo(D,T) where SplitInfo(D,T) is info due to split of T on basis of value of goal attribute D SplitInfo(D,T) = I(|T 1 |/|T|, |T 2 |/|T|,.., |T m |/|T|) where {T 1, T 2,.. T m } is the partition of T induced by value of D

62 Copyright  2004 limsoon wong Using Gain Ratios In our golfing example SplitInfo(Outlook,T)= – 5/14*log(5/14) – 4/14*log(4/14) – 5/14*log(5/14) = 1.577 GainRatio(Outlook, T) = 0.246/1.577 = 0.156

63 Copyright  2004 limsoon wong Deriving Rule Set It is easy to derive a rule set from a decision tree: –Write a rule for each path in the decision tree from the root to a leaf. –In that rule the left-hand side is easily built from the label of the nodes and the labels of the arcs.

64 Copyright  2004 limsoon wong Notes

65 Copyright  2004 limsoon wong References John A. Swets, “Measuring the accuracy of diagnostic systems”, Science 240:1285--1293, 1988 Trevor Hastie, Robert Tibshirani, Jerome Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Springer, 2001. Chapters 1, 7 Lance D. Miller et al., “Optimal gene expression analysis by microarrays”, Cancer Cell 2:353--361, 2002 Ross Quinlan, C4.5: Programming for Machine Learning, Morgan Kaufmann, 1993 Limsoon Wong, The Practical Bioinformatician, World Scientific, 2004


Download ppt "Copyright  2004 limsoon wong A Practical Introduction to Bioinformatics Limsoon Wong Institute for Infocomm Research Lecture 1, May 2004 For written notes."

Similar presentations


Ads by Google