pulsatrix
Loading...
Searching...
No Matches
plot_data.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <cstdint>
8#include <string>
9#include <vector>
10
13#include "pulsatrix/dataset.hpp"
14
15namespace pulsatrix {
16
18struct BarSeries {
19 std::vector<std::string> labels;
20 std::vector<float> values;
21};
22
39[[nodiscard]] BarSeries ToFeatureImportanceBars(const Attribution& attr, int top_k);
40
43 std::string label;
44 float delta;
46};
47
62[[nodiscard]] std::vector<WaterfallStep> ToWaterfallSteps(const Attribution& attr, float baseline_value);
63
66 float bottom;
67 float top;
70};
71
82[[nodiscard]] std::vector<WaterfallBar> ToWaterfallBars(const std::vector<WaterfallStep>& steps, float baseline_value);
83
86 std::vector<float> values;
87 int64_t rows;
88 int64_t cols;
89};
90
102[[nodiscard]] HeatmapGrid ToSaliencyHeatmap(const Attribution& attr);
103
116
128
131 float x;
132 float y;
133};
134
151[[nodiscard]] std::vector<BeeswarmPoint> ToBeeswarmPoints(const std::vector<Attribution>& runs, int64_t feature_index);
152
159[[nodiscard]] std::string CircuitNodeDisplayLabel(const CircuitNode& node);
160
163 std::vector<float> bin_edges;
164 std::vector<int64_t> counts;
165};
166
180[[nodiscard]] HistogramBins ToFieldHistogramBins(const Dataset& dataset, int64_t field_index, int num_bins);
181
184 std::vector<unsigned char> pixels;
185 int64_t height;
186 int64_t width;
187};
188
201[[nodiscard]] RgbImageBuffer ToRgbImageBuffer(const Tensor& image_chw);
202
203} // namespace pulsatrix
First-class explanation result type – values, method, and metadata together.
Self-contained circuit-graph artifact – scored nodes and weighted edges.
Random-access dataset abstraction – pulsatrix's analogue of PyTorch's torch.utils....
Definition dataset.hpp:33
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Random-access dataset abstraction – Sample, Dataset (size()/get()).
Definition acquisition_functions.hpp:16
std::vector< BeeswarmPoint > ToBeeswarmPoints(const std::vector< Attribution > &runs, int64_t feature_index)
Converts one feature's attribution value across many repeated/independent runs into jittered (x,...
RgbImageBuffer ToRgbImageBuffer(const Tensor &image_chw)
Converts a decoded image Tensor into an interleaved-RGB byte buffer for GPU texture upload (the data-...
HeatmapGrid ToSaliencyHeatmap(const Attribution &attr)
Reshapes an Attribution's values into a 2D grid for a saliency overlay heatmap.
std::string CircuitNodeDisplayLabel(const CircuitNode &node)
Human-readable label for a CircuitGraph node: the node's own label when it has one,...
TopKResult top_k(const Tensor &input, int64_t k, bool largest=true)
Selects the k largest (or smallest) entries of every row along the last dimension.
HistogramBins ToFieldHistogramBins(const Dataset &dataset, int64_t field_index, int num_bins)
Bins one Sample field's values (flattened across every sample's Tensor at that field position,...
std::vector< WaterfallStep > ToWaterfallSteps(const Attribution &attr, float baseline_value)
Converts an Attribution's per-feature values into a cascading waterfall from a real baseline to the f...
std::vector< WaterfallBar > ToWaterfallBars(const std::vector< WaterfallStep > &steps, float baseline_value)
Converts waterfall steps into floating bars, each spanning from the previous running total to its own...
BarSeries ToFeatureImportanceBars(const Attribution &attr, int top_k)
Converts an Attribution's per-feature values into labeled, magnitude-sorted bars for a horizontal bar...
HeatmapColorScale ComputeHeatmapColorScale(const HeatmapGrid &grid)
Chooses a heatmap's color scale from its values (hc_information_visualization.md SS4: sequential maps...
An explanation result: the raw attribution values, the method that produced them, and any relevant me...
Definition attribution.hpp:23
One feature-importance bar: a label and a signed value (sign carries direction).
Definition plot_data.hpp:18
std::vector< std::string > labels
Definition plot_data.hpp:19
std::vector< float > values
Definition plot_data.hpp:20
One beeswarm point: the attribution value (x) and a collision-avoidance vertical offset (y).
Definition plot_data.hpp:130
float y
Definition plot_data.hpp:132
float x
Definition plot_data.hpp:131
One node of a CircuitGraph: a computation-graph node plus its importance score.
Definition circuit_graph.hpp:20
The color-scale range and colormap family a heatmap's values call for.
Definition plot_data.hpp:105
float scale_max
Value mapped to the colormap's high end.
Definition plot_data.hpp:109
bool is_signed
True iff the grid has any negative value: the caller must then use a diverging colormap (DivergingCol...
Definition plot_data.hpp:114
float scale_min
Value mapped to the colormap's low end.
Definition plot_data.hpp:107
A row-major 2D grid of unsigned magnitude values, ready for a heatmap plot.
Definition plot_data.hpp:85
int64_t cols
Definition plot_data.hpp:88
int64_t rows
Definition plot_data.hpp:87
std::vector< float > values
Definition plot_data.hpp:86
Equal-width histogram bins: rows.size() == counts.size() + 1 edges.
Definition plot_data.hpp:162
std::vector< int64_t > counts
Definition plot_data.hpp:164
std::vector< float > bin_edges
Definition plot_data.hpp:163
An interleaved-RGB, row-major byte buffer ready for a texture upload.
Definition plot_data.hpp:183
int64_t height
Definition plot_data.hpp:185
int64_t width
Definition plot_data.hpp:186
std::vector< unsigned char > pixels
Definition plot_data.hpp:184
One floating waterfall bar: spans [bottom, top] on the value axis.
Definition plot_data.hpp:65
float top
Definition plot_data.hpp:67
float bottom
Definition plot_data.hpp:66
bool increase
True for a non-negative delta (drawn in the "increase" color).
Definition plot_data.hpp:69
One waterfall step: a labeled delta and the running cumulative value after it.
Definition plot_data.hpp:42
float cumulative
Definition plot_data.hpp:45
float delta
Definition plot_data.hpp:44
std::string label
Definition plot_data.hpp:43