## 4 Machine Learning Algorithms  
### Principal Component Analysis (PCA)  
PCA is a data-driven feature-extraction method. High dimensional data could be efficiently compressed into low dimensional data with less information loss. Our magnetic dataset has a high number of features (e.g., 4480 features) which are the pixels of the magnetic image. Therefore, reducing the number of features before feeding to classification models is necessary. Suppose the dataset has a size of \(M\times N\); where \(M\) and \(N\) are the number of magnetic images and number of features, respectively. The dataset is then normalized to scale the features in a similar range, as described by Equations (5) and (6). The covariance matrix \(R\) is computed, as described in Equation (8), and its eigenvalues (\(\lambda=diag(S)\)) and eigenvectors (\(U,H\)) are obtained by the singular vector decomposition method, as described in Equation (8). The collection of eigenvectors is a new orthogonal space of the data. Thus, the projected data, which is the projection of the normalized data on these eigenvectors, are new feature data, as described in Equation (9). The number of new features is the same as the number of selected eigenvectors selected by eigenvalues. Usually, the eigenvalues are sorted in descent order for easier selection, and the high value of an eigenvalue represents a high value of data. The retained information of data could be estimated by the cumulative explained variance (\(E\)), as expressed by Equation (10). \[\mathbf{V_{m}}(i,j)=\mathbf{V}(i,j)-\frac{1}{M}\sum_{j=1}^{M}\mathbf{V}(i,j), \tag{5}\] \begin{table}
\begin{tabular}{l c c} \hline \hline \multirow{2}{*}{**Data Splitting Strategy**} & \multicolumn{3}{c}{**Training Dataset**} \\  & \multicolumn{2}{c}{**(The Remained Data Is in the Validation Dataset)**} \\ \cline{2-3}  & \multicolumn{2}{c}{_Amount of Data_} & \multicolumn{2}{c}{_Distinguished Volumes_} \\ \hline
**Mixing** & 80\% of data & 5 volumes selected from small to large with a step of 5 \\
**Increasing** & 10\%, 20\%, 30\%, 40\%, 50\%, 60\%, 70\%, 80\% of data & With respect to 2, 5, 7, 10, 12, 15, 17, 20 volumes increasing from small to large \\
**Shifting** & Fixed 20\% of data for all shifting ranges & Volume in a range: P1, P2, P3, P4, P5 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Dataset splitting strategy and its corresponding amount of data and distinguished volumes. Figure 6: Training/validation dataset split strategies based on corrosion volume to evaluate the performance of machine learning algorithms: selection of corrosion for training dataset with 20% data of the entire volumes (mixing), 20% corrosion shifting from low to high volumes (\(P_{i=15}\)), and increasing volumes from low to high (20–80%). with \(i=1:SN,j=1:M\). \[\mathbf{V}_{norm}(i,j)=\frac{\mathbf{V}_{m}(i,j)}{\varepsilon+\sqrt{\frac{1}{M}\sum_{j=1} ^{M}\mathbf{V}_{m}^{2}(i,j)}}, \tag{6}\]  
with \(i=1:SN,\;\;j=1:M;\;\varepsilon\) is a small number to prevent zero division. \[\mathbf{R}=\frac{1}{M}\mathbf{V}_{norm}^{T}\mathbf{V}_{norm} \tag{7}\]  
\[\mathbf{R}=\mathbf{U}\mathbf{S}\mathbf{H}^{T} \tag{8}\]  
\[\mathbf{z}_{k}=\mathbf{U}_{k}^{T}\mathbf{x}_{norm} \tag{9}\]  
with \(k\) is the \(k\)-th features selected by eigenvalue \(\lambda_{k}\). \[E=\frac{\sum_{k=1}^{K}\lambda_{k}}{\sum_{k=1}^{N}\lambda_{k}}\;\;\;\;\;\;\;\; \;\;\;\;\;\;\lambda=diag(\mathbf{S}). \tag{10}\]  
where \(i\) and \(j\) are the sensor element index and scan index, respectively; \(\mathbf{V}_{m}\) is the Hall voltage after mean subtraction; \(\mathbf{V}_{norm}\) is the normalized Hall voltage; \(\mathbf{R}\) is the covariance matrix of Hall voltage \(\mathbf{V}_{norm}\); \(\mathbf{U}\) and \(\mathbf{V}\) are left and right eigenvectors, respectively; \(\lambda_{k}\) is the \(k\)-th eigenvalue, \(\lambda=diag(\mathbf{S})\); \(\mathbf{z}_{k}\) is the projection of data on the \(k\)-th eigenvector; and \(\mathbf{E}\) is the cumulative explained variance. Figure 7 shows the distribution of data on the first three orthogonal vectors (three principal components).