## 3 Fault Diagnosis: Machine Learning-based Adaptive Neuro High-Order Variable Structure Observer
### Fault Diagnosis Using Support Vector Machine  
Based on Figure 1, after estimating the normal and abnormal signals using the ANHVSO technique and finding the residual signals, the decision-making ability can be introduced into the pipeline using a support vector machine (SVM) technique. A SVM has two main steps: a) residual signal characterization, and b) SVM-based fault detection and identification (FDI). The residual signals obtained for normal and abnormal conditions are utilized for the FDI of the robot manipulator. First, numerical attributes such as feature parameters are used for SVM-based FDI [20; 21; 22; 23; 24; 25]. Various types of features can be used. For this research, the energy of residual signals was selected. The value of the energy attribute can be computed as follows:  
\[E=\sum_{i=1}^{M}r_{xi}^{2} \tag{23}\]  
where \(E,\ M\) and \(r_{xi}\) are the energy of the residual signals in different  
where \(\rho(x_{i})^{T}\rho\left(x_{j}\right)=K\left(x_{i},x_{j}\right)\) is a nonlinear kernel function,  
\[\begin{array}{ll}min&\frac{1}{2}\sum_{i}\sum_{j}\alpha_{i}\alpha_{j}y_{i}y_{j }\rho(x_{i})^{T}\rho\left(x_{j}\right)-\sum_{i}\alpha_{i}\\ s.t.&\sum_{i}\alpha_{i}y_{i}=0\\ 0\leq\alpha_{i}\leq\varnothing&\forall i\end{array}. \tag{30}\]  
If \(y_{i}y_{j}K\left(x_{i},x_{j}\right)=h_{ij}\), (26) can be represented as follows:  
\[\begin{array}{ll}min\left(\frac{1}{2}\sum_{i}\sum_{j}\alpha_{i}\alpha_{j}h_{ ij}-\sum_{i}\alpha_{i}\right)=\frac{1}{2}\alpha^{T}H\alpha+f^{T}\alpha,&f= \left[\begin{array}{c}-1\\ -1\\ \vdots\\ -1\end{array}\right]\\ \\ \alpha=\left[\begin{array}{c}\alpha_{1}\\ \alpha_{2}\\ \vdots\\ \vdots\\ \alpha_{n}\end{array}\right]&H=\left[\begin{array}{ccc}h_{11}&\cdots&h_{1 n}\\ \vdots&\ddots&\vdots\\ h_{n1}&\cdots&h_{nn}\end{array}\right]=\left[h_{ij}\right]\\ \\ -\sum_{i}\alpha_{i}=\left[\begin{array}{cccc}-1&-1&\cdots&-1&\end{array}\right] \alpha\end{array}. \tag{31}\]  
Therefore, the dual problem can be represented by the quadratic programming problem defined in Equation (32):  
\[\begin{array}{ll}min&\frac{1}{2}\alpha^{T}H\alpha+f^{T}\alpha\\ s.t.&\sum_{i}\alpha_{i}y_{i}=0\\ 0\leq\alpha_{i}\leq\varnothing&\forall i\end{array}. \tag{32}\]  
After finding \(\alpha\), the Karush-Kuhn-Tucker (KKT) optimization algorithm is defined by the following equation:  
\[\begin{array}{ll}\alpha_{i}\left[y_{i}\left(\omega^{T}x_{i}+b\right)-y_{i}+ \delta_{i}\right]=0\\ \mu_{i}\delta_{i}=\left(\varnothing-\alpha_{i}\right)\delta_{i}=0\end{array}. \tag{33}\]  
Based on Equation (33), the KKT has various conditions. These conditions are represented by Equations (34)-(36). The non-support vector (NSV) is defined by the following equation:  
\[\begin{array}{ll}\alpha_{i}=0\rightarrow\mu_{i}=\varnothing\rightarrow \delta_{i}=0\\ \left[y_{i}\left(\omega^{T}x_{i}+b\right)-y_{i}\geq 0\right]\end{array}. \tag{34}\]  
The outlier can be defined as:  
\[\begin{array}{ll}\alpha_{i}=\varnothing\rightarrow\mu_{i}=0\rightarrow \delta_{i}\geq 0\\ \left[y_{i}\left(\omega^{T}x_{i}+b\right)-y_{i}+\delta_{i}=0\right]\end{array}. \tag{35}\]  
The support vector (SV) can be defined as:  
\[\begin{array}{ll}0<\alpha_{i}<\varnothing\to 0<\mu_{i}<\varnothing \rightarrow\delta_{i}=0\\ \left[y_{i}\left(\omega^{T}x_{i}+b\right)-y_{i}=0\right]\end{array}. \tag{36}\]  
Therefore, \(\omega\) and \(b\) can be defined based on the following equations, respectively:  
\[\omega=\sum_{i}\alpha_{i}y_{i}K(x_{i},x), \tag{37}\]  
\[b=\frac{1}{|S|}\sum_{i\in S}(y_{i}-\sum_{j}\alpha_{j}y_{j}K\left(x_{i},x_{j} \right)). \tag{38}\]Here, \(S\) are support vectors and are defined by the following equation:  
\[S=\{i|0\leq\alpha_{i}\leq\varnothing\}. \tag{39}\]  
The output based on the SVM leveraging soft margin and the kernel trick is defined as  
\[y=sign\left(\sum_{i}\alpha_{i}y_{i}K\big{(}x_{i},x_{j}\big{)}+b\right). \tag{40}\]  
In this research, the Gaussian technique is used to define the nonlinear kernel function.