Jun Liua,
Ji Wang*bc,
Xiaopei Lia,
Hai Lina,
Tiancheng Liua,
Bingyan Zhoud and
Xiaoyong He*d
aDepartment of Information Science, Zhanjiang Preschool Education College, Zhanjiang 524084, Guangdong, China
bCollege of Electronic and Information Engineering, Guangdong Ocean University, Zhanjiang 524088, China. E-mail: wangji@gdou.edu.cn
cGuangdong Provincial Smart Ocean Sensing Network and Equipment Engineering Technology Research Center, Zhanjiang 524088, China
dSchool of Electrical Engineering and Intelligentization, Dongguan University of Technology, Dongguan, 523808, China. E-mail: hxy@dgut.edu.cn
First published on 16th January 2025
This work employs the femtosecond laser-ablation spark-induced breakdown spectroscopy (fs-LA-SIBS) technique for the quantitative analysis of magnesium alloy samples. It integrates four machine learning models: Random Forest (RF), Support Vector Machine (SVM), Partial Least Squares (PLS), and k-Nearest Neighbors (KNN) to evaluate their classification performance in identifying magnesium alloys. In regression tasks, the models aim to predict the content of four elements: manganese (Mn), aluminum (Al), zinc (Zn), and nickel (Ni) in the samples. For classification tasks, the models are trained to recognize different types of magnesium alloy samples. Performance evaluation is based on sensitivity, specificity, and accuracy. The results indicate that the RFR model performs optimally for regression tasks, while the Random Forest Classification (RFC) model outperforms other models in classification tasks. This work confirms the feasibility of quantitative analysis and identification of magnesium alloys using the fs-LA-SIBS technique combined with machine learning methods. It establishes a technical foundation for real-time monitoring of alloys in subsequent laser-induced breakdown spectroscopy (LIBS) instruments.
In fs-LIBS analysis, the duration of atomic emission generated by ablating samples with femtosecond lasers is usually shorter than that when using nanosecond lasers. This is a distinct disadvantage in spectral analysis as it directly leads to lower detection sensitivity of elements, especially for alloy element analysis. However, femtosecond lasers offer significant advantages in reducing background noise, improving spatial resolution, and minimizing matrix effects. Employing spark discharge to enhance the optical radiation of the plasma can significantly improve the sensitivity of spectral analysis. For terminological simplicity, this technique is termed femtosecond laser-ablation spark-induced breakdown spectroscopy (fs-LA-SIBS). The spark discharge LIBS (SD-LIBS) system combines high-voltage fast discharge circuits with traditional LIBS experimental setups.15–18 Due to the lower energy requirement of laser pulses, this method induces minimal damage to the sample surface. Furthermore, experiments have shown that under discharge conditions, the sample is ablated solely by the femtosecond laser. Therefore, the diameter of the craters on the sample surface is determined primarily by the characteristics of the femtosecond laser, including its focusing properties, pulse energy, and density. The discharge does not affect the crater diameter. This shows the biggest advantage of using femtosecond lasers as ablation sources is that they allow for high spatial resolution elemental analysis of micro-areas within the sample.19 These advantages make fs-LA-SIBS tech particularly effective for the quantitative analysis and identification of magnesium alloy samples. The aim of this work is to further optimize the performance of fs-LA-SIBS technique in magnesium alloy analysis by integrating machine learning methods, thereby achieving higher precision and reliability in the results.19
Machine learning methods applications in LIBS technique mainly include clustering, classification, and regression.20 Clustering, an unsupervised learning technique, forms multiple clusters with distinct centers solely based on the features of the data without the need for prior class labels.21 Classification, on the other hand, is a supervised learning method that involves learning patterns from sample data and class labels.22 Regression, also supervised, learns the relationship between continuous outcomes, forming patterns between the true values of spectra and sample results to provide predictive results.23 In machine learning clustering analysis, Dong et al. combined principal component analysis (PCA) with K-means clustering to classify coal. PCA reduces the dimensionality of the input LIBS spectral data to two principal components, aiming to describe data features with fewer variables. The accuracy of the K-means model based on PCA was found to be 92.59%. However, K-means relies heavily on distance calculation and cluster centers, making it challenging to establish complex separation boundaries between data categories due to its requirement for highly separated sample clusters.24 Yu et al. classified jade samples from five different locations using LIBS spectral data, employing methods such as partial least squares discriminant analysis (PLS-DA), pairwise PLS-DA, linear discriminant analysis (LDA), and support vector machine (SVM) models.25 The results indicated that the nature of the model itself, along with the selection of appropriate feature spectral lines based on weight differences, led to superior performance of the SVM model. The high accuracy demonstrated the suitability of LIBS technique for origin classification.
The Random Forest Regression (RFR) model can better uncover patterns in data, filtering out or discarding features with poor correlations, and using highly correlated data to build machine learning models, thereby improving model fitting and robustness. Li et al. proposed a new method that combines LIBS and RFR for the quantitative analysis of multiple elements in steel samples.26 This method utilizes normalized LIBS spectra to establish a calibration model by optimizing RFR parameters and comparing the performance of different input variables. The study results demonstrate the potential application value of integrating LIBS technique with RFR models for rapid in situ determination of multiple elements, particularly in the metallurgical field. Yang et al. utilized the RFR-LIBS model to measure the basicity of 30 sintered ore samples.27 They optimized the parameters of the RFR model, validated its prediction accuracy through a test set, and found that the RFR model outperformed the PLSR model. This technique shows promise as a method for real-time online rapid analysis in the mining industry. Liu et al. investigated the combination of LIBS with variable importance-based RFR (VI-RFR) for the quantitative analysis of toxic elements (Pb, Cr, and Hg) in plastic products.28 The results demonstrated that the LIBS-VI-RFR model exhibited superior performance in the quantification of Pb, Hg, and Cr in plastics, with lower root mean square error and higher correlation coefficients compared to other methods. Wang et al. proposed an RFR model combining LIBS and infrared spectroscopy (IR) data fusion for identifying different geographical regions of Radix Astragali. LIBS and IR spectra of 19 samples were collected and analyzed.29 The results showed that the predictive performance of the RF model based on data fusion surpassed that of individual LIBS or IR methods. Among them, the RF model based on intermediate-level data fusion exhibited the best performance, with high sensitivity, specificity, and accuracy.
This work introduces a rapid identification analysis method for magnesium alloys, based on standard magnesium alloy samples, employing the fs-LA-SIBS technique in combination with machine learning. Recognition models such as RF, SVM, PLS-DA, and KNN were established and compared for their effectiveness in processing fs-LA-SIBS data. Furthermore, the performance of these models was assessed through sensitivity, specificity, and accuracy metrics, discussing their potential applications in metallurgical analysis and identification.
The experiment analyzed standard magnesium alloy samples purchased from Aluminum Corporation of China Limited. Table 1 lists the concentrations of different elements in 5 different numbered standard samples. The element contents in the samples were determined using ICP-MS and AAS techniques, which are widely recognized for their accuracy and precision in trace element analysis. These techniques were calibrated and optimized specifically for the sample matrix to ensure reliable and reproducible results. Based on established literature and manufacturer specifications, the uncertainties associated with these measurements typically range from 2% to 10%, depending on the experimental conditions and sample characteristics. Among these 5 samples, particular attention was paid to the concentrations of aluminum (Al), manganese (Mn), nickel (Ni), and zinc (Zn). These spectral data were used for model training and calibration, with 70% randomly selected as the training set and the remaining 30% used as the test set. The training set was used for establishing the multivariate calibration model and optimizing model parameters, while the test set was used to verify the accuracy of the model's quantitative analysis results. Each sample collected 100 sets of fs-LA-SIBS spectral data, with each spectrum averaged 500 times by the fiber optic spectrometer and an integration time set to 10 ms. The spectral data covered a wavelength range from 200 nm to 500 nm, with each data set containing 5958 data points.
Sample no. | Concentration (%) | |||
---|---|---|---|---|
Mn | Al | Zn | Ni | |
1# (G301) | 0.082 | 3.04 | 1.21 | 0.0006 |
2# (G302) | 0.256 | 5.06 | 0.95 | 0.0047 |
3# (G303) | 0.374 | 6.97 | 0.71 | 0.0096 |
4# (G304) | 0.57 | 9.00 | 0.46 | 0.015 |
5# (G305) | 0.71 | 10.4 | 0.201 | 0.019 |
![]() | (1) |
![]() | (2) |
![]() | (3) |
TPR = TP/(TP + FN) | (4) |
TNR = TN/(TN + FP) | (5) |
Accuracy = (TP + TN)/(TP + TN + FP + FN) | (6) |
Occluded fs-LA-SIBS bands (nm) | Element | R2 | RMSE | MRE |
---|---|---|---|---|
200–500 | Mn | 0.978 | 0.021 | 0.022 |
Al | 0.775 | 10.023 | 21.081 | |
Zn | 0.663 | 1.354 | 0.044 | |
Ni | 0.976 | 0.676 | 1.629 | |
280–500 | Mn | 0.982 | 0.014 | 0.018 |
Al | 0.806 | 9.862 | 20.597 | |
Zn | 0.692 | 1.219 | 0.035 | |
Ni | 0.981 | 0.586 | 1.572 |
The analysis revealed that by reducing the wavelength range from 200–500 nm to 280–500 nm, the R2 values for all elements improved, indicating enhanced model prediction capability. Particularly for Mn and Ni, within the 280–500 nm wavelength range, the model demonstrated exceptionally high predictive accuracy, with R2 values approaching 1. This suggests that the shorter wavelength range better captures the characteristic information of these elements, thereby improving model accuracy.
Compared to Mn and Ni, the performance of the model for Al showed poorer performance in both wavelength ranges. Although there was an improvement in predictive accuracy after reducing the wavelength range, RMSE and MRE remained relatively high. While the predictive performance of Zn improved after reducing the wavelength range, there still exists a significant gap compared to Mn and Ni.
Although the numerical improvement is small, in the context of complex magnesium alloy spectral data, it shows that the selection of wavelength ranges influences the optimization of the performance of RFR model in predicting metal element content. These small improvements could have a significant impact in real-world applications, and greater performance gains will be realised in the future by incorporating additional techniques.
Optimizing the number of ntree and feature selection not only enhances the predictive performance of the RFR model but also improves its efficiency and applicability. As depicted in Fig. 4(a), the regression model for manganese achieved excellent performance at ntree = 500, mtry = 300, achieving high performance at a relatively low computational cost. In Fig. 4(b), the regression model for aluminum performed well at ntree = 200, mtry = 1000, demonstrating high performance with limited computational resources. In Fig. 4(c) and (d), the optimal configurations for the regression models of zinc and nickel were ntree = 500, mtry = 200, and ntree = 300, mtry = 2200, respectively, confirming that high predictive accuracy can be achieved under limited computational resources.
Table 3 presents the predictive performance of the RFR model for specific elements (Mn, Al, Zn, Ni) before and after optimization, including R2, RMSE, and MRE. Before optimization, the model already exhibited high predictive accuracy for Mn, with an R2 value of 0.977616. The predictive accuracy for Al was relatively low, with an R2 of only 0.774895. Zn showed high predictive performance similar to Mn, while Ni had the lowest predictive performance, with an R2 value of only 0.662897. After optimization, the predictive performance of all elements improved. The R2 value for Mn increased to 0.994041, with significantly reduced RMSE and MRE, indicating a significant improvement in Mn element predictive accuracy. The R2 of Al also increased, with slight reductions in RMSE and MRE compared to Mn. After optimization, Zn exhibited the best predictive performance, with an R2 value as high as 0.998904 and RMSE and MRE close to 0, indicating nearly perfect prediction. The performance of Ni also improved after optimization, with improvements in R2, RMSE, and MRE.
OOB error optimization | Element | R2 | RMSE | MRE |
---|---|---|---|---|
Before optimization | Mn | 0.978 | 0.021 | 0.022 |
Al | 0.775 | 10.023 | 21.081 | |
Zn | 0.976 | 1.354 | 0.044 | |
Ni | 0.663 | 0.676 | 1.629 | |
After optimization | Mn | 0.994 | 0.008 | 0.009 |
Al | 0.837 | 8.269 | 18.200 | |
Zn | 0.999 | 0.005 | 0.010 | |
Ni | 0.740 | 0.470 | 0.976 |
These results demonstrate the significant positive impact of OOB error optimization on the performance of the RFR model, particularly in reducing prediction errors. This renders the model more apt for predicting intricate datasets, particularly when handling elements with varying degrees of variability.
Table 4 displays the classification performance of the RFC model on different samples before and after optimization. Before optimization, both sensitivity and specificity for sample no. 1# were 1.000, indicating the model perfect prediction accuracy for this sample. However, the accuracy slightly fell below 1 (0.975) due to misclassifications in other sample categories. For sample no. 2#, sensitivity and specificity before optimization were 0.942, with an accuracy of 0.937, indicating good performance in identifying this sample but with room for improvement. Sample no. 3# exhibited lower sensitivity (0.578) before optimization, despite higher specificity (0.933), yet achieving an accuracy of 1, indicating high overall classification accuracy despite insufficient positive identification capability. This may suggest imbalanced class distribution in the classification problem or complete and accurate classification of samples in other categories. Sensitivity and specificity for sample no. 4# and 5# demonstrated excellent performance before optimization, with high accuracy, particularly achieving perfect accuracy for sample no. 5#. After optimization, sensitivity and specificity for all samples reached 1.000, indicating perfect performance in identifying positive and negative instances. Except for sample no. 4# with an accuracy of 0.754, all other samples achieved perfect accuracy of 1.000. The parameters adjusted during the optimisation process may not have a significant effect on sample no. 3#, but have a significant effect on other samples, resulting in the model not improving its accuracy relative to other samples in recognising that class of samples very significantly. Or perhaps the diversity of sample no. 3# in the training set is insufficient to cover all variants of the samples in this class, resulting in insufficient generalisation ability of the model.
OOB error optimization | Sample no. | Sensitivity | Specificity | Accuracy |
---|---|---|---|---|
Before optimization | 1# | 1.000 | 1.000 | 0.975 |
2# | 0.942 | 0.942 | 0.937 | |
3# | 0.578 | 0.933 | 1.000 | |
4# | 1.000 | 0.917 | 0.722 | |
5# | 0.964 | 0.964 | 1.000 | |
After optimization | 1# | 1.000 | 1.000 | 1.000 |
2# | 1.000 | 1.000 | 1.000 | |
3# | 0.667 | 1.000 | 1.000 | |
4# | 1.000 | 0.941 | 0.754 | |
5# | 1.000 | 1.000 | 1.000 |
Overall, the optimized RFC model exhibited significant performance improvements across most samples.
Fig. 6 presents the average accuracies of the four models after 100 independent tests. The results demonstrate that the RFC model achieves the highest average accuracy of 0.9498, confirming its outstanding performance in this task. In comparison, the SVM model has an average accuracy of 0.6551, PLS-DA model has 0.8327, and KNN model has 0.7170, all significantly lower than the RFC model. Therefore, the RFC model indisputably emerges as the preferred choice for magnesium alloy classification tasks. This finding not only provides valuable insights for alloy classification but also sets a precedent for the application of machine learning in materials science. The work further underscores the practicality and reliability of the RFC model, offering strong support for future industrial production and materials research endeavors.
This journal is © The Royal Society of Chemistry 2025 |