# A Novel Intelligent Condition Monitoring Framework of Essential Service Water Pumps
## 2 Basic Theory  
### Unsupervised Anomaly Detection Algorithms  
One-class SVM (OCSVM) tries to find a hyperplane with a maximum margin by almost all positive training samples to separate negative samples as far as possible [25]. Due to the nonlinear separability of samples in ordinary space, samples are usually converted into linearly separable samples through projection functions \(\varphi\). The hyperplane can be expressed as  
\[f(x_{i})=w^{T}\varphi(x_{i})-b \tag{1}\]  
where \(w^{T}\) is a normal vector representing weight, \(b\) is offset, and \(f(x_{i})\) is the classifier's output under input \(x_{i}\). The optimization problem can be described as  
\[ \begin{split}\min_{w,b,\xi}&\Big{(}\|w\|_{2}^{2}+ \frac{1}{\upsilon m}\sum_{i=1}^{N}\xi_{i}-b\Big{)}\\ s.t.\big{(}w^{T}\varphi(x_{i})\big{)}\geq b-\xi_{i},\xi_{i}\geq 0,i=\{1,2,\ldots,N\}\end{split}  \tag{2}\]  
where \(v\in(0,1]\), and \(\xi_{i}\) is the slack variable that balances boundary positions and classification errors, making the model more flexible and robust when dealing with incomplete linearly separable data. To obtain the solution to the optimization problem, the dual problem is  
\[ \begin{split}\min_{\alpha}&\big{(}-0.5\alpha^{T} \alpha\big{)}\\ \sum_{i=1}^{N}\alpha_{i}&=1\\ s.t.0\leq\alpha_{i}&\leq\frac{1}{\upsilon m}\end{split}  \tag{3}\]  
where \(\alpha\) represents the Lagrange multiplier. After calculating the offset \(b\) and the weight \(w\), the state of the sample is determined by the relationship between the sample and the hyperplane. AKPCA has illustrated that reconstruction error (Squared Prediction Error, \(SPE\)) with the RBF kernel can detect a sample exceeding the healthy operating range and a sample that does not follow the training data model [8]. For training data \(X=\{x_{i}|i=\{1,2,\ldots,N\}\}\), the \(SPE\) is defined by the second-order norm of the difference between the centered kernel feature \(\widetilde{\Phi}\big{(}\widetilde{x_{j}}\big{)}\) and the reconstruction kernel feature \(\hat{\widetilde{\Phi}}\big{(}\widetilde{x_{j}}\big{)}\). \[SPE_{j}=\left\|\widetilde{\Phi}\big{(}\widetilde{x_{j}}\big{)}-\hat{\widetilde {\Phi}}\big{(}\widetilde{x_{j}}\big{)}\right\|_{2} \tag{4}\]  
The second-order norm can be calculated by kernel matrix \(K\) by  
\[\left\|\widetilde{\Phi}\big{(}\widetilde{x_{j}}\big{)}\right\|_{2}=1-2 \overline{K_{j}}+\overline{K} \tag{5}\]  
where \(K\) is composed of \(K_{i,j}=\Phi(x_{i})\Phi\big{(}x_{j}\big{)}\), \(\overline{K_{j}}\) represents the average value of the \(j-\)th row in \(K\), and \(\overline{K}\) represents the average value of all elements in \(K\). According to the relationship of the projection matrix and kernel principal components, \(SPE\) for KPCA can be written explicitly, as follows:  
\[SPE_{j}=1-2\overline{K_{j}}+\overline{K}-y_{j}^{T}y_{j} \tag{6}\]  
where \(y_{j}\) is the kernel principal component obtained from the eigenvectors and kernel matrix. The upper control limit is the \(95-\)th percentile of \(SPE_{j},j=\{1,2,\ldots,N\}\)[26]. To judge whether a sample is normal or abnormal, the \(SPE\) in the kernel space of the sample can be calculated and compared with the upper control \(SPE_{\text{limit}}\). When \(SPE_{j}>SPE_{\text{limit}}\), the \(j-\text{th}\) sample is abnormal, and vice versa. Isolation forest (ISF) is an anomaly detection algorithm that isolates observations by randomly partitioning the data using binary trees, efficiently identifying anomalies with low computational cost [27]. The root node contains all samples randomly selected from the training dataset \(X\) for each tree. There are internal and external nodes, and every internal node is split into two sub-nodes (left and right) until sample isolation is completed or the maximum tree depth is reached: \(d_{\text{max}}=\log_{2}(\phi)\) After building the ISF, the following is calculated:  
\[ \begin{split} H(n-1)=\ln(n-1)+0.57721564\\ c(n)=2(H(n-1)-(n-1)/n)\\ s\big{(}x_{j},n\big{)}=2^{-E(h(x_{j}))/c(n)}\end{split}