Bug Prediction Using Source Code Embedding Based on Doc2Vec

Abstract

Bug prediction is a resource demanding task that is hard to automate using static source code analysis. In many fields of computer science, machine learning has proven to be extremely useful in tasks like this, however, for it to work we need a way to use source code as input. We propose a simple, but meaningful representation for source code based on its abstract syntax tree and the Doc2Vec embedding algorithm. This representation maps the source code to a fixed length vector which can be used for various upstream tasks – one of which is bug prediction. We measured this approach’s validity by itself and its effectiveness compared to bug prediction based solely on code metrics. We also experimented on numerous machine learning approaches to check the connection between different embedding parameters with different machine learning models. Our results show that this representation provides meaningful information as it improves the bug prediction accuracy in most cases, and is always at least as good as only using code metrics as features.

Publication
Proceedings of the 21th International Conference on Computational Science and Its Applications (ICCSA 2021), Cagliari, Italy, Pages 382–397

BibTeX:

@InProceedings{AJF21,
    author    = {Aladics, Tamás and Jász, Judit and Ferenc, Rudolf},
    booktitle = {Proceedings of the 21th International Conference on Computational Science and Its Applications (ICCSA 2021)},
    title     = {Bug Prediction Using Source Code Embedding Based on Doc2Vec},
    year      = {2021},
    address   = {Cagliari, Italy},
    month     = sep,
    pages     = {382--397},
    publisher = {Springer International Publishing},
    doi       = {10.1007/978-3-030-87007-2_27},
    keywords  = {Source code embedding, Code metrics, Bug prediction, Java, Doc2Vec},
    url       = {https://link.springer.com/chapter/10.1007/978-3-030-87007-2_27},
}