Skip to main content

Module association_rules

Module association_rules 

Source
Expand description

Apriori-style frequent itemset mining + association-rule generation over per-class callSequences blobs.

Each class node carries a callSequences JSON blob with shape

{"sequences": [{"method": str, "calls": [str], …}, …]}

Every sequence with len(calls) >= 2 becomes one transaction (the frozenset of its calls). We then:

  1. Mine frequent itemsets by Apriori (bottom-up by k), capped at k = 5 to match the Python reference.
  2. Generate rules A → C for every non-empty proper subset A of each frequent itemset, scoring with confidence = sup(A∪C)/sup(A) and lift = confidence / (sup(C)/n).
  3. Classify each rule as invariant (conf ≥ 0.99), strong (≥ 0.85), or moderate (≥ 0.5).

Mirrors analysis/association_rules.py in the visiting tool.

See DESIGN.md (Phase 3) at the workspace root.

Structs§

AssociationAnalysis
Whole-graph association-rule readout.
AssociationRule
An association rule antecedent → consequent with support, confidence, and lift.
CallSequence
One call-sequence record parsed from a class’s callSequences blob.
FrequentItemset
A frequent itemset and its support count across the transaction list.

Functions§

classify_rule
Classify by confidence threshold — invariant (≥0.99), strong (≥0.85), moderate otherwise.
compute_association_analysis
Walk every node’s callSequences blob and run end-to-end mining.
generate_rules
Generate association rules from frequent itemsets.
mine_frequent_itemsets
Mine frequent itemsets by Apriori. Caps k at 5 (matches Python ref) to keep candidate generation tractable on large unique-item alphabets.
parse_call_sequences
Parse the {"sequences": [...]} blob attached to a single class.