Git Product home page Git Product logo

detecting-if-inconsistencies's Introduction

Detecting IF-Inconsistencies

tl;dr I used an LSTM to classify if-condition-statement code blocks as consistent/inconsistent (think erroneous).

Using a provided codebase, I parsed the code into an abstract syntax tree (AST), extracted if-condition-statements, and transformed them into a dataset. Creating inconsistent but plausible synthetic data for training was an interesting problem to tackle here (see slides for more). I trained a neural network (bi-directional single-layer LSTM with a classifier head) to classify the statements as consistent or inconsistent (containing a bug or a typo). The solution reached an 87.4% accuracy in the synthetic dataset, but the performance did not generalize to real test cases (outside the dataset). In this project, I used: Python, Pytorch, Huggingface, Numpy, Pandas, LibCST, Scikit-Learn, Weights&Biases, a FastText tokenizer, and maybe a few other toys. This project was developed in the "Analysing Software with Deep Learning" course at Universität Stuttgart as a solo project under the supervision of Islem Bouzenia.

Presentation

Google Slides link

How to run

  • Create and activate a Python3.8 env
  • pip install -r requirements.txt
  • download shared resources (as per assignment instructions)
  • python3 milestone2/Train.py --source <dataset source dir> --destination <output trained model path>
  • python3 milestone2/Predict.py --model <model path> --source <testing inputs> --destination <output JSON predictions>

Dataset information

Ifs: 357866 Elses: 59717 Elifs: 34858 Raises: 155274

detecting-if-inconsistencies's People

Contributors

petrmiculek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.