pulsatrix
Loading...
Searching...
No Matches
pulsatrix::PDP Class Reference

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>

Public Member Functions

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.
 

Detailed Description

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.

Member Function Documentation

◆ 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
predictForward-pass callable: input Tensor in, output Tensor out.
backgroundReference instances to average over. Must be non-empty; every instance must have the same shape.
feature_indexWhich feature to sweep (0-based, flat index).
target_indexWhich output element to read (0-based, flat index).
grid_minFirst grid value.
grid_maxLast grid value (inclusive). Ignored (only grid_min used) when grid_size == 1.
grid_sizeNumber of evenly-spaced grid points, >= 1.
backendBackend 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_argumentif 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: