h2o-library 2.2.0 → 2.2.1

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.
@@ -12,7 +12,31 @@ export interface WaterfallFeature {
12
12
  value?: number | string;
13
13
  contribution: number;
14
14
  }
15
- export type ShapRecord = Record<string, number | string>;
15
+ /** One feature entry inside a {@link ShapExplanation}. */
16
+ export interface ShapFeature {
17
+ name: string;
18
+ prob: number;
19
+ value?: number | string;
20
+ }
21
+ /**
22
+ * The structured SHAP explanation object. Passed straight to
23
+ * {@link WaterfallChartProps.data} with no transform.
24
+ */
25
+ export interface ShapExplanation {
26
+ recordId?: number;
27
+ losRecordId?: number;
28
+ probabilityDischargeNext2Days?: number;
29
+ /** f(x) — model output probability. */
30
+ fx: number;
31
+ /** E(f(x)) — baseline (expected) probability. */
32
+ efx: number;
33
+ /** Summed contribution of all features not individually listed. */
34
+ otherFactorsProb?: number;
35
+ /** Count of features grouped into otherFactors. */
36
+ otherFactorsValue?: number;
37
+ text?: string;
38
+ features: ShapFeature[];
39
+ }
16
40
  export interface WaterfallColors {
17
41
  positive?: string;
18
42
  negative?: string;
@@ -25,16 +49,12 @@ export interface WaterfallBarDatum {
25
49
  contribution: number;
26
50
  }
27
51
  export interface WaterfallChartProps {
28
- data: WaterfallFeature[] | ShapRecord;
29
- baseValue?: number;
30
- prediction?: number;
52
+ data: ShapExplanation;
31
53
  maxFeatures?: number;
32
54
  colors?: WaterfallColors;
33
55
  compact?: boolean;
34
56
  height?: number;
35
57
  className?: string;
36
- probSuffix?: string;
37
- valueSuffix?: string;
38
58
  onBarClick?: (datum: WaterfallBarDatum, index: number, event: React.MouseEvent<SVGElement>) => void;
39
59
  }
40
- export declare const WaterfallChart: ({ data, baseValue, prediction, maxFeatures, colors, compact, height, className, probSuffix, valueSuffix, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
60
+ export declare const WaterfallChart: ({ data, maxFeatures, colors, compact, height, className, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
@@ -29,7 +29,7 @@ type BarChartSpecificProps = {
29
29
  layout?: "single" | "grouped" | "stacked" | "grouped-stacked";
30
30
  orientation?: "vertical" | "horizontal";
31
31
  };
32
- type WaterfallSpecificProps = Pick<WaterfallChartProps, "baseValue" | "prediction" | "maxFeatures" | "colors" | "compact" | "probSuffix" | "valueSuffix" | "onBarClick">;
32
+ type WaterfallSpecificProps = Pick<WaterfallChartProps, "maxFeatures" | "colors" | "compact" | "onBarClick">;
33
33
  type ChartTypeSpecificProps<T extends ChartType> = T extends "bar" ? BarChartSpecificProps : T extends "waterfall" ? WaterfallSpecificProps : Record<string, never>;
34
34
  export type ChartProps<T extends ChartType> = BaseChartProps & {
35
35
  data: BaseChartData[T];
@@ -12,7 +12,31 @@ export interface WaterfallFeature {
12
12
  value?: number | string;
13
13
  contribution: number;
14
14
  }
15
- export type ShapRecord = Record<string, number | string>;
15
+ /** One feature entry inside a {@link ShapExplanation}. */
16
+ export interface ShapFeature {
17
+ name: string;
18
+ prob: number;
19
+ value?: number | string;
20
+ }
21
+ /**
22
+ * The structured SHAP explanation object. Passed straight to
23
+ * {@link WaterfallChartProps.data} with no transform.
24
+ */
25
+ export interface ShapExplanation {
26
+ recordId?: number;
27
+ losRecordId?: number;
28
+ probabilityDischargeNext2Days?: number;
29
+ /** f(x) — model output probability. */
30
+ fx: number;
31
+ /** E(f(x)) — baseline (expected) probability. */
32
+ efx: number;
33
+ /** Summed contribution of all features not individually listed. */
34
+ otherFactorsProb?: number;
35
+ /** Count of features grouped into otherFactors. */
36
+ otherFactorsValue?: number;
37
+ text?: string;
38
+ features: ShapFeature[];
39
+ }
16
40
  export interface WaterfallColors {
17
41
  positive?: string;
18
42
  negative?: string;
@@ -25,16 +49,12 @@ export interface WaterfallBarDatum {
25
49
  contribution: number;
26
50
  }
27
51
  export interface WaterfallChartProps {
28
- data: WaterfallFeature[] | ShapRecord;
29
- baseValue?: number;
30
- prediction?: number;
52
+ data: ShapExplanation;
31
53
  maxFeatures?: number;
32
54
  colors?: WaterfallColors;
33
55
  compact?: boolean;
34
56
  height?: number;
35
57
  className?: string;
36
- probSuffix?: string;
37
- valueSuffix?: string;
38
58
  onBarClick?: (datum: WaterfallBarDatum, index: number, event: React.MouseEvent<SVGElement>) => void;
39
59
  }
40
- export declare const WaterfallChart: ({ data, baseValue, prediction, maxFeatures, colors, compact, height, className, probSuffix, valueSuffix, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
60
+ export declare const WaterfallChart: ({ data, maxFeatures, colors, compact, height, className, onBarClick, }: WaterfallChartProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "h2o-library",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "A set of components for H2O Apps development",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/esm/index.js",