AI in QA

AI Defect Prediction: Data, Validation, and Limits for QA Managers

AI Defect Prediction: Data, Validation, and Limits for QA Managers

A defect-prediction score can give a QA manager another reason to inspect a change. Before using it to allocate attention, the manager needs to know what the model learned, what the historical labels mean, and whether its apparent performance survives a realistic test on later work. A convincing retrospective chart can still depend on information that would not have existed when the prediction was needed.

Use AI defect prediction as an advisory signal for additional review. Keep the approved baseline and regression tests in place while evaluating whether the signal earns its review cost. A low score is not evidence that a change is bug-free, and a high score is not a confirmed defect.

Table of Contents

Define the Forecast Before Choosing a Model

Software defect prediction learns relationships between historical software characteristics and observed defect labels, then applies those relationships to new units of code. Depending on the design, the unit might be a module, a file, or an individual change. Those choices produce different questions: which files deserve extra investigation before a release, or which incoming changes deserve attention now?

Just-in-time defect prediction targets the change-level question. Features describe a change at its prediction moment, such as lines added and deleted, the spread of touched files, or relevant prior change history. A classifier learns from earlier labeled examples and produces a class or score for a new change. Logistic regression and tree-based models are possible approaches; a system does not need a generative language model to qualify as machine learning defect prediction.

The distinction is practical. A rule that marks every critical issue as high priority is an explicit policy, not evidence that a model learned defect-prone patterns. Generating test cases is another task. Neither operation validates a predictor of future defect-associated changes.

Write the forecast as a sentence before selecting technology: “At the time a change is ready for review, rank it for additional inspection using only information available at that moment.” Then define the target label and how it will eventually be observed. Changing the unit or moment later changes the experiment.

Keep ranking and probability separate. A score can order changes without being a calibrated probability. A value near 0.8 does not automatically mean an 80% chance of a defect. That interpretation requires calibration evidence for the relevant population and label definition. Even a well-calibrated association would not establish the cause of a defect or prove that an extra review prevents it.

Build Labels That Respect Time

Historical data is useful only when the team can reconstruct what was known when. The feature snapshot and the eventual outcome belong to different points on the timeline. Combining them into one current-state export can quietly reveal the future to the model.

Separate Available Features From Later Outcomes

For each prediction unit, retain an identifier, a prediction timestamp, the feature values available then, and the provenance of those values. Later defect reports and fixes can help establish an outcome label, but they cannot become earlier predictive features. For example, a count of fixes accumulated after a change is submitted would be unavailable to a predictor operating at submission time.

Also distinguish the date a change happened from the date its label became usable. If a model is fitted on July 1, a June change whose label becomes available on July 20 is not an eligible labeled training example for that fit. Sorting records by commit date alone does not enforce this boundary.

Treat missing history as a data-quality problem rather than a favorable signal. Renamed files, incomplete change logs, inconsistent defect categories and broken issue-to-change links can alter both features and labels. Audit representative records with engineering and QA reviewers before comparing model families. Retain the labeling procedure's version so a later cleanup does not silently change the meaning of an earlier evaluation.

Define Maturity and Keep Unknowns Visible

A positive label needs an operational definition. A pilot might count a reviewed defect linked to a change and observed within a specified period. That is narrower than “this change contains any possible bug.” Define which defect categories qualify, how disputed links are reviewed, and whether the observation process covers the full period.

A negative label means no qualifying defect was observed after the declared horizon, under that observation process. It does not certify permanent correctness. A recent change whose horizon has not ended is still pending. A change with missing observation data may remain unknown even after enough calendar time has passed. Neither should silently become a negative example.

Mining algorithms do not remove this uncertainty. SZZ-style approaches trace fixing changes back to candidate defect-introducing changes using historical records and heuristics. The foundational PLOS study on graph-based just-in-time prediction explicitly acknowledges that SZZ can mislabel changes. Human sample review and documented ambiguity handling are therefore part of defect prediction data quality, not optional cleanup after a model looks promising.

Choose an observation horizon from the project's reporting and discovery process, then examine how that choice affects label availability. A short horizon answers a different question from a long one. Keep the horizon stable within a comparison and report the pending population alongside the scored population.

Validate on a Later Period, Not a Random Mix

A deployment-facing evaluation should ask whether information available earlier helps forecast later changes. Reserve a future-period holdout and make model choices using earlier training and validation periods. At each simulated fit cutoff, include only examples whose features and labels would already have been available.

Use explicit calendar windows when changes arrive irregularly. A time-series splitter can preserve order, but a gap measured in samples is not automatically a defect-label waiting period. The required separation depends on the actual timestamps and observation policy. Check label maturity directly instead of assuming that a fixed number of intervening commits solves it.

Before opening the holdout, freeze the following decisions:

  • The prediction unit, feature snapshot, label definition and maturity rules.
  • The training and validation windows, later holdout, and treatment of duplicate or related changes.
  • The model, preprocessing, ranking direction, review budget or threshold, and tie handling.
  • A simple baseline and the measures that will determine whether further investigation is justified.

Fit scaling, imputation and feature selection only on the eligible training portion of each development split. Applying the same transformation to later data is appropriate; learning that transformation from the entire dataset is leakage. Keep duplicate, copied or cherry-picked representations from appearing on opposite sides of a split, where they could make memorization look like generalization.

