pulsatrix 1.1.0
Loading...
Searching...
No Matches

Individual conditional expectation (ICE), its centered and derivative forms, two-feature partial dependence (CFS-1) and accumulated local effects (CFS-2). More...

#include <cstdint>
#include <functional>
#include <vector>
#include "pulsatrix/tensor.hpp"
Include dependency graph for ice.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pulsatrix::IceResult
 ICE curves for one feature: curves[i][k] = f(x_i with feature j set to grid[k])[target]. More...
 
struct  pulsatrix::PartialDependence2D
 Partial dependence on two features at once, over a grid of value pairs. More...
 
struct  pulsatrix::AleResult
 First-order accumulated local effects (Apley and Zhu 2020) of one feature. More...
 

Namespaces

namespace  pulsatrix
 

Functions

std::vector< float > pulsatrix::FeatureGrid (const std::vector< Tensor > &background, int64_t feature_index, int64_t grid_size=100, float lower_percentile=0.05f, float upper_percentile=0.95f)
 An evenly spaced grid for one feature, built the way scikit-learn's partial_dependence builds it: the feature's distinct values when there are fewer than grid_size of them, otherwise grid_size points from the lower to the upper percentile of the feature's values (scipy.stats.mstats.mquantiles with its default plotting positions).
 
IceResult pulsatrix::ComputeIce (const std::function< Tensor(const Tensor &)> &predict, const std::vector< Tensor > &instances, int64_t feature_index, int64_t target_index, const std::vector< float > &grid)
 Computes ICE curves for every instance.
 
PartialDependence2D pulsatrix::ComputePartialDependence2D (const std::function< Tensor(const Tensor &)> &predict, const std::vector< Tensor > &background, int64_t feature_x, int64_t feature_y, int64_t target_index, const std::vector< float > &grid_x, const std::vector< float > &grid_y)
 Two-feature partial dependence: for every pair (grid_x[c], grid_y[r]), the mean over the background of the prediction with both features set. Where it isn't the sum of the two one-feature curves, the features interact.
 
AleResult pulsatrix::ComputeAle (const std::function< Tensor(const Tensor &)> &predict, const std::vector< Tensor > &instances, int64_t feature_index, int64_t target_index, int64_t num_bins=20)
 Computes first-order ALE the way PyALE 1.2 (and R's ALEPlot) does: edges at the feature's type-1 quantiles (num_bins + 1 of them, duplicates dropped), bins closed on the right with the first also holding the minimum, and centering by the count-weighted mean of each bin's midpoint effect.
 

Detailed Description

Individual conditional expectation (ICE), its centered and derivative forms, two-feature partial dependence (CFS-1) and accumulated local effects (CFS-2).