liveBook · Manning

Composite rule

As explained in Fight Fraud with Machine Learning

A compound rule is a binary decision rule formed by logically combining multiple simple rules or feature conditions.

A composite rule combines two or more simple or composite rules with logical operators such as AND and OR. Each rule produces a binary 0/1 decision, making the result directly usable in a rule-based fraud-detection system. section 2.2.1 section 2.4

Build composite rules by:

  • Creating simple rules from binary features, such as FrequentDomainNameMismatch == 1 or SubmitInfoToEmail == 0. section 2.2.1
  • Combining rules with OR or AND, then measuring accuracy against CLASS_LABEL. section 2.2.1
  • Mixing binary-feature rules with threshold rules over numerical features. section 2.2.3
  • Nesting a simple rule with an existing composite rule to create a larger decision expression. section 2.2.3

Phishing detection combination

Combining FrequentDomainNameMismatch == 1 with SubmitInfoToEmail == 0 using AND produced 69.23% accuracy, while combining a numeric threshold rule with that composite rule using OR reached 80.92%. section 2.2.1 section 2.2.3

df["rule_a_or_rule_1_and_rule_2"] = ((df.rule_a==1) | (df.rule_1_and_rule_2==1))*1.
rule_a_or_rule_1_and_rule_2_accuracy = (df["rule_a_or_rule_1_and_rule_2"] == df["CLASS_LABEL"]).mean() 
df["rule_a_and_rule_1_and_rule_2"] = ((df.rule_a==1) & (df.rule_1_and_rule_2==1))*1.
rule_a_and_rule_1_and_rule_2_accuracy = (df["rule_a_and_rule_1_and_rule_2"] == df["CLASS_LABEL"]).mean() 
print(rule_a_or_rule_1_and_rule_2_accuracy, rule_a_and_rule_1_and_rule_2_accuracy)

Inspect the executable pattern for combining a numeric rule with the composite binary rule using OR and AND. section 2.2.3

Logical choice changes operational behavior: OR is more inclined to predict fraud, whereas AND requires both conditions. Additional features rapidly increase the number of possible combinations, limiting scalability and analysis. section 2.2.1 section 2.4

How Fight Fraud with Machine Learning covers it

How deep it goes
Explains construction, nesting, evaluation, and combination limits, but stops short of scalable multi-feature rule search.
Examples
Uses phishing features, AND/OR expressions, numerical thresholds, Python listings, accuracy values, and fraud-system diagrams.
What it assumes
Assumes feature values and binary labels, while demonstrating simple rules and threshold selection before composite construction.
What you can do after
Build it from scratch in Python, combine binary and numeric rules, and evaluate the resulting fraud detector with accuracy.
How it connects
Connects simple rules, binary features, numerical features, threshold rules, and rule-based fraud detection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Fight Fraud with Machine Learning. The section links point to the parts of the book it draws on.