# Fault Diagnosis of a Reconfigurable Crawling-Rolling Robot Based on Support Vector Machines
## 4 Support Vector Machine (SVM)  
Once the statistical features are extracted from the IMU data, the next step is to use the features to generate a classification strategy for the data. Support Vector Machines (SVM) are viewed as one of the most accurate classification algorithms used in a supervised learning method of machine learning. In this paper, we used SVM to implement a fault diagnosis algorithm. An MATLAB-based program was developed using the Library of SVM (LIBSVM) package to implement SVM. LIBSVM requires the user to test the training vectors and training labels before the classifier is used to classify the test data. To obtain the training and testing dataset, the set of features obtained from the last few cycles is used as testing data, while the remaining data is used as training data. In addition, we also created a training label that indicates the true class of the training data in the same sequence. The flowchart in Figure 4 shows our fault classification process. The goal of a support vector machine is to determine a hyperplane that separates data from two different classes. Figure 5 presents the standard support vector machine classifier. There can be multiple correct solutions for a single classification problem. An optimal solution for a classification problem using SVM is a hyperplane that separates the data from two different classes without error. This hyperplane must also have a maximum separation margin, from the closest training data, for each class. Such a hyperplane is called a maximum-margin hyperplane. This maximum separation margin between the two classes will ensure that the generalization error, when evaluated via testing data, is minimal, which in turn provides the classifier with improved accuracy. The training data may be linearly separable, or they could also be nonlinear. To make the classification easier and to minimize error, the training data is mapped into a higher dimensional space, where then the hyperplane is constructed in the higher dimensional space. To build an optimal separating hyperplane, two parallel hyperplanes are constructed, which will separate the training data of two classes. These two parallel hyperplanes are called bounding planes. The area between the two hyperplanes is called a margin. The final separating hyperplane should lie in the margin area, i.e., the area between the two parallel hyperplanes. The two parallel hyperplanes will contain some training data points lying on them, and these training data points, which are called support vectors, will be useful in constructing the final separating hyperplane. Figure 4: Flowchart representing the fault diagnostic procedure. Measurement Unit (IMU): Inertial Measurement Unit; Support Vector Machine (SVM): Support Vector Machine. Let us consider a two-class classification problem. We consider a set of training data in the following format:  
* (x\({}_{i}\), y\({}_{i}\))  
where i = 1,2,....n. n is the number of samples. x\({}_{i}\) is the training data set, and y\({}_{i}\) is the label for the ith training data. x\({}_{i}\)\(\in\) R\({}^{n}\) and y\({}_{i}\)\(\in\) {+1, -1}  
The space between the two bounding planes is called a margin, and it is estimated to be \(\frac{2}{||W||}\). The SVM constructs a hyperplane that separates the two classes into +1 and \(-1\). The equation of the hyperplane is characterized by  
\[\mathrm{W}^{\mathrm{T}}\mathrm{x}+\mathrm{b}=0. \tag{8}\]  
The classification is done using the following strategy. X\({}_{i}\) belongs to class +1 if \(\mathrm{W}^{\mathrm{T}}\mathrm{x}+\mathrm{b}>\)0. X\({}_{i}\) belongs to class \(-1\) if \(\mathrm{W}^{\mathrm{T}}\mathrm{x}+\mathrm{b}<\)0. In addition to this, we can also check if the classification is valid by using the following constraints. A proper classification must satisfy  
\[\mathrm{y}(\mathrm{w}^{\mathrm{T}}\mathrm{x}+\mathrm{b})\geq 1. \tag{9}\]  
In this paper, we have used two types of SVM: C-Support Vector Classification (c-SVC) and v-Support Vector Classification (v-SVC).