pulsatrix 1.1.0
Loading...
Searching...
No Matches
svg.hpp
Go to the documentation of this file.
1
18#pragma once
19
20#include <cstdint>
21#include <string>
22#include <vector>
23
25
26namespace pulsatrix {
27
29struct SvgOptions {
32 int width = 640;
34 std::string title;
36 int font_size = 12;
37};
38
46[[nodiscard]] std::string RenderBarChartSvg(const AttributionDocument& doc, int top_k = 10, const SvgOptions& options = {});
47
55[[nodiscard]] std::string RenderWaterfallSvg(const AttributionDocument& doc, float baseline_value,
56 const SvgOptions& options = {});
57
69[[nodiscard]] std::string RenderHeatmapSvg(const HeatmapDocument& doc, const SvgOptions& options = {});
70
81[[nodiscard]] std::string RenderTokenStripSvg(const TokenRelevanceDocument& doc, const SvgOptions& options = {});
82
92[[nodiscard]] std::string RenderBeeswarmSvg(const std::vector<AttributionDocument>& docs,
93 const std::vector<int64_t>& feature_indices,
94 const SvgOptions& options = {});
95
97enum class IceStyle {
99 Raw,
101 Centered,
104};
105
113
122[[nodiscard]] std::string RenderPartialDependenceSvg(const PartialDependenceDocument& doc,
123 const PartialDependenceSvgOptions& pd = {},
124 const SvgOptions& options = {});
125
134[[nodiscard]] std::string RenderTornadoSvg(const SensitivityDocument& doc, int top_k = 10,
135 const SvgOptions& options = {});
136
145[[nodiscard]] std::string RenderCounterfactualSvg(const CounterfactualDocument& doc, int max_rows = 12,
146 const SvgOptions& options = {});
147
156[[nodiscard]] std::string RenderMorrisSvg(const MorrisDocument& doc, const SvgOptions& options = {});
157
166[[nodiscard]] std::string RenderSobolSvg(const SobolDocument& doc, int top_k = 10, const SvgOptions& options = {});
167
178[[nodiscard]] std::string RenderProjectionSvg(const ProjectionDocument& doc, int x_axis = 0, int y_axis = 1,
179 const SvgOptions& options = {});
180
190[[nodiscard]] std::string RenderCounterfactualSetSvg(const std::vector<CounterfactualDocument>& docs,
191 const SvgOptions& options = {});
192
193} // namespace pulsatrix
Versioned JSON documents (pulsatrix.<kind>.v1) that every renderer reads.
Definition acquisition_functions.hpp:16
std::string RenderHeatmapSvg(const HeatmapDocument &doc, const SvgOptions &options={})
The heatmap's grid with square cells and a color bar. Signed grids use the diverging map on a range s...
std::string RenderTokenStripSvg(const TokenRelevanceDocument &doc, const SvgOptions &options={})
The text's pieces (tokens or words) in reading order, wrapped across lines, each on a background colo...
std::string RenderWaterfallSvg(const AttributionDocument &doc, float baseline_value, const SvgOptions &options={})
A waterfall from baseline_value through each feature's contribution, in the document's feature order,...
std::string RenderTornadoSvg(const SensitivityDocument &doc, int top_k=10, const SvgOptions &options={})
A tornado chart: one row per feature, the top_k with the largest swing first. Each row has two bars f...
std::string RenderSobolSvg(const SobolDocument &doc, int top_k=10, const SvgOptions &options={})
Sobol indices: one row per feature, the top_k with the largest total order first, with a bar for the ...
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.
std::string RenderBeeswarmSvg(const std::vector< AttributionDocument > &docs, const std::vector< int64_t > &feature_indices, const SvgOptions &options={})
One beeswarm row per feature in feature_indices: each point is one document's value for that feature,...
std::string RenderCounterfactualSvg(const CounterfactualDocument &doc, int max_rows=12, const SvgOptions &options={})
What a counterfactual changed: a verdict line (whether it reaches the target, and the output before a...
std::string RenderBarChartSvg(const AttributionDocument &doc, int top_k=10, const SvgOptions &options={})
Horizontal bars of the top_k features with the largest |attribution|, largest first,...
IceStyle
Which form of the ICE curves RenderPartialDependenceSvg draws (CFS-1).
Definition svg.hpp:97
std::string RenderMorrisSvg(const MorrisDocument &doc, const SvgOptions &options={})
Morris screening as a scatter of mu* (importance) against sigma (how much the effect varies),...
std::string RenderPartialDependenceSvg(const PartialDependenceDocument &doc, const PartialDependenceSvgOptions &pd={}, const SvgOptions &options={})
A partial dependence plot: thin ICE curves under the bold average, over the feature's grid,...
std::string RenderCounterfactualSetSvg(const std::vector< CounterfactualDocument > &docs, const SvgOptions &options={})
Several counterfactuals of one input side by side (CFS-7): a column for the input and one per counter...
std::string RenderProjectionSvg(const ProjectionDocument &doc, int x_axis=0, int y_axis=1, const SvgOptions &options={})
A projection as a scatter plot of two of its axes (INT-5), both on one scale so distances on the page...
pulsatrix.attribution.v1: an Attribution's values, shape, method and metadata.
Definition document.hpp:58
pulsatrix.counterfactual.v1: an input, its counterfactual, and what reaching the target cost (CFS-5).
Definition document.hpp:316
pulsatrix.heatmap.v1: a row-major grid of values with optional axis labels.
Definition document.hpp:79
pulsatrix.morris.v1: Morris screening statistics per feature (CFS-4).
Definition document.hpp:350
pulsatrix.partial_dependence.v1: a partial dependence curve over one feature, with the individual (IC...
Definition document.hpp:239
Options for RenderPartialDependenceSvg.
Definition svg.hpp:107
int max_curves
At most this many ICE curves are drawn, evenly spaced through the instances; the average still uses t...
Definition svg.hpp:111
IceStyle style
Definition svg.hpp:108
pulsatrix.projection.v1: inputs placed in a few dimensions (INT-5), such as their first principal com...
Definition document.hpp:398
pulsatrix.sensitivity.v1: how one output moves when each input feature, alone, goes to a low and a hi...
Definition document.hpp:285
pulsatrix.sobol.v1: first- and total-order Sobol indices per feature (CFS-4).
Definition document.hpp:365
Options shared by every SVG chart.
Definition svg.hpp:29
std::string title
Drawn above the chart when not empty.
Definition svg.hpp:34
int width
Figure width in pixels (a heatmap narrower than this ends at its color bar). The height follows from ...
Definition svg.hpp:32
int font_size
Base font size in pixels.
Definition svg.hpp:36
pulsatrix.token_relevance.v1: relevance scores over the pieces of a text, in reading order....
Definition document.hpp:104