In fraud detection, a false positive occurs when a legitimate transaction is flagged as fraudulent. The false-positive rate is the proportion of actual legitimate transactions that are incorrectly flagged: false positives ÷ all actual legitimate transactions. section 7.4.1
A broader detection rule may catch more fraud but also flag more legitimate transactions. Those false alarms create customer friction, erode trust, and consume investigation capacity. Tuning rules requires balancing fraud detection against the cost of penalizing good customers. section 7.4.1
Listing 7.2 Applying and evaluating simple fraud detection rules
def calculate_rule_detection_performance(df, rules_conditions):
"""
Applies a dictionary of rules (as pandas query strings) to a DataFrame
and calculates performance metrics for each rule.
"""
results_list = []
for rule_name, condition_query_str in rules_conditions.items():
# Filter the DataFrame based on the rule's condition
flagged_by_rule_df = df.query(condition_query_str)
num_total_flagged = len(flagged_by_rule_df)
if num_total_flagged > 0:
num_fraud_flagged = flagged_by_rule_df['label'].sum() # Sum of 1s (fraud)
num_legit_flagged = num_total_flagged - num_fraud_flagged
# Detection Rate (Precision): Proportion of flagged transactions that are fraud
detection_rate = num_fraud_flagged / num_total_flagged
else:
num_fraud_flagged = 0
num_legit_flagged = 0
detection_rate = 0.0
results_list.append({
'Rule Name': rule_name,
'Legitimate Transactions Flagged': num_legit_flagged,
'Fraudulent Transactions Flagged': num_fraud_flagged,
'Precision (Fraud/Flagged)': detection_rate
})
return pd.DataFrame(results_list)
# Define our set of expert rules using pandas query syntax
defined_rules = {
'High Value Transaction (>5000)': "transaction_amount > 5000",
'Multiple Recent Payment Methods (>=3)': "recent_7d_payment_methods_count >= 3",
'Frequent Login Failures Recently (>=3)': "num_recent_login_failures >= 3",
'New Account & Large Transaction (>3000, age<=30d)': "(account_age_days <= 30) and (transaction_amount > 3000)",
'International IP & High Value Transaction (>2000)': "(is_domestic_ip == False) and (transaction_amount > 2000)"
}
# Evaluate the rules on our sample data
rule_performance_df = calculate_rule_detection_performance(sample_data.copy(), defined_rules)
print("\nPerformance of Defined Fraud Detection Rules:")
display(rule_performance_df)
The rule evaluation counts flagged legitimate and fraudulent transactions and calculates precision. Precision uses all flagged transactions as its denominator; the false-positive rate instead uses all actual legitimate transactions. section 7.4.1
In anti-money-laundering operations, false-positive rate sits alongside case resolution time and compliance penalty avoidance as a measure of success. Danske Bank’s reported 60% reduction in false AML positives illustrates the potential operational value: thousands of analyst hours saved and a stronger regulatory position. A reduction in the number of false positives is not itself a false-positive rate. section 2.4.2
Capture investigation outcomes, including confirmed fraud and false positives, to refine rules and thresholds. Monitor false-positive measures alongside precision, recall, fraud detected and missed, and investigation costs; also watch for data and concept drift and review models for compliance and unintended bias. section 7.4.4









