scieee AI-readable full text Open interactive document viewer

ICHNAEA 2.0: un programari pel modelatge en microbiologia

Pérez Pérez, Aitor

Abstract

ICHNAEA 2.0 és un programari que fa servir diferents tècniques de Machine Learning per a donar solució a un problema en microbiologia anomenat MST (Microbial Source Tracking), determinant l'origen dels residus fecals presents en mostres d'aigua.

Full text

Facultat d’Informàtica de Barcelona ICHNAEA 2.0: a software for microbiology modelling Autor: Aitor Pérez Pérez Director: Lluís Belanche Muñoz Barcelona, January 24, 2014 Acknowledgements To begin with, I would like to express my gratitude to Lluís Belanche, the director of this project, for giving me the opportunity to work with him developing ICHNAEA and for assisting me every time I would reach a dead end. I want to thank also Anicet Blanch for providing the data we have worked with. More generally, this project culminates a long, hard, but also wonderful period of my life. I am very glad for having achieved this goal, but it would not have been possible without help, so I want to acknowledge every single person that has been part of it, from the FIB but also from the FME, teachers, friends or relatives. Contents 1 Introduction 7 1.1 Description ............................... 7 1.2 Motivation................................ 7 1.3 Goals................................... 7 1.4 Structure of the document . . . . . . . . . . . . . . . . . . . . . . . 8 2 MST problem and previous Machine Learning approaches 10 2.1 MSTproblem.............................. 10 2.2 MachineLearning............................ 10 2.3 ICHNAEA1.0.............................. 11 2.4 Incomplete ICHNAEA 1.5 . . . . . . . . . . . . . . . . . . . . . . . 12 3 ICHNAEA 2.0 13 3.1 Readingthedata ............................ 13 3.1.1 Preparingdata ......................... 13 3.1.2 Aging and dilution . . . . . . . . . . . . . . . . . . . . . . . 14 3.1.3 Processingdata......................... 14 3.2 Estimation of t∗and α∗......................... 15 3.2.1 Regression coefficients of variable aging . . . . . . . . . . . . 16 3.2.2 Obtaining t∗and α∗through systems of equations . . . . . . 18 3.2.3 Relaxing the assumption . . . . . . . . . . . . . . . . . . . . 21 3.3 Featureselection ............................ 24 3.3.1 Previousversion......................... 24 3.3.2 Accuracy and F-measure . . . . . . . . . . . . . . . . . . . . 25 3.3.3 Guiding the search . . . . . . . . . . . . . . . . . . . . . . . 26 3.3.4 Improving the solution . . . . . . . . . . . . . . . . . . . . . 27 3.4 Modelfamiliesused........................... 29 3.5 Predicting a new sample . . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.1 Reading the sample . . . . . . . . . . . . . . . . . . . . . . . 30 3.5.2 Aging and dilution . . . . . . . . . . . . . . . . . . . . . . . 31 3.5.3 Processing the sample . . . . . . . . . . . . . . . . . . . . . 31 3.5.4 Selecting the models . . . . . . . . . . . . . . . . . . . . . . 31 3.5.5 Combining the results of the models . . . . . . . . . . . . . 32 3.6 Megavalidation ............................. 34 5 4 Experiments 36 4.1 Useddata ................................ 36 4.1.1 Cyprusmatrix.......................... 36 4.1.2 Testsets............................. 38 4.2 Aging sections paradigm vs. No section paradigm . . . . . . . . . . 39 4.2.1 Description ........................... 39 4.2.2 Results.............................. 40 4.3 Parameter adjustment . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.3.1 Description ........................... 41 4.3.2 Results.............................. 43 4.4 Discussion................................ 48 5 Conclusions 50 5.1 Planification and cost . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.2 User’sguide............................... 51 5.3 Extensions and future work . . . . . . . . . . . . . . . . . . . . . . 52 5.4 Finalconclusions ............................ 53 A Appendix I: Results of Experiment #2 57 6 1 Introduction 1.1 Description This project develops a Machine Learning approach to the problem of Microbial Source Tracking (MST). Through this document we will explain it in detail, but the main purpose is to determine the origin (human or animal) of the fecal pollution in water bodies, given some data from several analyses, environmental or created in a laboratory. ICHNAEA 2.0 is born as a software to make predictions in this context and for assessing the experts on their decisions. The software is called 2.0 because it is built over a previous version developed by another student as his Master Thesis. However, this project aims to improve it, even if some important changes are involved. To do so, the work load of the project is divided into three sections. First, we have to analyse the existing software, identify its defects and suggest changes in order to improve it. Second, these changes have to be implemented. Finally, the new software has to be tested and we have to draw conclusions and see if the improvements have worked as expected. 1.2 Motivation The motivation of this project is naturally the improvement of the system, to get a useful software in order to contribute to the resolution of the MST problem. Particularly, the initial software had some lacks. There were many points in which a less restrictive assumption or a better algorithm could be used, and there were many others in which a whole different approach was needed. The temptation of changing it and see what we obtained was also an incentive to do it. Finally, this software becomes the proof of the fact that collaborating in a transversal project such as this one allows us to attain results otherwise unattainable, since microbiologists usually have no knowledge about Machine Learning and computer scientists rarely study anything related to the MST problem. This has also been a good reason to contribute with the project. 1.3 Goals This project aims to accomplish the following goals: 7 •Acquisition of new knowledge involving combination of prediction models •Analysis of the received software and the MST problem itself •Detection of drawbacks and improvement opportunities. Development, implementation and deployment of solutions for this problems. In particular, some were already detected: –Improvement of the estimation of the sample’s age and dilution degree –Development of an algorithm to replace the blind search in the feature selection process •Revision and testing of the software and extraction of the final conclusions about the performance of the system •Definition of the future work based on the conclusions •Improvement of the personal performance and knowledge of the statistical package R 1.4 Structure of the document The first section is this introduction, which tries to initiate the reader into the context of the project and its framework, such as the MST problem. In the next section, we will explain the problem of MST in more detail and give more information about the previous approach from which this project arises. We will specify the detected parts of the system to improve and give an introduction of how can we do it. In addition, we will devote a few lines to introduce Machine Learning. The third chapter will be the most extense, for it will explain the developed system in depth. Every detail of how the software works can be found here, starting at the moment that data is provided and going all the way through until a prediction is made, and beyond to the generation of synthetic testing samples. Then, the document moves to the experiments, the place where the system is tested and the effectiveness of the proposed changes is checked. This section will also help us adjusting some variables of the system, comparing the obtained results 8 among them. We will also detail the particularities of the data we have used for the experiments. And finally, the last section will expose the conclusions of the project. In addition to the technical ones, we will explain the planification of the project and its cost. Moreover, the chapter will also include a brief user’s guide, as well as an insight into the extensions and future work. 9 3.2.1 Regression coefficients of variable aging Professor Anicet Blanch has provided some observations about the evolution of each of the variables through time. These observations consist of different essays of several experiments where known samples were aged, taking measurements of the variables in a concrete season (summer/winter). Formally, we are given the following information: (ts j,k,l, vs j,k,l) Where the first component represents the time and the second one represents the value of the variable considering that: •s∈ {summer, winter}is the season to which the observation belongs •j= 1, . . . , N is the index of the variable we are measuring •k= 1, . . . , ns,j essays is the index of the essay inside the season sand variable j essay set •lis the index of the observation inside the kth essay of this set So, fixing a season sand a variable j, we have ns,j essays essays each of which has ns,j,k observations observations for different values of time. The intention of these observations is to provide a regression line time-value of the variable for each of them, and for each season. This line will be useful for estimating the aging time and the dilution degree of the new sample before predicting its class, as long as the following assumptions hold. Assumption. Fixed a season s, the logarithm of the value of the variable jis a linear function of time, for every j. log(vs j) = as jt+bs j, as j, bs j∈R Assumption. The new sample variables behave along time as the observed in the set of observations of the same season provided by Professor Anicet Blanch. Then, given the observations of the evolution of variables along time, we want to determine the slope as jof the line. To do this, we have just found a regression 16 coefficient for each of the essays via least squares and have averaged them into the final slope. Formally, if we define as j,k as the awhich, together with some b, minimize the following expression ns,j,k obs X l=1 (ats j,k,l +b−vs j,k,l)2 then the final as jreduces to as j=1 ns,j ess ns,j ess X k=1 as j,k This way we have converted the provided observations into regression coefficients for each season and variable. In the previous version of ICHNAEA, the regression coefficients were obtained slightly different, some sort of correction was done. To obtain as j,k, the intention was to substitute the intercept bwith the expression Bj= log(median(uj HM )), where uj HM is the vector of human observations of the variable jfrom the data matrix. Then, updating conveniently the values vs j,k,l,as j,k would be the aminimizing ns,j,k obs X l=1 (ats j,k,l +b+ (−b+Bj−vs j,k,l))2= ns,j,k obs X l=1 (ats j,k,l +Bj−vs j,k,l)2 To do this, though, a problem arises. We do not know beforehand the value of b, the intercept the regression line would have, so an estimation is used. Since all observations of all essays satisfy that ts j,k,1= 0, the value vs j,k,1is the value at zero time of the variable. Thus, the used value for as j,k is the athat, together with some bminimizes ns,j,k obs X l=1 (ats j,k,l +b+ (−vs j,k,1+Bj−vs j,k,l))2= ns,j,k obs X l=1 (ats j,k,l +Bj−vs j,k,l + (b−vs j,k,1))2 and we assume that the difference (b−vs j,k,1)will be small. One of the modifications we have introduced in this version of the software is the possibiblity to choose between applying this modification or not. The reason is that, while we do not have evidences of this correction improving the estimations, 17 the system used it. In the experiments, we will test this and will extract conclusions to know if it helps or not. 3.2.2 Obtaining t∗and α∗through systems of equations Once we have the regression coefficients for the variables, we can infer a linear system of equations which will allow us to obtain estimations for the aging time and dilution degree of the new sample. Let sbe the season in which the new sample has been collected, and let (v1, . . . , vN) be its observed values for each of the variables. Let αbe the dilution degree of the new sample, and tits aging time. Both values are unknown. Let (˜v1,...,˜vN)be the values of the variables of the new sample at 0time and without dilution, which are also unknown. Under the assumptions exposed before, we have: log(vj) = as jt+ log ˜vj α, j = 1, . . . , N From these Nequations, we do not know exactly N+ 2 values, corresponding to t,αand ˜vj, for j= 1, . . . , N, so the system is not determined. This dead end forces us to make an extra assumption. Assumption. The new sample variables behave along time as the observed in the subset of observation from the training matrix having the same season as the new sample. With this in mind, let nsbe the number of observations of the season sof the training matrix, and let uj i, i = 1, . . . , nsbe the observed value of the variable j for the ith observation of the subset of the training matrix in the season s, which is at zero time and undiluted. Next, for a fixed variable j, we simmulate how the aging process would be for these known observations generating nsparallel lines all with slope as jand intercept log uj i α. Now, taking the assumption into account, we suppose that the aging time of the new sample is the time at which the value of each line is equal to the observed value of the new sample. 18 Equivalently, what we do is intersect all the lines with the constant line at height log(vj)and so we get nsequations and only two unknowns, tand α. Basically, the equations are these log(vj) = as jt+ log uj i α!, i = 1, . . . , ns;j= 1, . . . , N ui log( ) vj log( ) j ui' log( ) j ui'' log( ) j ... α α α Figure 1: We draw lines with slope as jfrom the intercepts in the matrix and intersect them with the height log(vj) This linear system of equations has nsNequations and only 2 unknowns, so it is solvable when nsN= 2 and overdetermined for any training matrix we consider. The method we used to obtain the estimations, once we have the relations, substracts the equations of different pairs of variables of the same observation to vanish α. We do this in order to get an estimation of t∗first, and then use it to approximate the dilution degree. After this transformation, the system becomes this one log(vj1)−log(vj2) = (as j1−as j2)t+log uj1 i α!−log uj2 i α!, i = 1, . . . , ns; 1 ≤j1< j2≤N which simplifies to log vj1 vj2= (as j1−as j2)t+ log uj1 i uj2 i!, i = 1, . . . , ns; 1 ≤j1< j2≤N 19 (as j1−as j2)t= log vj1 vj2−log uj1 i uj2 i!, i = 1, . . . , ns; 1 ≤j1< j2≤N Now we can use the least squares method straightforward and get the estimation of the age, which we have called t∗, that minimizes the square error given the data. With it, going back to the initial equations allows us to do the same with α. In detail, the system we solve again by least squares is the following log(vj) = as jt∗+ log uj i α!, i = 1, . . . , ns;j= 1, . . . , N log(vjα) = as jt∗+ log(uj i), i = 1, . . . , ns;j= 1, . . . , N vjα=uj i10as jt∗, i = 1, . . . , ns;j= 1, . . . , N With these relations, we can already use the least squares method again, and thus obtain the estimation of the dilution degree α∗. Now we have all the needed information to proceed to the prediction of the new sample. As a summary, these algorithms show the entire process up to this point: A← ∅ B← ∅ foreach i∈ {1, . . . , ns}do foreach (j1, j2)∈ {(j, j0): 1 ≤j < j0≤N}do coef ←as j1−as j2 indep ←log vj1 vj2−log uj1 i uj2 i! A←append(A,coef) B←append(B,indep) end end t∗←solveLeastSquares(A,B) Algorithm 1: Estimation of the aging time 20 A← ∅ B← ∅ foreach i∈ {1, . . . , ns}do foreach j∈ {1, . . . , N}do coef ←vj indep ←uj i10as jt∗ A←append(A,coef) B←append(B,indep) end end α∗←solveLeastSquares(A,B) Algorithm 2: Estimation of the dilution degree By the way, it is to notice that the extra assumption added to reduce the unknowns is very strong. In particular, it assumes that we can use all the training matrix values as intercepts for regression lines having the given regression coeficients in order to estimate the age of a sample. Therefore, in the next section we explain its consequences in detail and consider relaxing this supposition and modifying the procedure to reduce the error introduced. 3.2.3 Relaxing the assumption As we said, the introduction of the last assumption in the process of estimating the age of a new sample also represents an additional source of error. To begin with, in the linear relation y= log uj i α!+as jt we can identify the intercept, which is log uj i α, and the slope, being as jt. The value of the variable ydepends on the value of t, as in any other linear map. When we use the equations log(vj) = log uj i α!+as jt∗ we set the value of the dependent variable to the observed value in the sample, and then find t∗. By doing this, we assume the following: 21 Assumption. The observed value in the sample, at zero time and undiluted, is the same value as the one in the matrix observation we used. u log( ) vj log( ) 0t* ... i j α Figure 2: We fix the the slope and the height at t∗. As we still can’t find t∗, we need to fix also the intercept Since we do this for every single observation in the matrix of the same season, and values can differ significantly between different observations, the estimation of t∗may be quite inexact. Even more if we use observations the class of which is different to the class of the new sample. A way of reducing this effect is to use only observations with its same class, provided that it is more feasible that samples of the same origin will have similar values for all the studied variables. However, this is not possible since we do not know the class of the new variable (predicting this is indeed what we want to estimate the aging time for). To illustrate this effect, let’s consider the following example. Let the training matrix be the following matrix: 22 CLASS V 11.03 ·106 11.12 ·106 17.99 ·105 19.79 ·105 11.42 ·106 29.63 ·106 21.09 ·107 21.08 ·107 29.93 ·106 21.02 ·107 and let the value of the sample and the slope be v= 4.82·104and a=−0.0242. These values, although synthetic, are quite representative of what we could expect to be inputted to the system. For simplicity, we suppose α= 1, so the equations are log(v) = log(ui) + at∗i= 1, ..., 10 log(4.82 ·104) = log(ui)−0.0242t∗i= 1, ..., 10 Solving this system with the method of least squares with all the observations in the matrix, we obtain an estimation of t∗= 75.77h. Nevertheless, if we use only the equations corresponding to observations of class 1, the result is t∗ 1= 55.31h, and if we do the same for class 2, the system yields a solution of t∗ 2= 96.24h. This means that if the sample was of class 1, the estimated time should be t∗ 1, and on the other hand, if the sample was of class 2, it should be t∗ 2. In particular, the estimation should not be t∗in any case, because it introduces an error of around 20h in both cases. However, this is the estimation we would take as valid with the previous method. We don’t know beforehand the class of the sample, but we can’t ignore what we just found. Alternatively, what we can do is to consider not only one but two estimations of t∗, one per class, find two predictions according to the found times, and decide which one we keep or how we combine them after all the process, under some criteria. 23 By doing this, we add a step of decision before outputting the final prediction for the sample, but in exchange we detect and try to avoid this problem, which can significantly modify the results of the system. 3.3 Feature selection Before the process of generation of the predicting models, a question arises. Which provided variables should be used? If we generate models with very few variables, we will probably get models of poor performance, due to underfitting. To increase performance, we can try to add some more variables, but if we get too far and our models use a number of variables, we can end up in a situation where we are not able to predict some samples because they do not provide all of the needed variables. In addition, we can also be overfitting the data, and even with the samples we are able to predict the performance may not increase. Another approach would be generating every single model with every single combination of variables. With this classifier ensemble we would ensure the capability of prediction of all the new samples to arrive. However, the time consumed generating all these models grows with the factorial of the number of variables. This may be feasible for a very small number of variables, but it quickly becomes practically impossible. Furthermore, we would be generating a handful of irrelevant models. Imagine, for example, a situation in which three variables achieve the optimum classifier for most cases, and if we add other variables the only thing we get is overfitting. We would have (N−3)! models with a poor performance which almost never would be used, or that when used, would contribute just with randomness to the prediction. For all these reasons, the feature selection process has to be done very carefully. In this section we will explain how this process was handled in the previous version of the software, and the changes introduced in order to both find better models and reduce computing time in the section which represents the most time-consuming section in the whole system. 3.3.1 Previous version Before the changes were designed and implemented, the system performed what we could call a blind search. If the training dataset consisted of Nvariables, the system computed all the models of all the considered families which used 2, 3 or 24 4 variables. This was a reduced version of what we explained before, since it did not generate every single model but all the models using a number of variables in a given range. Obviously, this was quite time consuming. A full execution generating models corresponding to all aging sections would take five days. Therefore, finding an alternative to this method was one of the objectives already at the beginning. Nevertheless, the main problem was not the big time investment itself, but the fact that we were spending all this time without any guarantee about the models we were constructing. Instead, if we could find a way of guiding the search, the models we would obtain in the same time could be significantly better and so the efficiency of the system would improve. 3.3.2 Accuracy and F-measure In addition to changing the algorithm, we also wanted to make another modification to the construction of models. When comparing them, the previous version used their accuracy as a quality indicator. If we have this confusion matrix Real \Predicted ANIMAL HUMAN ANIMAL A B HUMAN C D accuracy is defined as the ratio A+D A+B+C+D. We wanted to try a second criterion to compare models: F-measure. This is defined with the notation of true/false positive/negative, which, considering the human class as positive, means that true positive is D, true negative is A, false positive is B and false negative is C. Let the precision be the proportion of human samples correctly predicted of all the samples predicted as human: P=D B+D, and the recall be the proportion of such samples of all the human samples: R=D C+D. Then, the F-measure is defined as the harmonic mean of these two values: F=1 1 P+1 R =2P R P+R. The F-measure for a confusion matrix is different, in general, to its accuracy. While the second is a symmetric indicator, the first tends to penalyze harder models making wrong predictions on the positive (human) class than models mistaking the negative (animal) class. Since we do not know how F-measure will affect to the system, we have preferred to maintain both criterions and setting which one to use prior to each execution. 25 Because of all this, a preprocess has to be done with the models. First, we extract the set of variables the new sample has supplied. Then, we drop all the models whose set of variables includes one that does not belong to the sample set. From the remaining models, we use only the mwith lower cross validation error. In our case, we have used the best 10, but, if necessary, we have increased this value not to be forced to break ties. At this point, we have reduced the bag of models from its previous size to a minimum of 0models and a maximum of m. If the bag of models is empty, it means that no model of the bag is able to make a prediction for the class of the sample, and thus the prediction we make must be random. One of the goals of the feature selection process is to reduce at a minimum the probability of this happening. On the other hand, if we still have models to predict, then the sample is inputted to them and each one delivers a prediction. 3.5.5 Combining the results of the models In this section we will show how we combine the predictions of all the models when a new sample arrives in order to get our final decision of which class we predict. At this point, for the new sample v, we already have a vector of predictions from each of the mmodels, (c1, . . . , cm), ci∈ {H, A} ∀i∈ {1, . . . , m},Hand A meaning human and animal, respectively. We also know the performance of each of the models in the training phase, given by the cross validation error and computed either with the accuracy criterion or with F-measure. So we have another vector (e1, . . . , em)with these errors. With this information, we have to output a final prediction and a final confidence in the prediction. If we do not use the error vector, we can combine the predictions by a majority vote rule. This is equivalent to vote as in a show of hands and select the most voted. This weighting system is very simple and assumes that all the models have a similar performance. The majority vote rule was the system used in previous versions of the software. We have developed two more weighting systems that take the errors into account, and have compared all three in the second experiment of next chapter. 32 In both new weighting systems we have defined a weight for each of the models, and these weights will measure the magnitude of their contribution to the final class. In the first one, the weighting by error, the weights are these: wi=1 m−1       1−ei m X j=1 ej       This way, we give more confidence to those models with less error, and viceversa. In the other weighting system, we use the squared error to define the weights: wi=1 m−1       1−e2 i m X j=1 e2 j       This method also relies more on the models with lower error. Using this weighting system we will give even more confidence to low error models than with the error weighting, and even less to the models with slightly higher error. This weighting system is introduced to enlarge the difference between models with close errors. In both weighting systems, the 1 m−1constant is added to make the weights sum one. This is not required but does not modify the decision of the weighting system. Having defined these weights, we just have to sum the weights of all the models supporting each class to get estimations of the posterior probability. P(H|v) = X i:ci=H wiP(A|v) = X i:ci=A wi The greater value of the two determines which is the selected class. However, in the estimation of the aging time and dilution degree, we decided to make two estimations instead of just one, the former assuming that the sample was from human origin, the latter assuming animal origin. At this point, then, we do not have two but four estimations of the posterior probability of each class: P(H|v, t∗ H, α∗ H)P(A|v, t∗ H, α∗ H)P(H|v, t∗ A, α∗ A)P(A|v, t∗ A, α∗ A) The final prediction is determined by the greater value among these four. If it 33 is the first or the third, human class is the final prediction. Else, animal class is outputted. Ties are broken randomly. 3.6 Megavalidation In order to perform a pseudo-independent validation for both the estimation of t∗ and α∗and, obviously, the prediction of the class, we have developed a method called Megavalidation. It uses the data contained in the input matrix to generate several randomly aged and diluted samples to feed the system, so it can produce an arbitrary number of them. The exact process goes as follows: Let nbe the number of rows of the input matrix, and V1, ..., VNthe Nvariables in it. Let also as 1, ..., as Nbe their associated aging regression coefficients for each season s. First, we take a uniformly random observation of the matrix, corresponding to the ith row. Then, we select a random subset of the variables, of size kgiven by a binomial distribution, with n= 5 and p= 0.7, having a minimum size of 2. In addition, we assure that at least one of these kvariables is "relevant", understanding this as belonging to a subset selected by the experts. We denote the selected variables with the indices j1, ..., jk Once we have the row and the kcolumns, we extract the instance data from the matrix. We also pick a random dilution degree α, age time tand season s, uniformly in some given ranges. This allows us to proceed with the aging of the instance: for each one of the variables, and using the regression coefficients according to the picked season, we update the values of the instance as follows, if we let (vj1, . . . , vjk)be the selected values of the sample: vj←10(log10(vj)+as jt)=vj10as jt, j ∈ {j1, . . . , jk} At this point, we also have to dilute the instance. This process takes place as: vj←vj α, j ∈ {j1, . . . , jk} Having these values computed, the only thing that remains is to append the randomly picked values and the class to the instance, only for verifying purposes, 34 not to be used in neither the estimation of the age or the dilution degree, nor the prediction of the class of the instance. Iterating this process, we can obtain as many validation samples as we require, and this fact is what the process Megavalidation is named after. 35 4 Experiments In this section we check the performance of the system under certain conditions, and try to adjust some of its parameters depending on the results we obtain. We have divided the tests in two blocks: the first one compares the aging sections paradigm with the no sections paradigm, the second one gathers a number of different executions with varying parameters, in order to decide whether they are relevant or not. Both blocks of experiments are explained right after an overview of the data we have used. Finally, all the results are discussed at the end of the section. 4.1 Used data 4.1.1 Cyprus matrix The data we have been working with for training the models is a matrix of observations collected in five different Europe geographic areas. We will refer to it as Cyprus matrix or Cyprus data, since it contains some samples from this country. Professor Anicet Blanch from the Microbiology Department in Barcelona University has supplied this data to us, and it is the result of an expensive project called TOFPSW (Tracking the origin of fecal pollution in surface water)[4]. The matrix contains exactly 103 training samples, and supply a total of 27 variables plus the class (the origin of the fecal pollution, specifying the type of animal, not only human/not human). However, not all of them have been used but a subset of 13, since the others have been proved to be unuseful for our purposes[5]. The following table shows all used variables with a short explanation of what they measure: 36 Type Label Description Single FC Enumeration of fecal coliforms FE Enumeration of fecal enterococci CL Enumeration of clostridia SOMCPH Enumeration of somatic coliphages FRNAPH Enumeration of F-specific RNA bacteriophages FRNAPH I % of genotype I of F-specific RNA bacteriophages FRNAPH II % of genotype II of F-specific RNA bacteriophages FRNAPH III % of genotype III of F-specific RNA bacteriophages FRNAPH IV % of genotype IV of F-specific RNA bacteriophages RYC2056 Enumeration of B. fragilis bacteriophages using the host strain RYC2056 GA17 Enumeration of B. fragilis bacteriophages using the new host strain B. thetaiotaomicron GA17 HBSA Y Enumeration of sorbitol-fermenting bifidobacteria HBSA T Enumeration of total bifidobacteria Derived FRNAPH I + FRNAPH IV Sum of the % of genotypes I and IV of F- specific RNA bacteriophages FRNAPH II + FRNAPH III Sum of the % of genotypes II and III of F- specific RNA bacteriophages SOMCPH/GA17 Ratio of the no. of somatic coliphages to that of the new host strain B. thetaiotaomicron GA17 FC/GA17 Ratio of the no. of fecal coliforms to that of the new host strain B. thetaiotaomicron GA17 FC/SOMCPH Ratio of the no. of fecal coliforms to that of coliphages FC/FE Ratio of the no. of fecal coliforms to that of enterococci SOMCPH/RYC2056 Ratio of the no. of somatic coliphages to that of phages on the host strain B. fragilis RYC2056 FC/RYC2056 Ratio of the no. of fecal coliforms to that of phages on the host strain B. fragilis RYC2056 HBSA Y/HBSA T Ratio of the no. of sorbitol-fermenting bifidobacteria to that of total bifidobacteria Figure 3: Used variables 37 4.1.2 Test sets The Cyprus matrix comes together with two testing sets. We will call them Cyprus1 and Cyprus2: •Cyprus1 consists of 15 observations and provides almost all the variables in the training matrix. It is an unaged and undiluted, so it should be an relatively easy challenge for the system. •Cyprus2 also contains 15 observations, but it provides only 3 variables for each of them: FC, SOMPCH and GA17. Since these samples are highly aged and diluted, this test set seems quite more difficult than Cyprus1. In addition to these two test sets, we have also been supplied a third one. It contains 50 environmental observations from three catalan locations (15 from Ridaura river, 32 from Abrera and 3 from Castell d’Aro), collected between 2004 and 2007. All 50 observations have a human source. The observations from Abrera provide 3 variables: FC, SOMCPH and GA17, while the ones from Ridaura provide, in addition of these 3, also RYC2056. Finally, all 3 observations from Castell d’Aro inform FC, SOMCPH, GA17 and HBSA T, and two of them include information from HBSA Y. For obvious reasons, we will refer to this test set as environmental. The main difficulty of this test set is the fact that its samples are also highly diluted and aged, because they are taken from an open environment like for example a river bank. Finally, as we have explained in the previous section, we are able to generate synthetic test sets in the Megavalidation process with an arbitrary size, using the Cyprus matrix as a starting point. For our purposes, we have fixed the size to 1000 observations, each of them providing between 2 and 5 variables, and randomly aged and diluted. With this test set we intend to massively check the performance of the software, to get an objective feedback but always keeping in mind that the samples we are testing do not come from real observations. 38 4.2 Aging sections paradigm vs. No section paradigm 4.2.1 Description The goal of this experiment is to decide whether it is worth it to spend the time of training more than one bag of models or not. With the aging sections approach, it is necessary to train a bag of models for each season and for each of the time sections, since the aging coefficients depend on the season. If we assume that this is not necessary, and use a unique model ensemble, we would divide the execution time, in our case, by a factor of 14 (since we have discretized time in 7 sections and are considering two seasons). To see if having generated all the model bags traduces into a results leap, we are going to predict the four test sets with both of the paradigms. To do so, it is necessary that no other differences exist in both executions. For this purpose, the following parameters will apply: •The criterion to compute the cross-validation error for each one of the models is the accuracy, as we have defined it: number of correct predictions number of predictions . •The modified forward search will run with a maximum size and a number of iterations of 5. •The correction in the process of computing the aging regression coefficients will be applied. •To combine the predictions of several classifiers, the method of majority vote will be used. With equal parameter settings, we guarantee that the differences in the obtained results will respond only to the way that samples to predict are handled. The first execution will bring it to an aged but undiluted state, and then deliver the sample to the corresponding section. The second execution, though, will both deage and concentrate the sample, bringing it to an estimation of what it would be like at the fresh point, and then supply it to the only model ensemble. Since we have four test sets, this simmulation will provide eight pieces of information, two for each of them, corresponding to the two executions. 39 4.2.2 Results First, we are going to give an efficiency insight into the generation of the models. We have built 14 model ensembles for the aging sections paradigm (we consider two seasons: winter and summer, and discretize the aging time in 7 sections), and only one for the no sections paradigm. Thus, the generation of the models for the first execution has taken 9 hours and 30 minutes, while the no sections paradigm’s executions has lasted only a 14th part of this time, approximately 45 minutes. Involving only the performance, the following table summarizes the results obtained in both executions. The first three sets are predicted exactly with the same precision by both approaches, while the Megavalidation set shows some minor differences. However, they are not relevant enough to take them into account. With the Cyprus first test we have obtained quite good results. Both executions have made only one error out of 15 samples. This means that both testing errors are 6,67%. Nevertheless, this set contained non-diluted and zero time samples from the laboratory, so good results were to expect. The results of the Cyprus second test set have been dramatically poor. The error of 66,67% corresponds to having predicted human class for all the 15 samples when only 5 were from this source. This test set shows a strong bias of the models towards predicting human class when samples are highly aged and/or diluted. This bias also materializes in the environmental test set, but in this case, since all samples have human origin, the error lowers to a 2%, only with one the prediction is wrong. As a consequence of this bias, both this error and the previous 66,67% are not reliable indicators of the performance of the software. 40 The only test set to show differences between the two paradigms is the Megavalidation test set, since it contains 1000 test samples. This is also the first test set in which not all the samples can be predicted, but they represent a small percentage of the total. With this test set, we can still recognise the bias effect that pushes models to predict human, but it is not so extreme as in the Cyprus 2 and the environmental test sets. The test error in both approaches is around 26%. Moreover, the number of human samples predicted incorrectly is quite small. This allows us to accept that the system is reliable when it predicts animal origin. The goal of this experiment was to compare, under the same configurations, the aging sections and the no sections paradigms. As we have seen, although the results are not of high quality, because of the detected bias towards human class, both approaches have obtained the same or very similar performances. The conclusion of this experiment is, thus, that the no sections paradigm can actually replace the aging sections paradigm. The performance is almost equal, but the execution time makes the difference. This reduced execution time allows us to move on to the next experiment, iterating the execution with several configurations of parameters to see which can contribute to get better results. 4.3 Parameter adjustment 4.3.1 Description Once we have compared the two paradigms in the previous experiment, we want to check some of the adjustable parameters to see which combinations yield the best results. Obviously, we do not intend to get a winner combination, since it would depend on the subjective expectations one would have from the system, but the goal is to discover which configurations to use in every case. Specifically, we will study a total of four parameters: •The criterion used to calculate the cross validation error of a model. In particular, we have used two. The first one is what we have defined as accuracy and the second one is the F-measure. As explained in the previous section, the accuracy uses the natural definition of the cross validation error, since it is number of correct predictions number of predictions . The F-measure, on the other hand, is a nonsymmetrical interpretation of the performance of a model. This means that 41 Again, the only parameter that makes the difference is the number of iterations. The bias is reduced by 11,49 percentage points on average. This effect, combined with the error reduction and the increase of predicted samples, makes the ratio #{animal samples predicted as human} #{all samples} drop from a 23,03% to a 18,26%. This proves that, although always present, the bias towards predicting human origin can be relaxed through the number of iterations in the models. 4.4 Discussion Once we have performed the experiments and studied the results, as well as their implications, we want to close this section giving a general overview about them, the system and its performance compared also to the previous versions of ICHNAEA. In experiment one, we have compared the aging sections paradigm versus the no sections paradigm, concluding that the first one, while using a lot more time to build the models, does not imply any improvement at all with respect to the second. 48 In addition, we have detected a bias in the models towards predicting human class in both paradigms. Experiment two has been more illustrative. In addition to confirm the results in experiment 1, it has also showed that from the four parameters adjusted, two of them are irrelevant: the weighting system (majority vote, error or squared error) and the error criterion (accuracy or F-measure). The number of iterations has been the most relevant parameter, for it has not only decreased the average error, but also has diminished the effect of the bias of the models substantially and has been able to predict the maximum number of samples. Finally, in relation to the correction applied to the aging regression coefficients, we have proved it to be useless. Even obtaining the same results with or without correction we would have considered it inappropriate for the system, but not only correction has not attained better results that raw regression coefficients, but they have been worse. In comparison to ICHNAEA 1.0, the main difference in results is the bias of the models towards human class. Analysing each test set individually, the Cyprus 1 has been predicted identically by both systems. The introduced bias has made the prediction of the Cyprus 2 test set worse but the prediction of the environmental test set better. Considering the Megavalidation test set, the massive test set with 1000 samples, the best achieved error with ICHNAEA 2.0 is of 20,90%, while the error with ICHNAEA 1.0 was of 19,19%. On the other hand, the big difference between both systems is related with execution time. To achieve the explained results, ICHNAEA 1.0 took 5 days approximately to generate the models, while ICHNAEA 2.0, with the combination of parameters that have yielded the lowest error, only takes 1 hour and 20 minutes for this purpose. Therefore, the execution time has been reduced by a factor of 90. 49 5 Conclusions 5.1 Planification and cost This project has been finished in approximately a year. The following Gantt chart shows the distribution of time for each one of the goals, as well as for the writing of this document: Although the progress of the project has not been strictly linear, because sometimes tasks would merge, the durations in the chart are a good indicator of the time spent for each one of them. As we see, the most time consuming tasks have been the implementation and deployment and the revision and testing of the software, and both could not be started before some other tasks. Specially, we want to remark the development of the solutions to fix the drawbacks of the software. In relation to the theoretical cost the project would have, we have divided the work in two blocks: tasks performed by an analyst and tasks performed by a developer. Basically, the first tasks in the chart would have been performed by the first, as well as the extraction of conclusions. In fact, we have considered only the implementation and deployment and the revision and testing tasks to be performed by a developer. Therefore, taking into account an estimation of the total hours invested on the project, about 350, we can make an estimation of the cost the project would have had: 50 Position Work load Hours Cost (EUR/hour) Cost(EUR) Analyst 45% 157,5 40 6.300 Developer 55% 192,5 30 5.775 Total 100% 350 12.075 Including also the computer maintenance, the electricity and other minor concepts, a total of 12.500 EUR becomes the final cost of the project. Note that we have not included the cost of any software, since all work has been done under Linux, R and other free platforms. 5.2 User’s guide The software has been developed with the statistical package R[8]. This is so because this project represents the continuation of a previous system, which was written in this language, and so we avoided rewriting the whole application from scratch. The software contains a total of 9 R scripts. Four of them are conceived for running them directly, the remaining five act as libraries, since they contain a number of calls or variables to be used. The following list details each one of them (* means executable): •constants.R: Contains some constants used all over the system. All configurable parameters can be modified here. •data_reader.R: Defines the functions needed to read any of the data from csv files. •data_processor.R: The functions provided here are used to logarithmize the data and to create the derived variables. •aging.R: Everything related to aging is in this file. From computing the linear regression coefficients of the aging process to the estimation of the age time. •models.R: Contains all the functions to generate the prediction models, as well as to perform the feature selection process. •megavalidation.R* : This file, when sourced, generates the synthetic test data named Megavalidation and stores it for later use. 51 •dataset_building.R* : This script loads the data matrix and computes the aging regression coefficients, and saves them as an Rdata object. •models_building.R* : The most time consuming script is this, since its task is to perform the feature selection process and generate the corresponding models. •testing.R* : This file loads one of the test sets and proceeds to make a prediction for each of its observations. Finally, it produces a summary of the results. The usage is very simple. First, the configuration parameters have to be set up in constants.R. Then, the data matrix has to be loaded sourcing dataset_building.R. This also generates the aging regression coefficients. After that, prediction models have to be generated by running models_building.R. Finally, to test them on any test set, just an execution of testing.R is needed. 5.3 Extensions and future work The conditions in which ICHNAEA is after the project are proper to add some new modifications to try to improve the system. Given the results of the experiments, we know that some of the applied changes are not necessary, as for example the correction in the aging coefficients or the use of F-measure to replace accuracy. On the other hand, we have proven some modifications to be worth it. The algorithm change in the feature selection process is an example. There are a few aspects yet to be improved. Here we explain some of them: •Bias of the models: As we have seen, models have presented certain bias towards predicting human class more often than animal class. This is a clear improvement point. •Design an analysis studying the performance of each model family separately. At the moment, all models are mixed and there may exist useless families that do not help on predicting at all. •Study the possibility of adding some new families of models, and check if they improve the global performance of the software. 52 •Improve the estimation of the dilution degree and the age time of a sample. An idea is to use, instead of a finite set of seasons (summer and winter in this case), the date of extraction of the sample, which is not expensive to measure, and is much more precise than the season. •Add to the system a 10-times 10-fold cross validation, since now it only uses 1-time 10-fold cross validation. It traduces roughly to executing each model 10 times and averaging the error to minimize the effect of randomness. •Convert the predictions of models from a unique value to a probability distribution, and then combine these probabilities in some smart way. As we can appreciate, far from ending at this point, this project can be extended as much as needed, always looking for better results adding profitable corrections or completely new paradigms. 5.4 Final conclusions To close the project, we are going to review the goals defined at the introduction and explain what has been done to accomplish them. In general, we can consider that we have satisfied almost all of them. •Acquisition of new knowledge involving combination of prediction models In particular, and in addition to the knowledge acquired in the Data Mining course, a specific book[1] about combining classifiers has been read, to get some ideas about the modifications that could have been done. •Analysis of the received software and the MST problem itself The Master Thesis where ICHNAEA 1.0 is explained has also been studied. In addition, diagrams of all the received software have been created. The differences between both systems have been detected. •Detection of drawbacks and improvement opportunities. Development, implementation and deployment of solutions for this problems. In particular, some were already detected: 53 –Improvement of the estimation of the sample’s age and dilution degree –Development of an algorithm to replace the blind search in the feature selection process In relation to the estimation of the age and dilution degree, two changes have been tested. The first one is to make two predictions and keep the one which yielded more confident results. The second is to eliminate the correction that was performed, and this has been proven effective in the second experiment. The algorithm replacement in feature selection has been a great success. The modified forward search algorithm has been developed, achieving a performance close to the prior and dividing the execution time by a factor of 90. Not only these changes have been made effective, as explained in section 3. A new paradigm has been used: we have moved from aging sections to no sections. The weighting system in the combination of the models has been extended to three: majority vote, error or squared error. Also the criterion to compute the performance of a model has been modified, since the F-measure has been introduced. Moreover, new model families have been added: Naive Bayes and Relevance Vector Machines. Finally, other minor changes have also been performed, such as removing the lower boundary for a variable when aging or diluting it. •Revision and testing of the software and extraction of the final conclusions about the performance of the system Once the software has been free of errors, two experiments have been designed and executed. Both experiments try to compare different configurations of the system. The first one confirms that using the aging sections approach results are not better than using no sections, even when its execution time is 14 times higher. The second experiment is more complex than the first, since we do not compare one value of a parameter against another, but compare 3 binary parameters and one ternary. So, a total of 96 executions had to be done. Moreover, the experiment does not only focus on the test error but also on other information as the number of predicted samples or the bias of the models. After having the experiment results, the discussion section in chapter 4 is devoted to analyse them deeply and draw specific conclusions. 54 •Definition of the future work based on the conclusions The previous section in this chapter gives an insight on this topic, explaining that much more can be done to improve the software, by proposing new techniques, testing them and concluding whether they are useful or not. •Improvement of the personal performance and knowledge of the statistical package R Finally, this goal is fully achieved, since all the implementation of the system has been done in R. In particular, some of the used packages have been ipred,class, kernlab and rvmbinary, and a lot of other core functions have been used. 55 References [1] Ludmila I. Kuncheva, Combining Pattern Classifiers, Methods and Algorithms. Wiley, 2004, ISBN: 9780471210788 [2] Hagedorn, Charles; Blanch, Anicet R.; Harwood, Valerie J., Microbial Source Tracking: Methods, Applications, and Case Studies. Springer Science & Business Media B.V., 2011, USA, ISBN: 9781441993854 [3] Sánchez-Mendoza, David, A Software system for the microbial source tracking problem. UPC, 2012, http://hdl.handle.net/2099.1/16066 [4] Blanch, A. R.; Belanche-Muñoz, L. B.; Bonjoch, X.; Ebdon, J.; Ganzer, C.; Lucena, F.; Ottoson, J.; Kourtis, C.; Iversen, A.; Kühn, I.; Mocé, L.; Muniesa, M.; Schwartzbrod, J.; Skraber, S.; Papageordiou, G.; Taylor, H.; Wallis, J.; Jofre, J., Tracking the origin of faecal pollution in surface water. An ongoing project within the European Union research programme. 913833 - Journal Of Water And Health, 2004, England, ISSN: 14778920 [5] Belanche-Muñoz,L. and Blanch,A.R., Machine learning methods for microbial source tracking. 909875 - Environmental Modelling & Software, 2008, England, ISSN: 13648152 [6] Ethem Alpaydin, Introduction to Machine Learning. MIT Press, 2004, ISBN: 9780262012119 [7] Trevor Hastie, Robert Tibshirani, Jerome Friedman, The Elements of Statistical Learning: Data Mining, Inference, and Prediction, Springer, 2001, ISBN: 9780387952840 [8] R Core Team, R: A Language and Environment for Statistical Computing R Foundation for Statistical Computing, Austria, 2013, http://www.R-project.org 56 A Appendix I: Results of Experiment #2 57