PDP_j(v) = (1/|B|) * sum_{b in B} f(x_j=v, x_{-j}=b_{-j}) – for each grid value v, replace every background instance's feature j with v (keeping its other features), average the model's output over the whole background set.
More...
#include <pdp.hpp>
|
| Attribution | explain (const std::function< Tensor(const Tensor &)> &predict, const std::vector< Tensor > &background, int64_t feature_index, int64_t target_index, float grid_min, float grid_max, int64_t grid_size, DeviceBackend *backend) const |
| | Computes the PDP curve for one feature.
|
| |
PDP_j(v) = (1/|B|) * sum_{b in B} f(x_j=v, x_{-j}=b_{-j}) – for each grid value v, replace every background instance's feature j with v (keeping its other features), average the model's output over the whole background set.
- Note
- Unlike every other explainer in this project, PDP is genuinely global, not per-instance – it describes the model's average response to one feature, not an explanation of a single prediction.
-
Takes a caller-supplied background set, not a dataset loader – no dataset infrastructure exists in this codebase (same gap real-MNIST-training discussions surfaced), same "caller supplies reference data" pattern IntegratedGradients' baseline and LIME's perturbation-around-x already established.
-
Takes a forward-pass callable, not ExplainerContext& – model-agnosticism by construction, same pattern as LIME/KernelSHAP.
-
Device-generic host boundary: each background instance is read to the host once; the swept copies are uploaded beside it and only f(z)[target] is read back.
◆ explain()
| Attribution pulsatrix::PDP::explain |
( |
const std::function< Tensor(const Tensor &)> & |
predict, |
|
|
const std::vector< Tensor > & |
background, |
|
|
int64_t |
feature_index, |
|
|
int64_t |
target_index, |
|
|
float |
grid_min, |
|
|
float |
grid_max, |
|
|
int64_t |
grid_size, |
|
|
DeviceBackend * |
backend |
|
) |
| const |
|
inline |
Computes the PDP curve for one feature.
- Parameters
-
| predict | Forward-pass callable: input Tensor in, output Tensor out. |
| background | Reference instances to average over. Must be non-empty; every instance must have the same shape. |
| feature_index | Which feature to sweep (0-based, flat index). |
| target_index | Which output element to read (0-based, flat index). |
| grid_min | First grid value. |
| grid_max | Last grid value (inclusive). Ignored (only grid_min used) when grid_size == 1. |
| grid_size | Number of evenly-spaced grid points, >= 1. |
| backend | Backend to allocate intermediate tensors through. |
- Returns
- An Attribution with method "pdp", values = the grid_size-length PDP curve, and metadata recording the sweep parameters used.
- Exceptions
-
| std::invalid_argument | if background is empty – external boundary (campaign_exai_dl_library_adversarial_hardening.md, Mission 2, finding 10): escalated from PULSATRIX_ASSERT-only, which left this a raw out-of-bounds background[0] access in Release builds. |
The documentation for this class was generated from the following file: