Rapid and Nondestructive On-Site Classification Method for Consumer-Grade Plastics Based on Portable NIR Spectrometer and Machine Learning

*e classification of plastic waste before recycling is of great significance to achieve effective recycling. In order to achieve rapid, nondestructive, and on-site detection, a portable near-infrared spectrometer was used in this study to obtain the diffuse reflectance spectrum for both standard and commercial plastics made by ABS, PC, PE, PET, PP, PS, and PVC. After applying a series of pretreatments, the principal component analysis (PCA) was used to analyze the cluster trend. K-nearest neighbor (KNN), support vector machine (SVM), and back propagation neural network (BPNN) classification models were developed and evaluated, respectively. *e result showed that different plastics could be well separated in top three principal components space after pretreatment, and the classificationmodels performed excellent classification results and high generalization capability.*is study indicated that the portable NIR spectrometer, integrated with chemometrics, could achieve excellent performance and has great potential in the field of commercial plastic identification.


Introduction
Plastics are ubiquitous in all aspects of modern life. Global plastic production has grown from 2 million tons in 1950, when plastic was initially conducted to large-scale production and use, to 380 million tons in 2015, which has increased approximately 190 times [1,2]. e Ellen Mac-Arthur Foundation reported that plastic use had increased 20-fold over the past half-century and predicted that plastic production would double again in the next 20 years and nearly quadruple by 2050, leading to an increase in plasticrelated waste [3]. Nearly 50% of plastic produced is intended for single-use disposable products [4], such as packaging bags, water bottles, and disposable consumer goods. e widespread use of plastics brings great challenge related to the waste flow disposal. With plastic solid waste (PSW) growing at an annual rate of 7-8 per cent, the widely used methods of dealing with plastic waste are landfilling, composting, or burning, which are neither economical nor environmentally friendly [5]. Driven by the concept of circular economy, the efficient recycling of plastics and polymers has become an emerging need in the past few years.
Plastic waste can be recycled through various methods, such as thermal depolymerization and thermal compression. However, the first and major problem in plastics recycling is the identification and separation of different types of polymers prior to the recycling process. Otherwise, due to high temperatures and the effect of oxygen, the plastic will oxidatively degrade during mechanical recycling, changing its thermal stability and mechanical property and limiting its further use [6,7].
Conventional analytical techniques are widely used, among which chromatographic, thermal, and spectroscopic techniques are prominent. Spectroscopic methods, including infrared spectroscopy, ultraviolet-visible absorption spectroscopy, Raman spectroscopy, mass spectrometry, are regularly used to provide accurate information about the structure of the polymers and analyze the additives contained qualitatively and quantitatively. However, most of these methods require an immense amount of time and diverse careful sample pretreatment. Besides, they are either expensive or mostly applied in laboratory.
In recent years, China has started to popularize national garbage classification, which means sorting and recycling are not an activity only performed in factories. Individual plastic identification requires portable equipment, which generally results in decline of measurement accuracy. Hyperspectral imaging is one of the potential solutions, but it has difficulties in data storage and transmission due to the large data volume. Moreover, the imaging equipment is also too expensive to upgrade [8]. By contrast, near-infrared (NIR) spectroscopy is a viable option.
NIR analysis, one of the fastest growing analytical techniques in the world, has advantage in convenient, rapid, efficient, accurate, nondestructive, and environmentally friendly detection [4,9,10], already widely used in the plastic recycling workshops to reduce the time consumed by manual recognition. e wavelength of near-infrared spectrum ranges from 780 to 2526 nm, which is consistent with the absorption region of the combined frequency and multiple frequency of hydrogen-containing groups (O-H, N-H, and C-H) in organic molecules. Kaihara et al. [11] constructed a decision tree to classify 18 plastics based on NIR spectroscopy. Tachwali et al. [12] built a plastic bottle classification system based on NIR reflectance spectrum and Bayes rule. Martin De Biasio et al. [13] combined hyperspectral technology with chemometric analysis to identify PP and PE. Masoumi et al. [14] invented "two filter" methods to achieve a PSW sorting system based on hyperspectral technology.
In this study, a portable near-infrared spectrometer was applied to collect the spectral data for standard and commercial plastic samples, including ABS, PC, PE, PET, PP, PS, and PVC. PCA was used to assess the cluster trend, and K-nearest neighbor algorithm (KNN), support vector machine (SVM), and backpropagation neural network (BPNN) were applied separately to perform the identification between different plastics. e novelty of this paper is that it developed a reliable, rapid, and nondestructive sorting model for consumer plastic rather than standard samples, with only handheld equipment, compensating for its gaps in testing accuracy. Moreover, the targeted modeling method mentioned was extensible for continuously growing data, having the potential to be integrated with smart devices and cloud platform, to achieve intelligence and practical application of spectral on-site sorting.

