# K-Means Module Division Method of FDM3D Printer-Based Function-Behavior-Structure Mapping
## 4 FDM3D Printer Module Division
### Evaluation of FDM3D Printer Module Division Results  
Before DSM clustering, it was unclear whether dividing the FDM3D printer into multiple modules would be appropriate, so different K values were chosen to create four different division structures for the FDM3D printer modules. Evaluation indicators of cluster analysis were introduced to assess the effectiveness of the four-module division. The specific indicators are as follows:  
(1) The sum of squares due to error (SSE)  
The sum of squared errors of the distance from the samples in each K value corresponding to the cluster to the cluster center is calculated after selecting different K values, and the K value corresponding to a sudden slowdown in the rate of decline is theoretically considered to be the best K value, and the SSE formula is as follows:  
\[SSE=\sum_{i=1}^{k}\sum_{p\in C_{i}}^{m}|p-m_{i}| \tag{2}\]  
In the formula, \(C_{i}\) represents the ith cluster,\(p\) represents the object in the cluster, and \(m_{i}\) represents the cluster center of the ith cluster. (2) Silhouette Coefficient (SC)  
The contour coefficient is used to evaluate the clustering results and aims to compare the similarity of a sample to the cluster it is in with the similarity to other clusters. The contour coefficient ranges between (\(-1\) and \(1\)); the closer it is to \(1\), the better the clustering result, and vice versa. The contour coefficient is calculated by the following formula:  
\[S(i)=\frac{b(i)-a(i)}{\max\{a(i),b(i)\}} \tag{3}\]  
\begin{table}
\begin{tabular}{c c c c c c c c c c c c c c} \hline \hline  & \multicolumn{3}{c}{K = 3} & \multicolumn{3}{c}{K = 4} & \multicolumn{3}{c}{K = 5} & \multicolumn{3}{c}{K = 6} \\
**Module** & **Component** & **Number** & **Distance** & **Module** & **Component** & **Number** & **Distance** & **Module** & **Component** & **Number** & **Distance** & **Module** & **Component** & **Number** & **Distance** \\ \hline  & \begin{tabular}{c} Interior \\ \end{tabular}  & A & 0.605 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & A & 0.605 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & A & 0.605 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & A & 0.602 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & A & 0.602 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & A & 0.564 \\  & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & B & 0.681 & 1 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & B & 0.681 \\  & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & J & 0.633 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & J & 0.633 & \ \begin{tabular}{c} [PERSON] \\ \end{tabular}  & J & 0.613 & \begin{tabular}{c} [PERSON] \\ \end{tabular}  & N & 0.429 \\  
\[S=\frac{1}{n}{\sum_{i=1}^{n}{s(i)}} \tag{4}\]  
Formula: \(a_{(i)}\) represents the average distance from sample \(i\) to other samples in the same cluster, and \(b_{(i)}\) represents the average distance from sample \(i\) to other samples of the cluster, whichever is minimum. The SSE of DSM clustering is calculated for k = 2,3,...,10. The SSE results are shown in Figure 9, and the average contour coefficients of the four module partition results are shown in Figure 10.  
According to Figure 9, there is a noticeable inflection point in the cluster error variance at k = 3 when compared to k = 4, 5, and 6. Additionally, it is evident that the average profile coefficient value at k = 3 is the highest. The results of the delineation are mainly as follows: Module 1 contains the body, consumable support, power supply, hotbed, display, and control components, mainly reflecting the FDM 3D printer in the support, power supply, and control functions; Module 2 mainly includes mechanical drive system components such as moving parts, drive motors and limit switches; Module 3 includes nozzles, feeds, fans and other components related to consumables extrusion, and the color DSM of the module delineation results is shown in Figure 11. By coloring the nodes of the FBS model, the results of the block division are shown in Figure 12.  
Figure 10: Average profile coefficient (SC).