# Deep Clustering of Student Code Strategies Using Multi-View Code Representation (CMVAE)
## 3 Methodology
### Deep Clustering  
In the deep clustering phase, CMVAE adopts a joint training approach, optimizing both reconstruction loss and clustering loss simultaneously. The initial clustering of the fused representations is carried out using the k-means algorithm. In the absence of labeled data, the silhouette score is used to identify the optimal number of clusters, which in turn determines the initial cluster centers. These initial cluster centers provide a reasonable starting point for subsequent clustering optimization.  
The next step involves using the Student's t-distribution to calculate the soft assignment probabilities for each data point with respect to the cluster centers. By adjusting the degrees of freedom of the distribution, the assignments can more effectively reflect the relative distance between the data points and the cluster centers. The calculation of the soft assignment probability of a data point relative to a cluster center is given by Equation (15):  
\[P(x_{i},c_{j})=\frac{1}{1+\|x_{i}-c_{j}\|^{2}/\sigma^{2}}, \tag{15}\]  
where \(\|x_{i}-c_{j}\|\) represents the Euclidean distance between the data point \(x_{i}\) and the cluster center \(c_{j}\), and \(\sigma^{2}\) is a scale parameter that controls the spread of the distribution.  
A reweighted target distribution is generated based on the soft assignment of probabilities to further optimize the clustering performance. The design of the target distribution aims to increase the contribution of high-confidence samples to the cluster centers while diminishing the influence of low-confidence samples. By amplifying the weight of high-confidence samples, the model emphasizes the data points that are more valuable for optimization. The calculation of the target distribution is shown in Equation (16):  
\[Q(x_{i},c_{j})=\frac{P(x_{i},c_{j})^{\alpha}}{\sum_{k}P(x_{i},c_{k})^{\alpha}}, \tag{16}\]  
where \(\alpha\) is a parameter that controls the sharpness of the distribution, increasing its focus on high-confidence points.  
Similar to DEC [21] and IDEC [22], the clustering loss is calculated as the Kullback-Leibler (KL) divergence between the soft assignment probabilities and the target distribution. By minimizing the difference between the soft assignment probability and the target distribution, the model gradually adjusts the position of the clustering centers during the iteration process to make it closer to the real clustering structure of the data and improve the clustering performance. The loss function is outlined in Equation (17):  
\[\mathcal{L}_{cluster}=\sum_{i}\sum_{j}Q(x_{i},c_{j})\log\frac{Q(x_{i},c_{j})}{ P(x_{i},c_{j})}, \tag{17}\]  
where \(P(x_{i},c_{j})\) is the soft assignment probability from the Student's t-distribution, and \(Q(x_{i},c_{j})\) is the target distribution.  
Throughout this process, the clustering module is optimized not only through the KL divergence but also by incorporating the reconstruction loss from the pre-training phase. This ensures that the model retains its ability to reconstruct the original data while simultaneously capturing code strategy features. As a result, the model can gradually approximate the true clustering structure. The overall joint loss function is computed as shown in Equation (18):  
\[\mathcal{L}_{total}=\lambda_{1}\mathcal{L}_{cluster}+\lambda_{2}\mathcal{L}_{ recon}, \tag{18}\]  
where \(\lambda_{1}\) and \(\lambda_{2}\) are balancing coefficients used to adjust the relative weights of the clustering optimization and reconstruction loss.  
As the joint optimization proceeds through multiple iterations, the cluster center positions are gradually adjusted, and the model converges to a stable state, ultimately producing the final clustering results.