Sample Preparation.
In this study, two types of plastic samples were chosen for classification. e first type was the standard plastic samples, including ABS, PC, PE, PET, PP, PS, and PVC, to conduct preliminary experiment and abandon unsuitable pretreatment. Considering the limitation of the NIR spectrum, dark plastic is difficult to identify due to its strong absorption capacity [5]. White    Journal of Spectroscopy and transparent samples were used for this study consequently. Each type of plastic included 30 samples with the same size, 30 mm by 30 mm by 3 mm. e second type was the consumer-grade plastic products in circulation, which is common in our daily life, but impossible to distinguish their raw material exteriorly. Specific sample information and the corresponding labels in this study are shown in Tables 1 and 2.

Spectral Acquisition.
In order to achieve on-site rapid detection, the Pynect NIR-S-G1 NIR handheld spectrometer was used in this study to obtain diffuse reflectance spectrum for two types of plastic samples. is spectrometer is highly integrated with the size of 82 mm * 65 mm * 42 mm with low pretreatment requirement for acquisition. Spectral data with a wavelength of 228 bands ranging from 900 nm to 1700 nm were measured. e spectrometer was fitted as closely as possible to each sample and scanned six times to output an average spectrum automatically. e same white background was used for all spectral measurements. e data acquisition was conducted without any pretreatment.
For the standard samples, each sample was scanned five times parallelly. 150 spectra were obtained for each type of plastic and 1800 spectra in total. For commercial products, the same operation was repeated. Limited by the shape of products, a contact location as close as possible for spectral scanning was selected. 200 spectra were obtained for each type of samples and 2000 spectra in total.  Figure 1(a) shows the raw spectra of transparent commercial samples.

Spectral Preprocessing Techniques.
Preprocessing for spectral data is an integral part of modeling, to remove background information and noise from the useful characteristics of the samples scanned [15,16]. Reproducibility of specific absorption features helps [17] to classify different polymers, and spectral pretreatment is an effective way to improve the repeatability of spectral features.

Journal of Spectroscopy
Considering the performance of the classification for standard samples, preprocessing methods used in this study included multiplicative scatter correction (MSC), standard normal variate transformation (SNV), first-order derivative, and Savitzky-Golay (SG) smoothing. MSC and SNV are commonly used to remove unwanted scattering effect from the spectral data matrix [15,18]. Derivative and SG smoothing can eliminate interference caused by baseline drift, resolve overlapping peaks, and improve resolution and sensitivity, but also introduce some errors. Figures 1(b)-1(d) show the spectra of transparent commercial samples preprocessed by MSC, SNV, and firstorder derivative methods. Considering the practical application scenario, the model was built with as little processing of the prediction data as possible, e.g., the MSC preprocessing was only performed for the calibration set.

Principle Component Analysis.
Principle component analysis (PCA) is an unsupervised pattern recognition method that clusters samples in the absence of a priori knowledge, extracting information from correlation matrix and visualizing data trends in dimensional scatterplots [19]. Transforming high-dimensional spectral data into an array of related variables containing overlapping information makes extracting useful information from high-dimensional data possible [20]. In addition, PCA is one of the manifold learning algorithms to reduce the dimensionality of spectral data [21].
In this study, PCA was applied to evaluate the cluster trend of spectral data and was also combined with other pretreatment methods to reduce the dimensionality. Figure 2 shows the performance of the MSC-PCA-KNN model with different numbers of principal components. e accuracy tended to stabilize with no significant improvement after the PC number exceeding 10, which was selected for the subsequent comparison of model performance. e same selection method was also applied to other pretreatment methods. [22], instance-based, lazy learning method. It works on a distance function, which classifies different features by measuring the distance between them. KNN has advantages of mathematical simpleness, not requiring statistical assumptions, and independence on the spatial distribution of the classes. When the training dataset is large, KNN requires a lot of storage space and time to calculate distance repeatedly [23].

Multivariate Analysis Methods. KNN is a nonparametric
SVM is a representative supervised statistical learning theory suitable for classification and regression problems, which can prevent underfitting and overfitting very well [24]. e algorithm has good classification performance on high-dimensional data though the number of training samples is limited [25]. If classes are separated by nonlinear boundaries, SVM uses kernel functions to enable linear separation of classes [18]. Radial basis function (RBF) was used in this study, for its computational simplicity and speed [23].
BPNN is one of the most commonly used algorithms for training feedforward neural networks [26]. BPNN has the characteristic of forward signal propagation and error backward propagation, which can automatically adjust the weights and biases in the architecture [27]. In this study, after multiple repeated experiments, BPNN had three hidden layers, with 128, 64, and 32 neurons, and the rectified linear unit (ReLU) function was used as the activation function. e output layer used softmax to output a probability matrix. e Adam optimization algorithm was used to calculate the gradient of the loss function in each epoch and update the parameters to minimize the loss function.

