# K-Means++ Clustering Algorithm in Categorization of Glass Cultural Relics
## 3 K-Means++ Subclass Classification  
### Prediction of the Chemical Composition Content before Weathering on Weathered Samples  
The weathering of glass products will lead to significant changes in their composition, so it is necessary to predict the composition content before weathering based on the weathering point detection data. We chose to use the similarity between glass products to predict the chemical composition of specific glass products when they are not weathered.  
Because the present compositions of weathered data deviate from their original compositions, we cannot compare the similarities using given chemical compositions directly. As an alternative, we chose to conduct a principal component analysis first, using only unweathered data so that the unimportant compositions would be eliminated. Second, we applied PCA to weathered data, and the principal components (PCs) obtained in this way would be irrelevant to the weathering degree.  
First, the original data were tested for validity, and only unweathered samples were selected, from which we had 35 data points [13; 14; 15]. The 14 chemical content compositions of these data were taken into PCA. The percentage of variance explained by each orthogonal index was analyzed, and the first four items were [0.72766864 0.15677105 0.05843352 0.02400202], and the first three items were taken as new PCs (for explained variance greater than 0.05), which were noted as PC\({}_{1}\), PC\({}_{2}\), and PC\({}_{3}\).  
PCA process:  
* Use 35 unweathered samples, with 14 chemical compositions, as matrix X (35 \(\times\) 14).
* Calculate the eigenvalue decomposition: X\({}^{\mathrm{T}}\)X = QZQ\({}^{\mathrm{T}}\).
* Choose the largest 3 eigenvalues and their eigenvectors, form matrix P (14 \(\times\) 3).
* Calculate PCs for unweathered data: Y = XP.
* Use 32 unweathered samples, with 14 chemical compositions, as matrix X1 (32 \(\times\) 14).
* Calculate PCs for weathered data: Y\({}_{1}\) = X\({}_{1}\)P.  
After that, this PCA model was applied to calculate the PCs of the weathered samples. The PC matrix obtained in this way is significantly less related to weathering because when constructing the model, no factors related to weathering are introduced, and when using the model to calculate the factor values of weathered samples, it is equivalent to making it as reductive as possible for the unweathered samples, in line with the prediction requirements.  
For the definition of similarity, we used the Euclidean distance to measure the similarity. Due to the large number of chemical components and the fact that some components are impurities, we first used the principal component analysis to perform the dimensionality reduction of the chemical content, which also ensured that some impurities in the glass products (such as strontium oxide, which is less than 0.01 in all glasses) can be ignored sufficiently as to not affect the subsequent prediction results [16; 17; 18].  
Based on the above definition of \"relevance\" and comparative analysis, the three PCs were used as indicators of similarity for prediction, as follows: similarity of glass products a and b,  
\[\mathrm{Similarity}_{\mathrm{a,b}}=\sqrt{\left(\mathrm{PC_{1a}-PC_{1b}} \right)^{2}+\left(\mathrm{PC_{2a}-PC_{2b}}\right)^{2}+\left(\mathrm{PC_{3a}-PC _{3b}}\right)^{2}}, \tag{1}\]  
For all weathered points, the n points that were most similar to them were taken, and the content prediction of this point was obtained by taking the similarity between the n points and this point as the weight and weighting the average of the chemical composition content of the n points. For the selection of n, we tried = 3, 4, 5, and found that the difference between the predicted values was less than 5%. Thus, the three cases could be regarded as equivalent within the error tolerance, and the prediction results were obtained by taking n = 4.