Skip to main content

A Python package for calculating the commit understandability features of Java projects.

Project description

neurojit

neurojit is a Python package designed to enhance Just-In-Time (JIT) defect prediction by leveraging insights from both neurophysiological and empirical developer reactions to code. Modern developers make changes based on their understanding of the existing code context, and the difficulty in comprehending these changes can increase the likelihood of human error, potentially introducing defects. NeuroJIT captures the understandability of each commit through features that correlate with developers’ cognitive and empirical responses to different code segments. These features have been shown to improve JIT defect prediction models by identifying defect-inducing commits more effectively. For more information, see our research paper "NeuroJIT: Improving Just-In-Time Defect Prediction Using Neurophysiological and Empirical Perceptions of Modern Developers."

Installation

You can install the NeuroJIT package from PyPI using pip:

$ pip install neurojit

To install with additional dependencies for replicating the research results:

$ pip install neurojit[replication]

For more information about the replication, see our NeuroJIT replication package

Example Usage

  1. Filtering Commits and Saving Method Changes

    from neurojit.commit import MethodChangesCommit, Mining, Method
    
    mining = Mining()
    target_commit = mining.only_method_changes(repo="activemq", commit_hash="8f40a7")
    if target_commit is not None:
        mining.save(target_commit)
    
  2. Calculating Commit Understandability Features

    Compute commit understandability features from the saved MethodChangesCommit instances.

    from neurojit.cuf.metrics import CommitUnderstandabilityFeatures
    
    cuf_calculator = CommitUnderstandabilityFeatures(target_commit)
    features = ["HV","DD", "MDNL", "NB", "EC", "NOP", "NOGV", "NOMT", "II", "TE", "DD_HV"]
    for feature in features:
        value = getattr(cuf_calculator, feature)
        print(f"{feature}: {value}")
    
  3. Splitting the Dataset Chronologically with KFoldDateSplit

    Use KFoldDateSplit to split the dataset into training and testing sets, considering chronological order, verification latency, and concept drifts.

    from neurojit.tools.data_utils import KFoldDateSplit
    
    data = pd.read_csv("...your jit-sdp dataset...")
    data["date"] = pd.to_datetime(data["date"])
    data = data.set_index(["date"])
    
    splitter = KFoldDateSplit(
        data, k=20, start_gap=3, end_gap=3, is_mid_gap=True, sliding_months=1
    )
    
    for i, (train, test) in enumerate(splitter.split()):
        X_train, y_train = train[features], train["buggy"]
        X_test, y_test = test[features], test["buggy"]
    

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neurojit-1.0.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file neurojit-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: neurojit-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for neurojit-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3abcac55735e5e8676912b4c9dce591341d54cce4618169f179dfdf35f54adec
MD5 353ec3ee32d1dab13543edc1bcb918a2
BLAKE2b-256 b31388154ee42d58e73824c0f2c40d1aad81804689fe541220538e6e3f2b7613

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page