pulsatrix 1.1.0
Loading...
Searching...
No Matches
prototypes.hpp File Reference

Explaining by example (XAI-4): the background inputs nearest one input that the model treats the same way and differently, and ProtoDash's weighted prototypes that summarize a dataset (Gurumoorthy, Dhurandhar, Cecchi and Aggarwal, ICDM 2019). More...

#include <cstdint>
#include <functional>
#include <vector>
#include "pulsatrix/json.hpp"
#include "pulsatrix/tensor.hpp"
Include dependency graph for prototypes.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::PrototypeOptions
 FindPrototypes()' settings. More...
 
struct  pulsatrix::Example
 One background example. More...
 
struct  pulsatrix::PrototypeResult
 FindPrototypes()' result. More...
 
struct  pulsatrix::ProtoDashOptions
 ProtoDash()'s settings. More...
 
struct  pulsatrix::ProtoDashResult
 ProtoDash()'s result. More...
 

Namespaces

namespace  pulsatrix
 

Typedefs

using pulsatrix::EmbedFn = std::function< std::vector< float >(const Tensor &input)>
 Maps an input to the vector distances are measured in.
 

Functions

PrototypeResult pulsatrix::FindPrototypes (const std::function< Tensor(const Tensor &)> &predict, const Tensor &input, const std::vector< Tensor > &background, const PrototypeOptions &options={})
 The background examples nearest input that the model classes the same way, and those it classes differently. Classes are the index of the model's largest output.
 
ProtoDashResult pulsatrix::ProtoDash (const std::vector< Tensor > &source, const std::vector< Tensor > &target, const ProtoDashOptions &options={})
 ProtoDash: chooses up to options.count points of source, with weights, whose weighted kernel mean best matches the kernel mean of target (an MMD criterion).
 
JsonValue pulsatrix::ToJson (const PrototypeResult &result)
 The result as a pulsatrix.prototypes.v1 document.
 

Detailed Description

Explaining by example (XAI-4): the background inputs nearest one input that the model treats the same way and differently, and ProtoDash's weighted prototypes that summarize a dataset (Gurumoorthy, Dhurandhar, Cecchi and Aggarwal, ICDM 2019).

"This input is classed like these, and unlike those" is often easier to check than a heatmap. The nearest same-class examples are the input's prototypes; the nearest examples of another class are its contrasts, the closest cases where the model decided differently.

Distances are Euclidean, either in the input space with a per-feature scale (pass MedianAbsoluteDeviation() for tabular data in mixed units) or in a representation the caller computes, such as a layer's activations.