Partial Dependence Plot ‐ Audit AI - BlackAlph4ndr01D/Daftar-Militer-AI-zionis-israel-part.2 GitHub Wiki

✅ Partial Dependence Plot (PDP) – Detailed Explanation

What is a Partial Dependence Plot?

Partial Dependence Plot (PDP) is a global interpretation technique in Explainable AI that shows how a specific feature affects the model's prediction, while averaging out the effects of all other features.

It answers the question:

“On average, how does changing this one feature affect the model’s output?”

PDP was introduced by Friedman in 2001 and remains one of the most popular and easy-to-understand global explanation methods.

How Partial Dependence Plot Works

  1. Choose one feature (e.g., age or in_hotspot_area).
  2. Fix all other features at their actual values for each data point.
  3. Vary the chosen feature across a range of values (e.g., age from 18 to 60).
  4. For each value, calculate the average prediction of the model.
  5. Plot the result as a line or curve.

The plot shows the marginal effect of that feature on the prediction.

Python Code Example

# =============================================
# Partial Dependence Plot Example
# =============================================

import pandas as pd
import matplotlib.pyplot as plt
from sklearn.ensemble import RandomForestClassifier
from sklearn.inspection import PartialDependenceDisplay

# Sample dataset (Threat Scoring simulation)
data = pd.DataFrame({
    'age': [28, 34, 19, 45, 22, 31, 27, 40],
    'in_hotspot_area': [1, 0, 1, 1, 0, 1, 1, 0],
    'night_communication': [1, 0, 1, 1, 0, 1, 1, 0],
    'weapon_detected': [0, 1, 0, 1, 0, 0, 1, 0]
})

target = [1, 1, 0, 1, 0, 1, 1, 0]   # 1 = High Threat

model = RandomForestClassifier(n_estimators=100, random_state=42)
model.fit(data, target)

# =============================================
# Generate Partial Dependence Plots
# =============================================

features = ['age', 'in_hotspot_area', 'night_communication']

fig, ax = plt.subplots(figsize=(12, 6))
PartialDependenceDisplay.from_estimator(
    model, 
    data, 
    features,
    kind='average',           # or 'both' to show individual lines too
    ax=ax
)

plt.suptitle("Partial Dependence Plots - Threat Scoring AI")
plt.tight_layout()
plt.show()

Interpretation Example

  • Age PDP: The plot shows that threat score increases sharply for ages 18–35, then decreases for older ages.
  • in_hotspot_area PDP: When the feature = 1 (in hotspot), average threat score jumps significantly.

This helps reveal non-linear relationships and potential bias (e.g., young males in certain areas are heavily penalized).

Advantages of PDP

  • Easy to understand and visualize.
  • Shows global effect of a feature.
  • Works with any model.
  • Good for detecting bias and non-linear patterns.

Disadvantages

  • Assumes features are independent (can be misleading if multicollinearity is high).
  • Only shows average effect (can hide heterogeneous behavior).
  • Less useful for highly correlated features.

Relevance to Israeli Military AI

PDP is very useful for auditing systems like:

  • Lavender → See how “age” and “location” affect threat scores.
  • Threat Scoring in Arbel → Understand which features drive automatic shooting decisions.
  • Gospel → Analyze how building characteristics influence targeting.

It helps expose systematic bias (e.g., young Palestinian males in certain areas automatically get high threat scores).


Next : add a more detailed code example with military context or compare PDP with other methods?

Integrated Gradients ‐ Audit AI