# The Adverse Effects of Code Duplication in Machine Learning Models of   Code

**Authors:** Miltiadis Allamanis

arXiv: 1812.06469 · 2019-08-13

## TL;DR

This paper investigates how code duplication inflates the performance metrics of machine learning models for code, highlighting the need for de-duplication and providing tools and best practices to improve research accuracy.

## Contribution

It reveals the impact of code duplication on model evaluation, introduces a duplication index, and offers tools and guidelines to mitigate this issue in future studies.

## Key findings

- Performance metrics can be inflated by up to 100% due to code duplication.
- De-duplication leads to more realistic evaluation of models.
- Tools and best practices are provided to avoid duplication bias.

## Abstract

The field of big code relies on mining large corpora of code to perform some learning task. A significant threat to this approach has been recently identified by Lopes et al. (2017) who found a large amount of near-duplicate code on GitHub. However, the impact of code duplication has not been noticed by researchers devising machine learning models for source code. In this work, we explore the effects of code duplication on machine learning models showing that reported performance metrics are sometimes inflated by up to 100% when testing on duplicated code corpora compared to the performance on de-duplicated corpora which more accurately represent how machine learning models of code are used by software engineers. We present a duplication index for widely used datasets, list best practices for collecting code corpora and evaluating machine learning models on them. Finally, we release tools to help the community avoid this problem in future research.

## Full text

_Full body text omitted from this summary view._ Fetch the complete paper as Markdown: https://tomesphere.com/paper/1812.06469/full.md

## Figures

4 figures with captions in the complete paper: https://tomesphere.com/paper/1812.06469/full.md

## References

29 references — full list in the complete paper: https://tomesphere.com/paper/1812.06469/full.md

---
Source: https://tomesphere.com/paper/1812.06469