## 3 LIBS Spectral Pretreatment
### Model Indicators  
(1) Evaluation indicator of clustering models  
The silhouette coefficient is an evaluation indicator for the clustering model. For each sample, the intra-cluster dissimilarity a(i) and the inter-cluster dissimilarity b(i) were calculated to obtain the average silhouette coefficient of the model. The intra-cluster dissimilarity refers to the average dissimilarity between the point and other points in the same group, and a smaller value indicates that the clustering is more reasonable. The inter-cluster dissimilarity refers to the average dissimilarity between the point and other points in different clusters, and a bigger value means that the clustering is more unreasonable. The average silhouette coefficients can be obtained by the calculation results of all points. The formula for calculating the silhouette coefficient of one sample is as Equation (2):  
\[S(i)=\frac{b(i)-a(i)}{\max\{a(i),b(i)\}} \tag{2}\] \begin{table}
\begin{tabular}{c c c} \hline \hline
**Item** & **Element** & **Peak Wavelength (nm) \({}^{*}\)** \\ \hline \multirow{4}{*}{Organic elements} & C & 247.86 (I) \({}^{**}\) \\  & H & 656.28 (I) \\  & N & 742.36 (I), 744.23 (I), 746.83 (I) \\ \hline \multirow{4}{*}{Inorganic elements} & Si & 250.69 (I), 251.61 (I), 251.92 (I), 252.41 (I), 252.85 (I), 288.16 (I), 390.55 (I) \\  & Al & 308.22 (I), 309.28 (I), 394.40 (I), 396.15 (I) \\  & Ca & 422.67 (I), 610.27 (I), 616.22 (I), 643.91 (I), 317.93 (II), 393.37 (II), 396.85 (II) \\  & Cr & 407.77 (I), 421.53 (I) \\  & K & 766.49 (I), 769.90 (I) \\  & Li & 670.78 (I) \\  & Mg & 285.21 (I), 279.55 (II), 280.27 (II) \\  & Na & 589.00 (I), 589.59(I) \\  & Ti & 498.17 (I), 499.11 (I), 499.95 (I), 500.72 (I), 308.80 (II), 323.45 (II), 323.66 (II), \\  & 323.90 (II), 334.90 (II), 336.12 (II), 337.28 (II), 338.12 (II) \\ \hline \multirow{2}{*}{Molecular spectra} & CN & 358.39, 358.59, 359.04, 385.09, 385.47, 386.19, 387.14, 388.34 \\  & C\({}_{2}\) & 516.32 \\ \hline \hline \end{tabular} \({}^{*}\) Data from NIST. \({}^{**}\) (I) represents atomic spectra and (II) denotes ion spectra.  
\end{table} 
Table 1: Characteristic peaks used in this article for classification and quantification. where \(S(i)\) close to 1 indicates that the cluster is reasonable; \(S(i)\) close to \(-1\) shows that the sample belongs to other clusters; and close to 0 means that the current sample is on the boundary of the two clusters. (2) Evaluation indicator of the classification models  
A confusion matrix can be used to evaluate the performance of the classification model. The results on the diagonal of the matrix are the number of correct results, and the other results are the number of incorrect results, as shown in Figure 4. On this condition, the accuracy can also be calculated according to the results of the confusion matrix in Equation (3):  
\[\text{Accuracy}=\frac{TP+TN}{TP+TN+FP+FN} \tag{3}\]  
where \(TP\) is the true positive result; \(FP\) is the false positive result; \(TN\) is the true negative result; and \(FN\) is the false negative result. (3) Evaluation indicators of quantification models  
The coefficient of determination (\(R^{2}\)) describes the fitting degree of the regression model. The closer the R\({}^{2}\) is to 1, the better the fitting degree of the model. The other indicator is the root mean square error (RMSE), which can describe the robustness of the model. The closer the RMSE is to 0, the better the stability of the model. For the model validation, the RMSE is the root mean square error of cross-validation (RMSECV), and for the model prediction, the RMSE is the root mean square error of prediction (RMSE). These two indicators are used to select the optimal parameters for the regression model. Thus, the model parameter with the largest R\({}^{2}\) and smallest RMSE should be determined to build the model.