Delos Santos, Venn P.

Python code similarity detection using abstract syntax tree with k-means algorithm / Venn P. Delos Santos, John Christian M. Gava, and Marc Christian D. Tumaneng - 166 leaves.

Undergraduate Thesis (BSCS) - Computer Science.

Includes bibliographical references.

This study presents a hybrid methodology for detecting source code similarity in Python programming language. Integrating Abstract Syntax Tree (AST) analysis for structural similarity evaluation, the SimHash algorithm for textual similarity assessment, and the K-Means clustering algorithm for grouping Python codes according to their similarity fea-tures. The evaluation of the source code similarity detection was thoroughly conducted us-ing a dataset of student-submitted Python code, focusing on the detection of prevalent types of source code changes employed to conceal plagiarism attempts. With 28,701 pairwise comparisons across non-plagiarized and plagiarized code files, the model achieved an ac-curacy of 83%, with a high precision of 100%, a recall of 83%, and a 91% F-Measure. Ad-ditionally, the similarity detection process underwent a comprehensive assessment through test cases involving different degrees of source code transformation, demonstrating the model's robustness in identifying plagiarism across varying levels of structural and textual code transformations. Moreover, the K-Means algorithm exhibited high performance in grouping codes effectively, with optimal cohesion and separation validated using evalua-tion metrics such as the elbow method and silhouette score. Furthermore, a web application prototype was developed using Streamlit to operationalize the methodology. The applica-tion is user-friendly and provides an accessible platform where users can register, log in, and utilize the toolkit for source code similarity detection. The findings of the study under-score the effectiveness of integrating Abstract Syntax Tree (AST) analysis with a text-based approach, combined with the K-Means algorithm, as a scalable and comprehensive method for detecting source code similarity in Python programs.