A simple baseline might rank changes by lines changed, using a direction and tie rule chosen beforehand. It is a comparator, not an assumption that larger changes are always riskier. Evaluate both policies on the same future population and review-slot budget. If actual review effort matters, measure it separately: inspecting four changes can take very different amounts of time under two policies.

Research results need the same scrutiny. The 2023 PLOS graph-based study establishes a learned change-level prediction problem and discusses important limitations, but its reported experiment uses a random partition and static graph features. Its benchmark results are not evidence that a chronological pilot will achieve the same performance in your project. Use the mechanism as background, then validate the operational question directly.

Do not select the best threshold after seeing holdout outcomes and report that outcome as an untouched test. A change prompted by the holdout becomes a new policy version that needs another later evaluation period.

Read the Confusion Matrix and Review Load Together

Consider DEFECT-PILOT-1.0, a wholly fictional teaching packet with twelve synthetic changes. Its scores and outcomes are authored illustrative outputs. No model was trained, no repository was analyzed, and no real pilot or vendor benchmark was executed. The calculation checks the illustration's arithmetic only.

The assumed policy is frozen on June 30, 2026, with a hypothetical fit cutoff of July 1. Predictions occur from August 1 through August 12, within a window ending before August 13. A 30-day observation horizon is an illustrative assumption, not a recommended universal waiting time. At September 9, 12:00 UTC, ten labels have matured and two remain pending.

Three of the ten mature labels are positive, so the known-label base rate is 3/10. Both policies allocate four additional review slots across the same twelve changes. The authored score ranking flags C01, C02, C03 and C04; the descending-churn baseline flags C04, C06, C07 and C01. Neither policy flags the two pending changes in this packet.

Measure

Authored Score Policy

Churn Baseline

Flagged, positive label

2

1

Flagged, negative label

2

3

Not flagged, positive label

1

2

Not flagged, negative label

5

4

Precision among known flagged changes

50.0%

25.0%

Recall among known positive changes

66.7%

33.3%

Review slots across all changes

4 of 12

4 of 12

Labels still pending

2

2

The first four rows form the confusion matrix for the ten known labels: true positives, false positives, false negatives and true negatives. Precision is true positives divided by all known flagged changes. Here, the score policy gives 2/4 and the baseline 1/4. Recall is true positives divided by all known positive changes, giving 2/3 and 1/3 respectively. The displayed percentages are rounded to one decimal place.

These denominators exclude pending labels, while the workload ledger retains all twelve changes. Do not report a pending change as a correct negative. If a future packet includes flagged changes with unknown outcomes, show those separately too; precision on only the resolved subset does not describe every review slot.

The score policy looks better in this invented packet, but its two false positives still consume attention and its one false negative remains a risk. A false positive means a flag without a qualifying observed positive label, not necessarily a pointless review. Reviewers may uncover another issue, dispute the label, or find no actionable problem. Record that disposition rather than treating every flag as a discovered defect.

For a predeclared capacity sensitivity, reduce the score policy to two review slots. It then flags C01 and C02: one true positive, one false positive, two false negatives and six true negatives. Precision remains 1/2, but recall falls to 1/3. This is an arithmetic sensitivity, not evidence that two slots are the right operating point or permission to tune on the holdout. Neither comparison measures time saved, defects prevented or real predictive accuracy.

Run an Advisory Pilot Without Cancelling Tests

Start with a read-only pilot design and an explicitly authorized data boundary. Access to source code or defect histories needs its own approval; interest in predictive analytics in QA does not authorize exporting records to a new service. The pilot record should identify the data owner, label reviewer, model owner and QA decision-maker, with unresolved prerequisites recorded as blockers.

Use a bounded sequence for the eventual evaluation:

  1. Audit the historical feature and label timeline, including unknowns and disputed defect links.
  2. Freeze the model version, baseline, future evaluation window and review-capacity policy using earlier evidence.
  3. Record predictions before outcomes become available, then evaluate mature labels with false alarms, misses and reviewer dispositions visible.
  4. Decide whether to continue, revise or stop the advisory experiment without changing the approved testing baseline on the strength of scores alone.

A high score can prompt extra code inspection or exploratory investigation by a named reviewer. It should not automatically block a release, cancel tests, assign blame to a developer, or establish the severity of a defect that has not been confirmed. Keep mandatory regression coverage and release decision authority independent of the experimental ranking.

Retain low-scored changes in the risk record as well. Otherwise, attention follows the predictor and the team may learn little about what it misses. Review false negatives and observation gaps rather than using a high overall accuracy figure to obscure them, especially when positive labels are uncommon.

Finally, treat a new project, major version or changed development process as a new validation question. Feature distributions, defect base rates and label practices can shift, so earlier precision and recall may not transfer. Monitor those changes and suspend reliance on the signal when its evidence is no longer representative.

The first useful deliverable is a time-correct data and label audit with an owned, frozen evaluation plan. If that foundation is weak, improve it before expanding the model. If it is sound, test whether the advisory queue adds useful information at an acceptable review cost while ordinary testing continues unchanged.

Related

More on AI in QA

Create traceable test cases, prepare release-specific test runs, and keep approved coverage current as the product changes.