Data augmentation of Python code refactoring datasets based on LLMs

Refactoring is a crucial software engineering practice aimed at improving code quality, yet automatically detecting and predicting refactoring activities remains difficult due to the limited availability of labeled data. This study examines how data augmentation can strengthen refactoring detection models. We experimented with 4 augmentation methods, namely Back Translation from textual description, Back Translation from Java, Generating Python code from existing comments, and Generating Python code from generated comments, and applied each of them using 4 large language models, specifically Gemini, GPT-4o, DeepSeek, and GPT-5-Nano. Through these combinations, we generated new instances of paired pre-refactor and post-refactor functions derived directly from the original ground truth pairs. We compute embedding-based cosine similarities between original functions, refactored functions, and their generated counterparts to evaluate semantic fidelity and proximity. We also validate and balance the resulting dataset to ensure it remains suitable for downstream machine learning tasks. Our findings suggest that many augmented samples remain semantically aligned with the original functions while adding diversity that improves robustness, reduces overfitting, and enhances generalization in automated refactoring detection.

Authors

Institutions

Publication Details

Journal
Journal of Systems and Software
Published
2026-06-18
DOI
https://doi.org/10.1016/j.jss.2026.113009
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Data augmentation of Python code refactoring datasets based on LLMs

V. MOLDOVAN, Simona Motogna, Rares Patcas
Journal of Systems and Software
Software Engineering Research
article

Data augmentation of Python code refactoring datasets based on LLMs

V. MOLDOVAN, Simona Motogna, Rares Patcas
article en

Abstract

Refactoring is a crucial software engineering practice aimed at improving code quality, yet automatically detecting and predicting refactoring activities remains difficult due to the limited availability of labeled data. This study examines how data augmentation can strengthen refactoring detection models. We experimented with 4 augmentation methods, namely Back Translation from textual description, Back Translation from Java, Generating Python code from existing comments, and Generating Python code from generated comments, and applied each of them using 4 large language models, specifically Gemini, GPT-4o, DeepSeek, and GPT-5-Nano. Through these combinations, we generated new instances of paired pre-refactor and post-refactor functions derived directly from the original ground truth pairs. We compute embedding-based cosine similarities between original functions, refactored functions, and their generated counterparts to evaluate semantic fidelity and proximity. We also validate and balance the resulting dataset to ensure it remains suitable for downstream machine learning tasks. Our findings suggest that many augmented samples remain semantically aligned with the original functions while adding diversity that improves robustness, reduces overfitting, and enhances generalization in automated refactoring detection.

Journal of Systems and SoftwareVol. 241
Babeș-Bolyai University (RO)
Openalex Percentile: Top 2%
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.