Skip to content

Build the evidence-grounded rule classifier #11

Description

@khatchad

Build the baseline classifier that predicts a commit's data-refactoring type from its change, not just its message. A message-only keyword pass false-positives: a commit whose message says "split" but whose diff only edits the README is not a refactoring. Keep the message anyway, since when the observed change is consistent with it the message supplies intent (a file deleted with a message calling it a duplicate is deduplication, not a plain delete).

Step 0: Featurization

Turn a commit into its evidence: message tokens, change-op types, file counts, column delta, file extensions. All three stages below need this, so it is a prerequisite rather than part of the ML stage, and it is most of the work in this issue. tests/gold_set.csv carries labels only, no features, so something has to resolve each DatasetID/CommitId pair to its evidence.

analysis/classify_commit.py should not consume the output of inspect() in analysis/inspect_commit.py. That function prints and returns None, and its display is partial by design: column diffs only for modified non-LFS CSVs, word diff truncated at 50 lines, failures sent to stderr. Share the underlying pieces instead. Factor clone, lfs_status, header and parse_csv_header into a module both files call, leaving inspect_commit.py as a thin CLI over it and giving classify_commit.py structured evidence rather than printed text. Leave the LFS and Xet fetch logic as it is; it took #37 and #45 to get right.

Stages

Stage 1 is the whole scope of this issue. Do not start 2 or 3 before 1 is scored.

  1. Evidence-Grounded Rules. Combine message keywords with the step-0 signals. The bar it has to clear is the message-only keyword pass, especially on false positives.
  2. Feature-Based ML. Train something simple on the step-0 features: logistic regression, a decision tree, or k-nearest neighbours.
  3. Optional LLM Classifier. Only if it beats the rule baseline, and disclosed as a threat to validity.

This Is Multi-Label

The gold set records one row per refactoring, so a single commit can carry several types (for example add column(s) and standardize in the same commit). Predict a set of types per commit, not a single class. Scoring follows from that: per-label precision/recall/F1, micro- and macro-averaged, plus per-label binary confusion or a type co-occurrence matrix. A single-label confusion matrix does not apply.

Scoring

Developed and scored against the hand-labeled gold set, using the multi-label metrics described above. The evaluation step itself is tracked outside this repo.

Notes

Tracked Outside This Repo

Labeling the gold set precedes this, and evaluating the classifier follows it. Both are tracked outside this repo, so neither appears in this issue's blocked-by relations.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions