shap-svg 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ParsedExplanation, D as DisplayRows, V as ValuePrecision, R as RowSort } from './format-wEav_cPe.cjs';
2
- export { a as DisplayRow, E as Explanation, I as InvalidExplanationError, U as UnsupportedContractVersionError, f as formatFeatureLabel, b as formatLevel, c as formatShapValue, s as sortDisplayRows } from './format-wEav_cPe.cjs';
1
+ import { P as ParsedExplanation, a as PlotLabels, D as DisplayRows, V as ValuePrecision, R as RowSort } from './labels-7wofev8M.cjs';
2
+ export { b as DisplayRow, E as Explanation, I as InvalidExplanationError, U as UnsupportedContractVersionError, f as formatFeatureLabel, c as formatLevel, d as formatShapValue, r as resolveLabels, s as shapLabels, e as sortDisplayRows } from './labels-7wofev8M.cjs';
3
3
 
4
4
  /**
5
5
  * Taxonomy-aware views of an Explanation.
@@ -68,7 +68,7 @@ declare function orderFeatures(importance: number[]): number[];
68
68
  * absorbs the Feature ranked `maxDisplay` — so maxDisplay=15 shows 14 real Features. The default
69
69
  * corrected mode shows `maxDisplay` real Features and adds the Other features row alongside.
70
70
  */
71
- declare function collapseToDisplay(featureNames: string[], importance: number[], order: number[], maxDisplay: number, faithfulOtherRow: boolean): DisplayRows;
71
+ declare function collapseToDisplay(featureNames: string[], importance: number[], order: number[], maxDisplay: number, faithfulOtherRow: boolean, labels?: PlotLabels): DisplayRows;
72
72
 
73
73
  type AxisTick = {
74
74
  value: number;
@@ -95,6 +95,8 @@ type BarLayoutOptions = {
95
95
  marginLeft: number;
96
96
  marginRight: number;
97
97
  marginTop: number;
98
+ /** Resolved wording; SHAP's when omitted. */
99
+ labels?: PlotLabels;
98
100
  };
99
101
  type BarGeometry = {
100
102
  label: string;
@@ -170,6 +172,8 @@ type WaterfallLayoutOptions = {
170
172
  marginTop: number;
171
173
  /** Decimal places for the bar labels. Display only; omit for 3 significant figures. */
172
174
  decimals?: ValuePrecision;
175
+ /** Resolved wording; SHAP's when omitted. */
176
+ labels?: PlotLabels;
173
177
  };
174
178
  type Point = {
175
179
  x: number;
@@ -245,13 +249,94 @@ type WaterfallLayout = {
245
249
  * The value-space part of shap/plots/_waterfall.py::waterfall_legacy.
246
250
  * It walks backward from f(x), leaving pixel scaling and arrowheads to waterfallLayout.
247
251
  */
248
- declare function waterfallRows(explanation: ParsedExplanation, sampleIndex: number, maxDisplay: number, faithfulOtherRow: boolean): WaterfallRows;
252
+ declare function waterfallRows(explanation: ParsedExplanation, sampleIndex: number, maxDisplay: number, faithfulOtherRow: boolean, labels?: PlotLabels): WaterfallRows;
249
253
  declare function waterfallLayout(valueRows: WaterfallRows, opts: WaterfallLayoutOptions): WaterfallLayout;
250
254
 
251
255
  type ColormapName = "red_blue" | "red_white_blue";
252
256
  /** Samples a captured SHAP colour map, interpolating adjacent LUT entries in sRGB. */
253
257
  declare function sampleColormap(name: ColormapName, t: number): string;
254
258
 
259
+ type ColorBarSpec = {
260
+ colormap: ColormapName;
261
+ /** The labels at the bottom and top ends of the bar. */
262
+ tickLabels: [string, string];
263
+ /** matplotlib's offset text ("1e−5"), when the tick labels are scaled. */
264
+ offsetText?: string;
265
+ label: string;
266
+ /** set_label's labelpad, in pt: 0 for the beeswarm, -10 for the heatmap. */
267
+ labelPad: number;
268
+ };
269
+ type ColorBarStep = {
270
+ y: number;
271
+ height: number;
272
+ color: string;
273
+ };
274
+ type ColorBarTick = {
275
+ y: number;
276
+ label: string;
277
+ };
278
+ type ColorBarGeometry = {
279
+ x: number;
280
+ y1: number;
281
+ y2: number;
282
+ width: number;
283
+ /** The colour map from bottom to top, as stacked bands. */
284
+ steps: ColorBarStep[];
285
+ tickX: number;
286
+ tickFontSize: number;
287
+ ticks: ColorBarTick[];
288
+ offsetText?: {
289
+ x: number;
290
+ y: number;
291
+ text: string;
292
+ };
293
+ /** Drawn rotated -90° about (x, y), reading bottom to top. */
294
+ label: {
295
+ x: number;
296
+ y: number;
297
+ text: string;
298
+ fontSize: number;
299
+ };
300
+ /** Right edge of everything the bar draws. */
301
+ right: number;
302
+ };
303
+ /** How far right of its own left edge a bar of this height draws. */
304
+ declare function colorBarExtent(height: number, spec: ColorBarSpec): number;
305
+ /**
306
+ * Width of the plot once a colour bar beside it has room.
307
+ *
308
+ * matplotlib's colorbar pad is a fraction of the axes it steals from, so the gap
309
+ * grows with the plot; `minGap` keeps it clear of anything drawn between the two,
310
+ * such as the heatmap's side bars. When the right margin cannot hold the bar, the
311
+ * plot gives up the difference rather than the bar being clipped.
312
+ */
313
+ declare function fitColorBar(opts: {
314
+ plotWidth: number;
315
+ available: number;
316
+ gapRatio: number;
317
+ minGap: number;
318
+ extent: number;
319
+ }): {
320
+ plotWidth: number;
321
+ gap: number;
322
+ };
323
+ /** Places a vertical colour bar with its left edge at `x`, spanning y1 (top) to y2. */
324
+ declare function colorBarLayout(spec: ColorBarSpec, position: {
325
+ x: number;
326
+ y1: number;
327
+ y2: number;
328
+ }): ColorBarGeometry;
329
+ /**
330
+ * Tick labels as matplotlib's ScalarFormatter writes them for a fixed set of
331
+ * ticks: the decimals are the fewest that keep every tick exact to a thousandth
332
+ * of the tick range, and the minus sign is U+2212. Ticks outside the power
333
+ * limits are scaled, with the scale returned as matplotlib's offset text.
334
+ */
335
+ declare function scalarFormatterLabels(locs: number[]): {
336
+ labels: string[];
337
+ offsetText?: string;
338
+ };
339
+
255
340
  declare const BEESWARM_MISSING_COLOR = "#777777";
256
341
  declare const BEESWARM_ROW_HEIGHT = 0.4;
257
342
  type BeeswarmPoint = {
@@ -288,6 +373,10 @@ type BeeswarmLayoutOptions = {
288
373
  marginRight: number;
289
374
  marginTop: number;
290
375
  dotRadius: number;
376
+ /** Draw SHAP's feature value colour bar right of the plot. */
377
+ colorBar?: boolean;
378
+ /** Resolved wording; SHAP's when omitted. */
379
+ labels?: PlotLabels;
291
380
  };
292
381
  type BeeswarmPointGeometry = Omit<BeeswarmPoint, "x" | "y"> & {
293
382
  x: number;
@@ -310,13 +399,15 @@ type BeeswarmLayout = {
310
399
  /** The bottom spine, which _beeswarm.py:493-495 leaves visible. */
311
400
  xSpine: AxisSpine | null;
312
401
  xTitle: AxisTitle;
402
+ /** Null unless the options asked for one. */
403
+ colorBar: ColorBarGeometry | null;
313
404
  height: number;
314
405
  };
315
406
  /**
316
407
  * Computes SHAP-compatible beeswarm rows entirely in value space. Pixel scaling belongs in
317
408
  * beeswarmLayout so golden values can be compared without a viewport.
318
409
  */
319
- declare function beeswarmRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, seed?: number, rowSort?: RowSort): BeeswarmRows;
410
+ declare function beeswarmRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, seed?: number, rowSort?: RowSort, labels?: PlotLabels): BeeswarmRows;
320
411
  /** Projects beeswarm value-space rows into SVG coordinates. */
321
412
  declare function beeswarmLayout(valueRows: BeeswarmRows, opts: BeeswarmLayoutOptions): BeeswarmLayout;
322
413
 
@@ -367,6 +458,10 @@ type HeatmapLayoutOptions = {
367
458
  marginRight: number;
368
459
  /** Top of the matrix; the f(x) line occupies the space above it. */
369
460
  marginTop: number;
461
+ /** Draw SHAP's SHAP value colour bar right of the side bars. */
462
+ colorBar?: boolean;
463
+ /** Resolved wording; SHAP's when omitted. */
464
+ labels?: PlotLabels;
370
465
  };
371
466
  type HeatmapCellGeometry = HeatmapCell & {
372
467
  x: number;
@@ -446,11 +541,13 @@ type HeatmapLayout = {
446
541
  xTitle: AxisTitle;
447
542
  plotWidth: number;
448
543
  cellWidth: number;
544
+ /** Null unless the options asked for one. */
545
+ colorBar: ColorBarGeometry | null;
449
546
  height: number;
450
547
  };
451
548
  /** Computes the SHAP-compatible orderings, collapse, colours, line, and side bars in value space. */
452
- declare function heatmapRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, rowSort?: RowSort): HeatmapRows;
549
+ declare function heatmapRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, rowSort?: RowSort, labels?: PlotLabels): HeatmapRows;
453
550
  /** Projects heatmap value-space rows into SVG geometry. */
454
551
  declare function heatmapLayout(valueRows: HeatmapRows, opts: HeatmapLayoutOptions): HeatmapLayout;
455
552
 
456
- export { type AggregatedExplanation, BEESWARM_MISSING_COLOR, BEESWARM_ROW_HEIGHT, type BarGeometry, type BarLayout, type BarLayoutOptions, type BeeswarmLayout, type BeeswarmLayoutOptions, type BeeswarmPoint, type BeeswarmPointGeometry, type BeeswarmRow, type BeeswarmRowGeometry, type BeeswarmRows, type ColormapName, DisplayRows, type GenusGrouping, type HeatmapAxisMark, type HeatmapCell, type HeatmapCellGeometry, type HeatmapColumn, type HeatmapColumnGeometry, type HeatmapLayout, type HeatmapLayoutOptions, type HeatmapLinePoint, type HeatmapRow, type HeatmapRowGeometry, type HeatmapRows, type HeatmapSideBarGeometry, type HeatmapSpine, type HeatmapYTick, NEGATIVE_COLOR, POSITIVE_COLOR, ParsedExplanation, type Point, RowSort, ValuePrecision, WATERFALL_BASE_LABEL_DY, WATERFALL_HEAD_LENGTH_PX, WATERFALL_TICK_LABEL_DY, type WaterfallArrowGeometry, type WaterfallAxisMark, type WaterfallConnector, type WaterfallLayout, type WaterfallLayoutOptions, type WaterfallRow, type WaterfallRows, type WaterfallSeparator, type WaterfallTick, type WaterfallValueLabel, aggregateByGenus, barLayout, beeswarmLayout, beeswarmRows, collapseToDisplay, genusOf, globalImportance, groupByGenus, groupExplanationByGenus, heatmapLayout, heatmapRows, orderFeatures, parseExplanation, sampleColormap, waterfallLayout, waterfallRows };
553
+ export { type AggregatedExplanation, BEESWARM_MISSING_COLOR, BEESWARM_ROW_HEIGHT, type BarGeometry, type BarLayout, type BarLayoutOptions, type BeeswarmLayout, type BeeswarmLayoutOptions, type BeeswarmPoint, type BeeswarmPointGeometry, type BeeswarmRow, type BeeswarmRowGeometry, type BeeswarmRows, type ColorBarGeometry, type ColorBarSpec, type ColorBarStep, type ColorBarTick, type ColormapName, DisplayRows, type GenusGrouping, type HeatmapAxisMark, type HeatmapCell, type HeatmapCellGeometry, type HeatmapColumn, type HeatmapColumnGeometry, type HeatmapLayout, type HeatmapLayoutOptions, type HeatmapLinePoint, type HeatmapRow, type HeatmapRowGeometry, type HeatmapRows, type HeatmapSideBarGeometry, type HeatmapSpine, type HeatmapYTick, NEGATIVE_COLOR, POSITIVE_COLOR, ParsedExplanation, PlotLabels, type Point, RowSort, ValuePrecision, WATERFALL_BASE_LABEL_DY, WATERFALL_HEAD_LENGTH_PX, WATERFALL_TICK_LABEL_DY, type WaterfallArrowGeometry, type WaterfallAxisMark, type WaterfallConnector, type WaterfallLayout, type WaterfallLayoutOptions, type WaterfallRow, type WaterfallRows, type WaterfallSeparator, type WaterfallTick, type WaterfallValueLabel, aggregateByGenus, barLayout, beeswarmLayout, beeswarmRows, collapseToDisplay, colorBarExtent, colorBarLayout, fitColorBar, genusOf, globalImportance, groupByGenus, groupExplanationByGenus, heatmapLayout, heatmapRows, orderFeatures, parseExplanation, sampleColormap, scalarFormatterLabels, waterfallLayout, waterfallRows };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as ParsedExplanation, D as DisplayRows, V as ValuePrecision, R as RowSort } from './format-wEav_cPe.js';
2
- export { a as DisplayRow, E as Explanation, I as InvalidExplanationError, U as UnsupportedContractVersionError, f as formatFeatureLabel, b as formatLevel, c as formatShapValue, s as sortDisplayRows } from './format-wEav_cPe.js';
1
+ import { P as ParsedExplanation, a as PlotLabels, D as DisplayRows, V as ValuePrecision, R as RowSort } from './labels-7wofev8M.js';
2
+ export { b as DisplayRow, E as Explanation, I as InvalidExplanationError, U as UnsupportedContractVersionError, f as formatFeatureLabel, c as formatLevel, d as formatShapValue, r as resolveLabels, s as shapLabels, e as sortDisplayRows } from './labels-7wofev8M.js';
3
3
 
4
4
  /**
5
5
  * Taxonomy-aware views of an Explanation.
@@ -68,7 +68,7 @@ declare function orderFeatures(importance: number[]): number[];
68
68
  * absorbs the Feature ranked `maxDisplay` — so maxDisplay=15 shows 14 real Features. The default
69
69
  * corrected mode shows `maxDisplay` real Features and adds the Other features row alongside.
70
70
  */
71
- declare function collapseToDisplay(featureNames: string[], importance: number[], order: number[], maxDisplay: number, faithfulOtherRow: boolean): DisplayRows;
71
+ declare function collapseToDisplay(featureNames: string[], importance: number[], order: number[], maxDisplay: number, faithfulOtherRow: boolean, labels?: PlotLabels): DisplayRows;
72
72
 
73
73
  type AxisTick = {
74
74
  value: number;
@@ -95,6 +95,8 @@ type BarLayoutOptions = {
95
95
  marginLeft: number;
96
96
  marginRight: number;
97
97
  marginTop: number;
98
+ /** Resolved wording; SHAP's when omitted. */
99
+ labels?: PlotLabels;
98
100
  };
99
101
  type BarGeometry = {
100
102
  label: string;
@@ -170,6 +172,8 @@ type WaterfallLayoutOptions = {
170
172
  marginTop: number;
171
173
  /** Decimal places for the bar labels. Display only; omit for 3 significant figures. */
172
174
  decimals?: ValuePrecision;
175
+ /** Resolved wording; SHAP's when omitted. */
176
+ labels?: PlotLabels;
173
177
  };
174
178
  type Point = {
175
179
  x: number;
@@ -245,13 +249,94 @@ type WaterfallLayout = {
245
249
  * The value-space part of shap/plots/_waterfall.py::waterfall_legacy.
246
250
  * It walks backward from f(x), leaving pixel scaling and arrowheads to waterfallLayout.
247
251
  */
248
- declare function waterfallRows(explanation: ParsedExplanation, sampleIndex: number, maxDisplay: number, faithfulOtherRow: boolean): WaterfallRows;
252
+ declare function waterfallRows(explanation: ParsedExplanation, sampleIndex: number, maxDisplay: number, faithfulOtherRow: boolean, labels?: PlotLabels): WaterfallRows;
249
253
  declare function waterfallLayout(valueRows: WaterfallRows, opts: WaterfallLayoutOptions): WaterfallLayout;
250
254
 
251
255
  type ColormapName = "red_blue" | "red_white_blue";
252
256
  /** Samples a captured SHAP colour map, interpolating adjacent LUT entries in sRGB. */
253
257
  declare function sampleColormap(name: ColormapName, t: number): string;
254
258
 
259
+ type ColorBarSpec = {
260
+ colormap: ColormapName;
261
+ /** The labels at the bottom and top ends of the bar. */
262
+ tickLabels: [string, string];
263
+ /** matplotlib's offset text ("1e−5"), when the tick labels are scaled. */
264
+ offsetText?: string;
265
+ label: string;
266
+ /** set_label's labelpad, in pt: 0 for the beeswarm, -10 for the heatmap. */
267
+ labelPad: number;
268
+ };
269
+ type ColorBarStep = {
270
+ y: number;
271
+ height: number;
272
+ color: string;
273
+ };
274
+ type ColorBarTick = {
275
+ y: number;
276
+ label: string;
277
+ };
278
+ type ColorBarGeometry = {
279
+ x: number;
280
+ y1: number;
281
+ y2: number;
282
+ width: number;
283
+ /** The colour map from bottom to top, as stacked bands. */
284
+ steps: ColorBarStep[];
285
+ tickX: number;
286
+ tickFontSize: number;
287
+ ticks: ColorBarTick[];
288
+ offsetText?: {
289
+ x: number;
290
+ y: number;
291
+ text: string;
292
+ };
293
+ /** Drawn rotated -90° about (x, y), reading bottom to top. */
294
+ label: {
295
+ x: number;
296
+ y: number;
297
+ text: string;
298
+ fontSize: number;
299
+ };
300
+ /** Right edge of everything the bar draws. */
301
+ right: number;
302
+ };
303
+ /** How far right of its own left edge a bar of this height draws. */
304
+ declare function colorBarExtent(height: number, spec: ColorBarSpec): number;
305
+ /**
306
+ * Width of the plot once a colour bar beside it has room.
307
+ *
308
+ * matplotlib's colorbar pad is a fraction of the axes it steals from, so the gap
309
+ * grows with the plot; `minGap` keeps it clear of anything drawn between the two,
310
+ * such as the heatmap's side bars. When the right margin cannot hold the bar, the
311
+ * plot gives up the difference rather than the bar being clipped.
312
+ */
313
+ declare function fitColorBar(opts: {
314
+ plotWidth: number;
315
+ available: number;
316
+ gapRatio: number;
317
+ minGap: number;
318
+ extent: number;
319
+ }): {
320
+ plotWidth: number;
321
+ gap: number;
322
+ };
323
+ /** Places a vertical colour bar with its left edge at `x`, spanning y1 (top) to y2. */
324
+ declare function colorBarLayout(spec: ColorBarSpec, position: {
325
+ x: number;
326
+ y1: number;
327
+ y2: number;
328
+ }): ColorBarGeometry;
329
+ /**
330
+ * Tick labels as matplotlib's ScalarFormatter writes them for a fixed set of
331
+ * ticks: the decimals are the fewest that keep every tick exact to a thousandth
332
+ * of the tick range, and the minus sign is U+2212. Ticks outside the power
333
+ * limits are scaled, with the scale returned as matplotlib's offset text.
334
+ */
335
+ declare function scalarFormatterLabels(locs: number[]): {
336
+ labels: string[];
337
+ offsetText?: string;
338
+ };
339
+
255
340
  declare const BEESWARM_MISSING_COLOR = "#777777";
256
341
  declare const BEESWARM_ROW_HEIGHT = 0.4;
257
342
  type BeeswarmPoint = {
@@ -288,6 +373,10 @@ type BeeswarmLayoutOptions = {
288
373
  marginRight: number;
289
374
  marginTop: number;
290
375
  dotRadius: number;
376
+ /** Draw SHAP's feature value colour bar right of the plot. */
377
+ colorBar?: boolean;
378
+ /** Resolved wording; SHAP's when omitted. */
379
+ labels?: PlotLabels;
291
380
  };
292
381
  type BeeswarmPointGeometry = Omit<BeeswarmPoint, "x" | "y"> & {
293
382
  x: number;
@@ -310,13 +399,15 @@ type BeeswarmLayout = {
310
399
  /** The bottom spine, which _beeswarm.py:493-495 leaves visible. */
311
400
  xSpine: AxisSpine | null;
312
401
  xTitle: AxisTitle;
402
+ /** Null unless the options asked for one. */
403
+ colorBar: ColorBarGeometry | null;
313
404
  height: number;
314
405
  };
315
406
  /**
316
407
  * Computes SHAP-compatible beeswarm rows entirely in value space. Pixel scaling belongs in
317
408
  * beeswarmLayout so golden values can be compared without a viewport.
318
409
  */
319
- declare function beeswarmRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, seed?: number, rowSort?: RowSort): BeeswarmRows;
410
+ declare function beeswarmRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, seed?: number, rowSort?: RowSort, labels?: PlotLabels): BeeswarmRows;
320
411
  /** Projects beeswarm value-space rows into SVG coordinates. */
321
412
  declare function beeswarmLayout(valueRows: BeeswarmRows, opts: BeeswarmLayoutOptions): BeeswarmLayout;
322
413
 
@@ -367,6 +458,10 @@ type HeatmapLayoutOptions = {
367
458
  marginRight: number;
368
459
  /** Top of the matrix; the f(x) line occupies the space above it. */
369
460
  marginTop: number;
461
+ /** Draw SHAP's SHAP value colour bar right of the side bars. */
462
+ colorBar?: boolean;
463
+ /** Resolved wording; SHAP's when omitted. */
464
+ labels?: PlotLabels;
370
465
  };
371
466
  type HeatmapCellGeometry = HeatmapCell & {
372
467
  x: number;
@@ -446,11 +541,13 @@ type HeatmapLayout = {
446
541
  xTitle: AxisTitle;
447
542
  plotWidth: number;
448
543
  cellWidth: number;
544
+ /** Null unless the options asked for one. */
545
+ colorBar: ColorBarGeometry | null;
449
546
  height: number;
450
547
  };
451
548
  /** Computes the SHAP-compatible orderings, collapse, colours, line, and side bars in value space. */
452
- declare function heatmapRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, rowSort?: RowSort): HeatmapRows;
549
+ declare function heatmapRows(explanation: ParsedExplanation, maxDisplay: number, faithfulOtherRow: boolean, rowSort?: RowSort, labels?: PlotLabels): HeatmapRows;
453
550
  /** Projects heatmap value-space rows into SVG geometry. */
454
551
  declare function heatmapLayout(valueRows: HeatmapRows, opts: HeatmapLayoutOptions): HeatmapLayout;
455
552
 
456
- export { type AggregatedExplanation, BEESWARM_MISSING_COLOR, BEESWARM_ROW_HEIGHT, type BarGeometry, type BarLayout, type BarLayoutOptions, type BeeswarmLayout, type BeeswarmLayoutOptions, type BeeswarmPoint, type BeeswarmPointGeometry, type BeeswarmRow, type BeeswarmRowGeometry, type BeeswarmRows, type ColormapName, DisplayRows, type GenusGrouping, type HeatmapAxisMark, type HeatmapCell, type HeatmapCellGeometry, type HeatmapColumn, type HeatmapColumnGeometry, type HeatmapLayout, type HeatmapLayoutOptions, type HeatmapLinePoint, type HeatmapRow, type HeatmapRowGeometry, type HeatmapRows, type HeatmapSideBarGeometry, type HeatmapSpine, type HeatmapYTick, NEGATIVE_COLOR, POSITIVE_COLOR, ParsedExplanation, type Point, RowSort, ValuePrecision, WATERFALL_BASE_LABEL_DY, WATERFALL_HEAD_LENGTH_PX, WATERFALL_TICK_LABEL_DY, type WaterfallArrowGeometry, type WaterfallAxisMark, type WaterfallConnector, type WaterfallLayout, type WaterfallLayoutOptions, type WaterfallRow, type WaterfallRows, type WaterfallSeparator, type WaterfallTick, type WaterfallValueLabel, aggregateByGenus, barLayout, beeswarmLayout, beeswarmRows, collapseToDisplay, genusOf, globalImportance, groupByGenus, groupExplanationByGenus, heatmapLayout, heatmapRows, orderFeatures, parseExplanation, sampleColormap, waterfallLayout, waterfallRows };
553
+ export { type AggregatedExplanation, BEESWARM_MISSING_COLOR, BEESWARM_ROW_HEIGHT, type BarGeometry, type BarLayout, type BarLayoutOptions, type BeeswarmLayout, type BeeswarmLayoutOptions, type BeeswarmPoint, type BeeswarmPointGeometry, type BeeswarmRow, type BeeswarmRowGeometry, type BeeswarmRows, type ColorBarGeometry, type ColorBarSpec, type ColorBarStep, type ColorBarTick, type ColormapName, DisplayRows, type GenusGrouping, type HeatmapAxisMark, type HeatmapCell, type HeatmapCellGeometry, type HeatmapColumn, type HeatmapColumnGeometry, type HeatmapLayout, type HeatmapLayoutOptions, type HeatmapLinePoint, type HeatmapRow, type HeatmapRowGeometry, type HeatmapRows, type HeatmapSideBarGeometry, type HeatmapSpine, type HeatmapYTick, NEGATIVE_COLOR, POSITIVE_COLOR, ParsedExplanation, PlotLabels, type Point, RowSort, ValuePrecision, WATERFALL_BASE_LABEL_DY, WATERFALL_HEAD_LENGTH_PX, WATERFALL_TICK_LABEL_DY, type WaterfallArrowGeometry, type WaterfallAxisMark, type WaterfallConnector, type WaterfallLayout, type WaterfallLayoutOptions, type WaterfallRow, type WaterfallRows, type WaterfallSeparator, type WaterfallTick, type WaterfallValueLabel, aggregateByGenus, barLayout, beeswarmLayout, beeswarmRows, collapseToDisplay, colorBarExtent, colorBarLayout, fitColorBar, genusOf, globalImportance, groupByGenus, groupExplanationByGenus, heatmapLayout, heatmapRows, orderFeatures, parseExplanation, sampleColormap, scalarFormatterLabels, waterfallLayout, waterfallRows };
package/dist/index.js CHANGED
@@ -13,6 +13,9 @@ import {
13
13
  beeswarmLayout,
14
14
  beeswarmRows,
15
15
  collapseToDisplay,
16
+ colorBarExtent,
17
+ colorBarLayout,
18
+ fitColorBar,
16
19
  formatFeatureLabel,
17
20
  formatLevel,
18
21
  formatShapValue,
@@ -24,11 +27,14 @@ import {
24
27
  heatmapRows,
25
28
  orderFeatures,
26
29
  parseExplanation,
30
+ resolveLabels,
27
31
  sampleColormap,
32
+ scalarFormatterLabels,
33
+ shapLabels,
28
34
  sortDisplayRows,
29
35
  waterfallLayout,
30
36
  waterfallRows
31
- } from "./chunk-OXFKP5I3.js";
37
+ } from "./chunk-4X6PMJYT.js";
32
38
  export {
33
39
  BEESWARM_MISSING_COLOR,
34
40
  BEESWARM_ROW_HEIGHT,
@@ -44,6 +50,9 @@ export {
44
50
  beeswarmLayout,
45
51
  beeswarmRows,
46
52
  collapseToDisplay,
53
+ colorBarExtent,
54
+ colorBarLayout,
55
+ fitColorBar,
47
56
  formatFeatureLabel,
48
57
  formatLevel,
49
58
  formatShapValue,
@@ -55,7 +64,10 @@ export {
55
64
  heatmapRows,
56
65
  orderFeatures,
57
66
  parseExplanation,
67
+ resolveLabels,
58
68
  sampleColormap,
69
+ scalarFormatterLabels,
70
+ shapLabels,
59
71
  sortDisplayRows,
60
72
  waterfallLayout,
61
73
  waterfallRows
@@ -108,4 +108,47 @@ declare function formatLevel(v: number, decimals?: ValuePrecision): string;
108
108
  /** Spec 3.5 V3. The italic styling is applied by the renderer, not here. */
109
109
  declare function formatFeatureLabel(name: string): string;
110
110
 
111
- export { type DisplayRows as D, type Explanation as E, InvalidExplanationError as I, type ParsedExplanation as P, type RowSort as R, UnsupportedContractVersionError as U, type ValuePrecision as V, type DisplayRow as a, formatLevel as b, formatShapValue as c, formatFeatureLabel as f, sortDisplayRows as s };
111
+ /**
112
+ * Every piece of text the charts draw, keyed by what it means rather than where
113
+ * it appears, so a word used in two places is changed once.
114
+ *
115
+ * The defaults are SHAP 0.49.1's own wording: a chart given no labels reads the
116
+ * way SHAP's figures do.
117
+ */
118
+ type PlotLabels = {
119
+ /** The value itself, as the beeswarm tooltip names it. */
120
+ shapValue: string;
121
+ /** The axis that measures it: beeswarm x axis and heatmap colour bar (_labels.py VALUE). */
122
+ shapValueAxis: string;
123
+ /** The bar chart's x axis. */
124
+ meanAbsShapValue: string;
125
+ /** A Feature's input value: beeswarm tooltip and colour bar title. */
126
+ featureValue: string;
127
+ /** The low end of the beeswarm colour bar. */
128
+ featureValueLow: string;
129
+ /** The high end of the beeswarm colour bar. */
130
+ featureValueHigh: string;
131
+ /** Written in place of a Feature value the payload does not have. */
132
+ missingFeatureValue: string;
133
+ /** The heatmap's Sample axis. */
134
+ samples: string;
135
+ /** A Sample's summed SHAP values, in the heatmap tooltip. */
136
+ sampleTotal: string;
137
+ /** A Sample the payload gives no label, numbered from 1. */
138
+ sampleFallback: (sampleNumber: number) => string;
139
+ /** The waterfall's starting point, E[f(X)]. */
140
+ baseValue: string;
141
+ /** The waterfall's end point, f(x). */
142
+ modelOutput: string;
143
+ /**
144
+ * The row standing in for every Feature not shown. `style` is "sum" for the
145
+ * bar, beeswarm and heatmap row in faithfulOtherRow mode, which SHAP titles as
146
+ * a sum, and "count" everywhere else.
147
+ */
148
+ otherFeatures: (count: number, style: "sum" | "count") => string;
149
+ };
150
+ declare const shapLabels: PlotLabels;
151
+ /** The given wording over SHAP's. A key given as undefined keeps the default. */
152
+ declare function resolveLabels(labels?: Partial<PlotLabels>): PlotLabels;
153
+
154
+ export { type DisplayRows as D, type Explanation as E, InvalidExplanationError as I, type ParsedExplanation as P, type RowSort as R, UnsupportedContractVersionError as U, type ValuePrecision as V, type PlotLabels as a, type DisplayRow as b, formatLevel as c, formatShapValue as d, sortDisplayRows as e, formatFeatureLabel as f, resolveLabels as r, shapLabels as s };
@@ -108,4 +108,47 @@ declare function formatLevel(v: number, decimals?: ValuePrecision): string;
108
108
  /** Spec 3.5 V3. The italic styling is applied by the renderer, not here. */
109
109
  declare function formatFeatureLabel(name: string): string;
110
110
 
111
- export { type DisplayRows as D, type Explanation as E, InvalidExplanationError as I, type ParsedExplanation as P, type RowSort as R, UnsupportedContractVersionError as U, type ValuePrecision as V, type DisplayRow as a, formatLevel as b, formatShapValue as c, formatFeatureLabel as f, sortDisplayRows as s };
111
+ /**
112
+ * Every piece of text the charts draw, keyed by what it means rather than where
113
+ * it appears, so a word used in two places is changed once.
114
+ *
115
+ * The defaults are SHAP 0.49.1's own wording: a chart given no labels reads the
116
+ * way SHAP's figures do.
117
+ */
118
+ type PlotLabels = {
119
+ /** The value itself, as the beeswarm tooltip names it. */
120
+ shapValue: string;
121
+ /** The axis that measures it: beeswarm x axis and heatmap colour bar (_labels.py VALUE). */
122
+ shapValueAxis: string;
123
+ /** The bar chart's x axis. */
124
+ meanAbsShapValue: string;
125
+ /** A Feature's input value: beeswarm tooltip and colour bar title. */
126
+ featureValue: string;
127
+ /** The low end of the beeswarm colour bar. */
128
+ featureValueLow: string;
129
+ /** The high end of the beeswarm colour bar. */
130
+ featureValueHigh: string;
131
+ /** Written in place of a Feature value the payload does not have. */
132
+ missingFeatureValue: string;
133
+ /** The heatmap's Sample axis. */
134
+ samples: string;
135
+ /** A Sample's summed SHAP values, in the heatmap tooltip. */
136
+ sampleTotal: string;
137
+ /** A Sample the payload gives no label, numbered from 1. */
138
+ sampleFallback: (sampleNumber: number) => string;
139
+ /** The waterfall's starting point, E[f(X)]. */
140
+ baseValue: string;
141
+ /** The waterfall's end point, f(x). */
142
+ modelOutput: string;
143
+ /**
144
+ * The row standing in for every Feature not shown. `style` is "sum" for the
145
+ * bar, beeswarm and heatmap row in faithfulOtherRow mode, which SHAP titles as
146
+ * a sum, and "count" everywhere else.
147
+ */
148
+ otherFeatures: (count: number, style: "sum" | "count") => string;
149
+ };
150
+ declare const shapLabels: PlotLabels;
151
+ /** The given wording over SHAP's. A key given as undefined keeps the default. */
152
+ declare function resolveLabels(labels?: Partial<PlotLabels>): PlotLabels;
153
+
154
+ export { type DisplayRows as D, type Explanation as E, InvalidExplanationError as I, type ParsedExplanation as P, type RowSort as R, UnsupportedContractVersionError as U, type ValuePrecision as V, type PlotLabels as a, type DisplayRow as b, formatLevel as c, formatShapValue as d, sortDisplayRows as e, formatFeatureLabel as f, resolveLabels as r, shapLabels as s };