# TCCCD: Triplet-Based Cross-Language Code Clone Detection
## 5 Experiment Setup
### Metrics  
In our experiment, the Precision (P), Recall (R), and F-measure (F1) were used as the metrics to evaluate the effectiveness of code clone detection.  
True Positive (TP) is the count of correctly classifying positive class samples as positive. True Negative (TN) is the count of correctly classifying negative class samples as negative. False Positive (FP) is the count of incorrectly classifying negative class samples as positive. False Negative (FN) is the count of incorrectly classifying positive class samples as negative.  
**Precision** measures the proportion of correctly predicted positive samples by the classifier. It is calculated as the ratio of TPs to the sum of TPs and FPs. In code clone detection, precision represents the percentage of accurately detected clones among the samples that include both clones and non-clones. If \(T_{p}\) is a TP and \(F_{p}\) is an FP clone, Equation (5) for the Precision (\(P\)) is:  
\[P=\frac{T_{p}}{T_{p}+F_{p}}. \tag{5}\]  
**Recall** measures the proportion of actual positive samples that are correctly predicted as positive by an approach. In code clone detection, recall represents the percentage of detected clone code out of all actual clone code instances. If \(T_{p}\) is the number of detected TP clones and \(F_{n}\) is the number of detected FP clones, Equation (6) for the Recall (\(R\)) is:  
\[R=\frac{T_{p}}{T_{p}+F_{n}}. \tag{6}\]  
**The F-measure** (F1-score) is a comprehensive evaluation metric that takes into account both the precision and recall. If P represents precision and R represents recall, Equation (7) for the F-measure (\(F_{1}\)) is:  
\[F_{1}=\frac{2 PR}{P+R} \tag{7}\]  
In the context of code clone detection, the precision, recall, and F1-score serve as vital metrics for measurement. Precision indicates the accuracy of labeling genuine code  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Language** & **Code Snippets** & **Average Lines** & **Average Tokens** \\ \hline Java and Python & 18,836 & 104 & 686 \\ Python & 18,331 & 26 & 191 \\ C++ & 32,281 & 66 & 556 \\ C\# & 16,359 & 111 & 855 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Statistics for specific language code snippets.  
clone fragments, ensuring that the identified code segments indeed exhibit duplication and merit the attention of developers. This aids in keeping the development team focused on addressing real issues, without being distracted by false clone alerts. Recall measures the proportion of genuinely cloned code instances successfully detected by the model among all true clones. A low recall implies that the model may have missed numerous genuinely existing code clones, leaving these clones unattended and unaddressed. The F1-score strikes a balance between precision and recall while considering both FPs and FNs, providing a critical and versatile metric for comprehensive effectiveness evaluation.  
In the field of cross-language clone detection, ensuring high precision is of paramount importance. False positives are a particularly concerning issue as they can lead to developers spending a significant amount of time and effort examining and handling code that is not actually cloned. When balancing high precision against recall and the F1-score, we believe that high precision takes precedence, and a slight compromise in recall and the F1-score may be acceptable in the pursuit of achieving high precision.  
By computing these metrics, the effectiveness of a approach in clone detection tasks can be assessed. Higher values of the precision, recall, and F-measure indicate the better effectiveness of the approach.