# Electrocardiographic Fragmented Activity (II):
## 3 Materials and Methods
### Classifiers  
In this work, we used five different classifiers to evaluate the diagnostic capabilities of each of them to detect fragmentation or fibrosis. The implemented classifiers were SVM, MLP, KNN, DT and NB and all of these presented classifiers were developed and tested according to the recommendations in [18]. Before the explanation of each classifier, some shared mathematical concepts need to be summarized. First, our observations are defined in terms of their features, which are numeric values that shape the observations and they are labelled according to the class to which they belong. More, hereafter we work with binary problems. Therefore, from a mathematical point of view, our data set can be defined as  
\[\begin{split} S=\{\mathbf{x}_{i},  
where \(P(c)\) is the probability of a class, this value is a constant that can be computed as \(\frac{1}{\overline{classes}}\) or as the probability of the class in the training data and \(P(\mathbf{x}_{ij}|c)\) can be computed as a Gaussian function, according to  
\[P(\mathbf{x}_{ij}|c)=\frac{1}{\sqrt{2\pi\sigma_{c}^{2}}}e^{\frac{-(x_{ij}-\mu_{c})^ {2}}{2\sigma_{c}^{2}}} \tag{15}\]  
where \(\sigma_{c}^{2}\) is the variance of the \(i\)-th feature and it is computed using the training data, \(\mu_{c}^{2}\) is the mean of the \(j\)-th feature and it is computed using the training data and \(x_{ij}\) is the value of the \(j\)-th feature of test data. Finally, the decision rule can be written as  
\[C(\mathbf{x}_{i})=argmax(P(c_{k})\prod_{j=1}^{n}P(\mathbf{x}_{ij}|c) \tag{16}\]  
where \(P(c_{k})\) is the probability of the \(k\)-th class and \(\mathbf{x}_{ij}\) is the \(j\)-th feature from \(i\)-th observation. Another widely used classifier is the KNN [21], which belongs to the so-called lazy learning classifiers, as they do not use the whole training dataset, but instead the solution is only computed as a discriminative function from the closest subset of training observations to classify the test dataset. The classification process follows the next steps: First, the training dataset is mapped to features space; Second, when a new observation is classified, the KNN must compute the distance to every point in the plane; Finally, the classification is made taking into account the label of the k-nearest points in the plane. The distance definition could diverse, but the Euclidean distance is mostly used and it can be mathematically expressed as  
\[d(\mathbf{x}_{i},\mathbf{x}_{j})=\sqrt{\sum_{k=1}^{D}{(x_{ik}-x_{jk})^{2}}} \tag{17}\]  
where \(D\) is the number of dimension of observation \(\mathbf{x}\) and \(\mathbf{x}_{i}\) and \(\mathbf{x}_{j}\) are the points which their distance between which we need to know. Moreover, there is a collection of algorithms to label an observation according to their neighbors and one of the most used is the one using a polling among the \(k\)-nearest neighbors in order to label a new observation, this is,  
\[Vote_{\mathbf{x}_{i}}=\sum_{k=1}^{K}{\frac{1}{d(\mathbf{x}_{k},\mathbf{x}_{i})}}\alpha \tag{18}\]  
where \(Vote_{\mathbf{x}_{i}}\) is the voting value of the \(c\)-th class for \(\mathbf{x}_{i}\) observation, \(\mathbf{x}_{i}\) is the observation that we wanted to classify, \(x_{k}\) is the \(k\)-th nearest neighbour and \(\alpha\) is a constant that is 1 when \(x_{i}\) and \(x_{k}\) belong to the same class and zero otherwise. The final classification is performed by taking the label that reaches highest value of \(Vote_{\mathbf{x}_{i}}\). The DT are classifying algorithm that recursively split the input space [20]. DT are compounded by three different parts, namely, the root node (which has no inputs), the leaf nodes (which have one input and no outputs) and the internal nodes (which present one input and different outputs). Each internal node divides the input space into two or more semi-spaces according to a discrete function of the features.