DPGExplainer Saga Benchmarks: Episode 1 — Iris
Episode 1: Iris
DPGExplainer Saga Benchmarks — Episode 1: Iris
Welcome to the first episode of the “DPGExplainer Saga Benchmarks”, a short series of eXplainable Machine Learning (XAI) report where I stress-test **Decision Predicate Graphs (DPG)** on classic datasets and widely used models.
In this post, I use a Random Forest trained on the Iris dataset as a clean, familiar starting point. The goal is simple: show what DPG reveals about the model’s decision structure beyond accuracy, and how those signals align (or not) with what the dataset itself suggests.
The workflow is straightforward:
- Train a **Random Forest model (**using Python with scikit-learn)
- Extract the **DPG** from the trained model
- Analyze local reaching centrality (LRC), betweenness centrality (BC), and detected communities
- Cross-check DPG insights against dataset statistics to validate and contextualize the findings
All the Python implementations of this post are available as a Jupyter notebook in the [tutorials](https://github.com/Meta-Group/DPG/tree/main/tutorials) directory of the DPG repository.
1. Iris dataset and data visualization
The Iris dataset is a small, clean benchmark that’s ideal for interpretability demos because it is simple enough to inspect visually, yet still contains non-trivial class overlap. It includes 150 samples, each described by four continuous features (in centimeters): sepal length, sepal width, petal length, and petal width. The target has three classes — setosa, versicolor, and virginica — with 50 samples per class, so the class distribution is perfectly balanced.
A quick way to build intuition before touching any model is a pairwise plot (pairplot). A pairplot is a grid where each cell shows the relationship between two features (a scatter plot), while the diagonal typically shows the distribution of a single feature. When points are colored by class, the plot becomes a compact “map” of separability: you can immediately see which feature pairs tend to cluster by species, where overlap happens, and which dimensions are likely to drive decision boundaries. Figure 1 shows the pairplot for Iris (colored by class). A few practical takeaways usually pop out:
- Petal features dominate separability. Setosa typically forms a clearly isolated cluster, especially on petal length and petal width. That visual separation hints that many models will learn very simple thresholds to identify setosa early.
- Versicolor vs. virginica is the real challenge. These two classes often overlap in several projections. The overlap tends to shrink when you look at petal length vs. petal width, but it rarely disappears completely, which foreshadows more complex (and more interesting) boundaries for the classifier.
- Sepal features are weaker discriminators. Sepal length/width often show substantial mixing across classes, suggesting they may contribute as secondary refinements rather than as primary splitters.
- Correlations matter. You can often see a strong positive relationship between petal length and petal width, which implies redundancy: multiple features may encode similar information, and the model can choose among them when constructing splits.

Figure 1 — Iris Pairplot
This visual snapshot is useful later as a sanity check: if a Random Forest (and therefore the extracted DPG) claims that sepal width is the main driver of global structure, that would be surprising given what the pairplot suggests. Conversely, if DPG highlights petal-based predicates as structurally central and boundary-defining, that aligns with the geometry we can already see in the data.
Interpretation: Setosa is largely isolated in petal-space, while versicolor and virginica show substantially more overlap. Keep this in mind, we’ll revisit these patterns and extract deeper, model-level insights with DPG.
2. Model creation
In this step we create a machine learning model to classify Iris samples. For this first benchmark, we use a Random Forest (RF), a strong and widely adopted baseline that is both accurate and relatively robust out of the box.
Random Forest in a nutshell
A RF is an ensemble of decision trees. Instead of relying on a single tree (which can be unstable and prone to overfitting), the forest trains many trees and aggregates their predictions, typically by majority vote for classification. These mechanisms encourage diversity among trees. Each tree may make slightly different errors, and when combined, the forest tends to reduce variance and improve generalization.
The idea behind Random Forest feature importance
RFs often come with “importance” scores that attempt to quantify which features matter most. The most common is impurity-based importance (often called Gini importance): every time a feature is used to split a node, it contributes to reducing impurity; these reductions are summed across all trees and normalized.
This is useful as a quick diagnostic, but it has limitations:
- It is global and aggregate: it doesn’t tell you how a feature is used, only that it tends to reduce impurity.
- It can be biased toward certain feature types or distributions (e.g., continuous features with many potential split points).
- It does not reveal decision structure: which features act early, which ones connect sub-decisions, and where classes truly overlap in the model’s logic.
That’s exactly where DPG aims to add value: not only what is important, but how the model routes decisions.
Confusion matrix: what it tells you (and what it doesn’t)
Before DPG analysis, we verify the classifier is doing something reasonable. A standard tool for this is the confusion matrix, which summarizes how predictions match true labels.
For a 3-class problem like Iris, the confusion matrix is a 3×3 table:
- Rows: true class
- Columns: predicted class
- Diagonal cells: correct predictions
- Off-diagonal cells: misclassifications (which classes are being confused)
A confusion matrix is great for answering questions like:
- Which class is easiest or hardest?
- Which pair of classes is most often confused?
- Are errors symmetric (A→B as often as B→A) or not?
However, it is still an outcome-level view. It does not explain why the model confuses two classes, which rules/predicates cause it, or where in feature space the confusion happens.
What DPG can reveal beyond the confusion matrix?
This is where Decision Predicate Graphs go further. While the confusion matrix tells you that errors exist, DPG helps explain the structure behind those errors, for example:
- Which predicates (features + logic operator + value) are upstream “routers” (high LRC) that steer a large portion of the decision process.
- Which predicates act as bridges between decision submodules (high BC), often signaling structural bottlenecks or mediating rules.
- Communities of predicates that form coherent “modules” in the model’s logic (e.g., a petal-based module vs. a sepal-based refinement module). Also, overlap, and class complexity as properties of the model’s decision program — not just the dataset geometry.
In this particular benchmark, the confusion matrix typically confirms the expected Iris pattern: setosa is usually easy, while versicolor/virginica carry most of the confusion. This is exactly the part DPG should help explain structurally, showing which predicates create that overlap, how the model navigates it, and whether the decision program contains clear bottlenecks or competing sub-rules that drive those mistakes.

Figure 2 — Confusion Matrix of Random Forest Model prediction
The confusion matrix of our RF model created (Figure 2) confirms the expected Iris pattern: setosa is classified almost perfectly, while most errors concentrate on the versicolor/virginica boundary. This is precisely where DPG becomes most informative, by exposing the structural reasons behind that confusion in the model’s decision logic.
3. Why DPG on top of Random Forest
RFs are a strong baseline: they tend to deliver excellent predictive performance with minimal tuning, and they provide convenient summaries such as feature importance. The catch is that feature importance is not a model blueprint. It can tell you which features are influential on average, but it does not expose the explicit decision flow of the model, namely, how concrete threshold predicates interact across trees to route samples toward different classes.
In practice, many interpretability questions are structural:
- Which predicates act early and steer most samples?
- Where are the bottlenecks that many decision paths must pass through?
- Which groups of predicates form coherent “modules” that define a class region?
- Where does the model exhibit overlap between classes, and which rules create it?
This is where Decision Predicate Graphs (DPG) come in. Figure 3 presents the DPG identity.

Figure 3 — DPG identity
From a forest of trees to a single predicate graph
DPG provides a global, model-level representation by converting the ensemble model, such as RF, into a single graph of predicates.
Nodes represent concrete split predicates of the form:
feature ≤ thresholdfeature > threshold
Edges represent transitions between predicates that occur along decision paths in the trees. If a tree path applies predicate A and later predicate B, the graph contains an edge A → B.
The result is a compact object that preserves the logic of the model in a form that can be inspected with graph reasoning.
Graph metrics as “roles” in the decision program
Once the model becomes a graph, we can ask not only “what matters”, but “what role does it play” in the overall decision logic. DPG typically leverages structural measures such as:
- LRC (Local Reaching Centrality): highlights upstream predicates that tend to appear early and influence many downstream decisions, intuitively, global routers.
- BC (Betweenness Centrality): identifies predicates that sit on many shortest paths, intuitively, bridges or bottlenecks connecting decision submodules.
- Communities: groups predicates that frequently co-occur along paths, often revealing modular structures (e.g., a petal-driven module vs. sepal refinements in Iris).
- Class boundaries / overlap / complexity: structural indicators of how clearly the model separates classes and how entangled the rule sets become.
In other words, DPG doesn’t replace the RF or RF Importance, it turns it into something you can read, analyze, and audit as a global decision program.
4. LRC vs RF importance (complementary views)
RF feature importance and DPG’s LRC answer related, but different, questions. RF importance aggregates how much each feature reduces impurity across the whole ensemble, so it is great for a feature-level ranking. LRC, instead, operates at the level of concrete threshold predicates (for example, petal width > 0.80) and measures how structurally influential a predicate is in the downstream decision flow of the global predicate graph.
What changes when we move from “feature” to “predicate”?
In Figure 4 (right), RF importance confirms the classical Iris story: petal length and petal width dominate, while sepal features contribute less. This tells us where the signal is, but not how the model routes decisions using that signal.
In Figure 4 (left), LRC decomposes those same top features into specific split points that the model repeatedly uses as upstream routers. Instead of saying “petal width matters”, LRC highlights which petal-width thresholds matter and why they matter structurally. You can see multiple high-LRC predicates concentrated on petal width and petal length (several cut values along the same features), which is exactly what you would expect from an ensemble: different trees reuse slightly different thresholds that play similar routing roles.

Figure 4 — LRC and RF Importance ranking
- A subtle but important detail is that sepal length also appears among top-LRC predicates even though its RF importance is comparatively small. This is a typical “complementarity” case: a feature can be less informative overall (lower average impurity reduction) but still be structurally central because it is often used as a secondary router that refines decisions after the primary petal-based separation. RF importance compresses everything into one score per feature; LRC exposes the actual logic tokens the model relies on.
- A practical rule of thumb is the following: if a feature scores high in RF importance and also contributes many high-LRC predicates, it is both statistically useful and structurally central. Here, both views converge on the petal features, which is reassuring and consistent with the data geometry.
Projecting high-LRC predicates onto the data manifold
To make the predicate view tangible, Figure 5 projects the top LRC split lines onto the most informative 2D plane (petal length vs. petal width). This plot shows where the most structurally influential predicates “cut” the dataset.

Figure 5 — LRC projections using top predicates
Three insights stand out:
- Early isolation of setosa. The vertical split around petal length ≈ 2.70 and the horizontal split around petal width ≈ 0.80 neatly separate the setosa cluster in the lower-left region. This mirrors what we observed in the pairplot and explains why setosa is almost always classified correctly.
- The versicolor/virginica bottleneck. The line around petal width ≈ 1.65 sits right in the transition band between versicolor and virginica. This is exactly where the two classes start to overlap, so it is natural that a predicate near this threshold becomes structurally central: many paths need it to decide which side of the boundary a sample should follow.
- Why confusion concentrates where it does. The confusion matrix tells us that most errors occur between versicolor and virginica, but it cannot show what decision structure causes that. Figure 5 gives a structural explanation: the model relies on a small set of upstream, high-LRC cut points that carve the space into regions, and the hardest region is precisely the one around the petal-width boundary where classes are not cleanly separable.
Overall, the takeaway is that RF importance tells you what features matter, while LRC tells you which specific predicates act as global routers. When you overlay those predicates on the feature space, you get a concrete picture of how the model’s decision program aligns with the dataset geometry, and where the remaining ambiguity (and therefore misclassification) is structurally concentrated.
5. BC as bottleneck decision logic
What is a “bottleneck”?
In a graph, a bottleneck is a node (or edge) that many paths must pass through to connect different parts of the network. In DPG terms, a bottleneck predicate is one that sits “in-between” major decision regions.
What does that mean for a classifier?
For a classifier, a bottleneck predicate is not just “important” in the impurity-reduction sense. Instead, it plays a connective role in the decision program:
- it often appears at transition points between broad decision regimes (e.g., from an easy-to-separate class region to an ambiguous overlap region),
- it funnels many decision paths toward a smaller set of downstream refinements,
- it links otherwise distinct predicate communities, acting as a structural “bridge” in the model logic.
In DPG, this role is captured by Betweenness Centrality (BC): predicates with high BC lie on many shortest paths in the predicate graph, which is a strong signal that they coordinate how different parts of the model interact.
Is BC related to performance?
Indirectly. High-BC predicates often sit near regions where the problem is inherently harder (class overlap, boundary ambiguity). That means:
- They can be where errors concentrate (because the data is genuinely ambiguous there).
- They can also be where the model’s robustness is tested (small shifts in feature values around these predicates may flip routes).
- But a high-BC predicate is not automatically “good” or “bad” for accuracy, BC is about structure, not error rate. Performance depends on whether those bottleneck splits align well with the true class geometry and how the downstream logic resolves uncertain regions.
A useful mental model is: RF importance tells you what reduces impurity; BC tells you what holds the decision program together.
BC bottleneck cloud in PCA space
Figure 6 visualizes where bottleneck logic tends to concentrate by projecting samples into PCA space and overlaying a “bottleneck cloud.” The key intuition is that high-BC predicates tend to activate around transition zones, where class assignment is less straightforward.

Figure 6 — PCA Projection and BC bottlenecks highlighted by blue color.
In Iris, this pattern is particularly clear:
- The left cluster (largely corresponding to setosa) is relatively isolated and “easy”, so the decision program doesn’t need many bridges there.
- The central/right region contains the versicolor/virginica interaction, where points are closer and boundaries are more entangled. That is exactly where the model needs connective logic, predicates that route samples into the right refinement subtrees and reconcile competing decision alternatives across the model.
Interpretation: high-BC predicates concentrate around overlap regions because those are the places where the model must coordinate multiple decision modules to reach a stable class assignment. In Iris, these overlap-driven bottlenecks largely reflect the versicolor/virginica boundary, consistent with the confusion matrix, but now explained in terms of the model’s internal decision structure rather than just its final errors.
6. DPG communities
A RF is an ensemble of many trees, which means it contains many decision paths. Even for a simple dataset like Iris, that can quickly become hard to “read” as a single rule list. The DPG is the compression step: it merges all those tree paths into one predicate graph where we can inspect the model as a single decision program.
What is a community?
In graph terms, a community is a subset of nodes that are more densely connected to each other than to the rest of the graph. In DPG, this usually corresponds to predicates that:
- frequently appear together along decision paths,
- belong to the same “reasoning theme” (e.g., petal-based routing vs. sepal-based refinements),
- form a coherent submodule of the model logic.
So, communities are a practical way to translate “thousands of tree steps” into a smaller set of rule groups that you can interpret.
Figure 8 shows the raw DPG layout. Even though the Iris model is not huge, the structure is already busy: many predicates (nodes) and many observed transitions (edges). This view is valuable to appreciate the overall connectivity, but it is not yet easy to summarize.

Figure 8 — Decision Predicate Graph of a RF over Iris dataset
Now, in the Figure 9, the same graph, but nodes are colored according to their detected community. This view is where interpretation becomes much more immediate: you can visually spot clusters of predicates that operate together and see how they connect via a smaller number of cross-community links.

Figure 9 — DPG with communities identified by different colours
A few useful intuitions when you look at the community view:
- Communities ≈ decision submodules. A community often corresponds to a “block” of logic that the model reuses across trees. In Iris, one community is typically dominated by petal predicates (the main separability signal), while other communities capture refinements and edge cases.
- Cross-community links ≈ bridges/bottlenecks. When only a few edges connect two communities, those connections are often mediated by the same high-BC predicates discussed earlier. This is the structural signature of “handoff points” in the model’s reasoning.
- Community size hints at complexity. Large communities suggest broad rule families the model relies on frequently; smaller communities can correspond to specialized corrections, niche regions, or exception-handling logic.
Once communities are identified, we can summarize class logic and overlap quantitatively.
7. Why communities matter?
Communities provide a middle ground between two extremes:
- Too coarse: RF feature importance tells you what matters globally, but hides how decision logic differs across classes.
- Too detailed: individual tree paths are explicit, but overwhelming.
DPG communities address this by aggregating predicates that frequently co-occur along tree paths into coherent, class-relevant rule themes. This makes it easier to see where each class is separated, where classes share logic (overlap), and which classes require more decision structure (complexity).
To connect communities to class behavior, I summarize the DPG predicates per class and visualize them in four complementary views.

Figure 10 — (a) Class and Feature predicate counts (b) row-normalized feature by class
Figure 10(a). This heatmap counts how many distinct predicates each class uses per feature. Setosa relies on a much smaller predicate set overall (values around 2–3 per feature), while versicolor and virginica use substantially more predicates across all features. In particular, versicolor shows the highest counts on sepal length and sepal width (both 9), indicating heavier reliance on sepal-based refinements, whereas virginica places more weight on petal length (8) and generally fewer predicates on sepal width (5) compared to versicolor. Overall, this supports the classic Iris pattern: setosa is structurally simpler, while the other two classes require more rule refinement.
Figure 10(b). The row-normalized heatmap highlights how each class distributes its predicate usage across features. Versicolor is fairly balanced (roughly 0.21–0.27 across all four features), suggesting it draws on a broad mix of cues. Virginica is more petal-driven (higher share on petal length = 0.31) with a lower contribution from sepal width = 0.19. Setosa shows the most distinctive profile, with the highest share on petal length = 0.33 and equal, smaller shares (0.22) on the other features. Notably, versicolor and virginica are not identical here: they overlap in sepal length share (0.27 each), but differ more on petal length and sepal width. This nuance matches the idea that their boundary is the hardest region — similar enough to create confusion, but still driven by different rule emphases in the model.

Figure 11 — (a) Predicate volume by Class (b) Feature coverage by class
In Figure 11(a), the bar chart summarizes the predicate volume by class, i.e., how much distinct rule logic the model allocates to each label. Here, versicolor uses the largest predicate set (≈ 33), virginica follows (≈ 26), and setosa is much smaller (≈ 9). This provides a practical proxy for class complexity: the model needs a larger predicate “budget” to separate classes whose regions are less cleanly separable (especially around the versicolor/virginica boundary), while setosa can be captured with far fewer, crisper rules.
In Figure 11(b), feature coverage is constant across classes (4 for all of them), meaning each class involves predicates from all four features at least once. The key difference is therefore not whether a feature appears, but how intensely it is used, how many distinct thresholds and predicates the model needs per feature to express each class’s decision region.
What this adds beyond traditional interpretation?
A traditional RF interpretation would stop at something like: “petal length and petal width are the most important features”. That’s correct, but it is still feature-centric and does not explain class-specific structure.
By contrast, Figures 10(a)–10(b) expose the model’s internal organization:
- Which classes are structurally simple vs. complex (predicate volume, Figure 11(a)),
- Which features dominate each class’s rule profile (counts and shares, Figures 10(a)–10(b)),
- Where overlap is structurally concentrated (similarity between class profiles, Figure 10(b)).
In short, DPG communities don’t just summarize the model, they reveal how the model allocates rule logic across classes, and why versicolor and virginica remain entangled even when overall accuracy is high.
8. DPG community ranges vs. dataset ranges
Figure 12 compares, for each class, the empirical class range in the dataset (gray band) with the community-derived DPG range (blue), together with the DPG min/max bounds (green/red). This is a practical sanity check: it tells you whether the model is simply reproducing the raw data spread or whether it learns tighter, class-defining intervals.
Three observations stand out in the Figure 12:
- Range tightening is strongest for the discriminative petal features. For setosa, the DPG range for petal length and petal width is compact and tightly aligned with the class band, matching the intuition that setosa is largely isolated and can be captured with a few crisp thresholds.
- Versicolor and virginica remain broader and partially overlapping. In the versicolor and virginica panels, the blue ranges are often wider and closer to the dataset bands, reflecting that the model must accommodate more variability and rely on combinations of predicates rather than a single clean cut. This mirrors the confusion pattern concentrated on the versicolor/virginica boundary.
- When DPG bounds extend beyond the empirical class range, it reflects routing logic, not a “wrong” boundary.
A DPG community captures predicates that are frequently traversed together, not predicates that are all simultaneously true. Some predicates behave as permissive gates (constraints): they are useful checkpoints for routing even if their threshold lies outside the observed class extremes. Taking the complementary branch at such checkpoints (the
>side instead of the≤side, represented by a different predicate node) typically routes an instance into a different rule module, often associated with competing classes, especially in overlap regions.

Figure 12 — Data Ranges vs Class Communities ranges
Overall, Figure 12 complements the earlier range-width summary by showing where those widths come from: DPG communities extract class-relevant slices of feature space, tightening boundaries when the class is easy (setosa) and remaining broader where the geometry is intrinsically ambiguous (versicolor vs. virginica).
9. Main DPG contributions in this benchmark
DPG extends standard model (e.g., Random Forest) interpretation by adding a structural, rule-centric view of the model:
- Global rule topology: moves from isolated feature rankings to a connected view of how predicates chain into a decision program.
- Predicate-level influence (LRC): highlights the specific threshold rules that act as global routers and organize downstream reasoning.
- Bottleneck routing (BC): identifies bridge predicates that connect major decision regions, often concentrating near overlap zones.
- Community-level class semantics: frames class logic as coherent rule modules (predicate ecosystems), not just split frequencies.
- Overlap diagnostics: reveals where classes share communities/predicate themes, marking regions that are structurally prone to confusion.
- Class complexity profiling: treats complexity as a property of the predicate organization (rule volume, modularity, and routing depth), not only performance.
- Boundary validation vs. dataset statistics: compares community-derived class ranges with empirical class distributions to sanity-check the learned decision structure.
10. References and related work
Original DPG proposal
Extended DPG (Isolation Forest)
Real-life applications of DPG
- Moradbeikie, A., Ayub da Costa Barbon, A. P., Grigore, I. M., Barbin, D. F., & Barbon Junior, S. (2025). Process Mining of Sensor Data for Predictive Process Monitoring: A HACCP-Guided Pasteurization Study Case. Systems, 13(11), 935
- Moradbeikie, A., Bregant, L., Guido, R. C., & Barbon Junior, S. (2026). Real-time and explainable non-destructive nut classification using spike-triggered acoustic sensing. Computers and Electronics in Agriculture, 244, 111502
Next Episode: Episode 2: Wine
메타데이터
- post_id
- c8816db2857d
- slug
- dpgexplainer-saga-benchmarks-episode-1-iris-c8816db2857d
- url
- https://medium.com/@sbarbonjr/dpgexplainer-saga-benchmarks-episode-1-iris-c8816db2857d
- canonical_url
- https://medium.com/@sbarbonjr/dpgexplainer-saga-benchmarks-episode-1-iris-c8816db2857d
- author_url
- https://medium.com/@sbarbonjr
- status
- ok
- fetched_at
- 2026-06-25 16:53:31