Data Partition and Model Evaluation.
e complete dataset was divided into calibration set (80%) and prediction set (20%). e calibration set, further divided into training and validation sets, was applied to train and evaluate the models with the same pretreatments, and the prediction set was applied to evaluate the generalization capability of the models. e prediction set was not involved in the modeling process to avoid data leakage. Cross-validation is one of the simplest and most commonly reproduced methods for estimating prediction accuracy [28]. To avoid the impact of random data partition, 10-fold cross-validation method was used for the calibration set, which was repeated 10 times to obtain average metrics. e model evaluation applied general evaluation metrics for multiclassification, including accuracy, precision, sensitivity, and F1-score. is study considered macroaverage and microaverage methods to calculate evaluation metrics. Averaged precision is defined as follows: where TP i and FP i refer to true-positive and false-positive values for single species of plastic, respectively, n class refers to number of categories, and n total refers to number of all samples.

2.7.
Software. All the spectral data processing and multivariate analysis algorithms were carried out using Python 3.7 and JetBrains PyCharm 2019.2.3 x64 software under Windows 10.

Principle Component Analysis (PCA).
e principal component score plots of the mixed dataset, transparent dataset, and white dataset with different pretreatments are given in Figures 3(a)-3(d).
e mixed sample datasets showed a faint clustering compared with other two datasets. Considering white or transparent samples separately, all the samples clustered well among top three PCs space after the spectral pretreatment. e MSC method gave excellent performance, with the cumulative variance contribution exceeding 99%, and different categories were clearly separated. In order to achieve better performance and expansibility for future applications, targeted modeling according to colors was adopted in the subsequent modeling process.

Model Comparison and Discussion
. KNN, SVM, and BPNN were applied for modeling. Figure 4 presents the confusion matrix of SVM model built for the transparent sample dataset. e observed values of the correct and incorrect classes of the prediction set could be visually obtained and can be used to calculate corresponding metrics. It could be seen that the misjudgment mainly occurs between PC and PET samples. Table 3 and 4 give the performance of the classification models developed for transparent samples and white samples. Compared with the standard samples, the number of PCs decreased significantly, indicating that after separating the datasets by color, the data of the same category were more consistent and fewer PCs could explain the difference.
For the transparent plastic samples using the MSC method, the accuracy of the prediction set was much lower than that of the calibration set, most likely because of the great difference between the raw prediction dataset and the preprocessed dataset for training.
As a lazy learning method, KNN needs to store all the training data, resulting in slower prediction process, more memory, and expensive overhead [29,30], which is not an optimal solution in practical application. Accordingly, for transparent samples, SNV-PCA-SVM and SNV/D1-PCA-BPNN were selected as the optimal models, and for white samples, D1-PCA-SVM was selected, both achieving 100% accuracy. Both SVM and BPNN can achieve high accuracy, and BPNN has the potential to outperform SVM dealing with large volumes of spectral data.

Conclusions
NIR spectroscopy has been considered as an effective method for the identification of PSW. is study has revealed that the handheld NIR spectrometer, rather than laboratory equipment, coupling with appropriate pretreatment and multivariate analysis methods, could be used to identify not only standard plastic samples but also consumer-grade plastics for field application. Targeted modeling of commercially available consumer products by color was carried out, and each optimal model chosen could give a 100% correct recognition rate in both the calibration set and prediction set, entirely meeting the requirement for field application. e methods of establishing, tuning, and evaluating different plastic classification models described in this paper are universally valid, and it is feasible for modeling the classification of consumer products according to different colors. Furthermore, the targeted modeling methods is extensible and plastic of other colors can be added easily, contributing to expand the range of application. In the future study, the models can be extended by following several aspects: addition of threshold criterion of additives in consumer products to identify plastics qualitatively and quantitatively and targeted modeling for roughness and transparency. Besides, considering the advantages of BPNN in large volume data modeling, portable spectrometer can be redeveloped to integrate with intelligent devices and build a spectral data cloud platform. Such platform can continuously optimize the model by collecting vast data in the process of large-scale application, contributing to achieve the miniaturization, automation, and intelligence of the rapid on-site spectral detection.

Data Availability
e spectral data used to support the findings of this study are available from the corresponding author upon request.