@elaraai/east-py-datascience 0.0.2-beta.8 → 0.0.2-beta.80
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/README.md +58 -1
- package/dist/src/alns/alns.d.ts +528 -0
- package/dist/src/alns/alns.d.ts.map +1 -0
- package/dist/src/alns/alns.js +238 -0
- package/dist/src/alns/alns.js.map +1 -0
- package/dist/src/google_or/google_or.d.ts +2422 -0
- package/dist/src/google_or/google_or.d.ts.map +1 -0
- package/dist/src/google_or/google_or.js +542 -0
- package/dist/src/google_or/google_or.js.map +1 -0
- package/dist/{gp → src/gp}/gp.d.ts +185 -136
- package/dist/src/gp/gp.d.ts.map +1 -0
- package/dist/{gp → src/gp}/gp.js +64 -12
- package/dist/src/gp/gp.js.map +1 -0
- package/dist/src/index.d.ts +34 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +57 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lightgbm/lightgbm.d.ts +575 -0
- package/dist/src/lightgbm/lightgbm.d.ts.map +1 -0
- package/dist/{lightgbm → src/lightgbm}/lightgbm.js +104 -18
- package/dist/src/lightgbm/lightgbm.js.map +1 -0
- package/dist/src/lightning/lightning.d.ts +1594 -0
- package/dist/src/lightning/lightning.d.ts.map +1 -0
- package/dist/src/lightning/lightning.js +468 -0
- package/dist/src/lightning/lightning.js.map +1 -0
- package/dist/{mads → src/mads}/mads.d.ts +109 -112
- package/dist/src/mads/mads.d.ts.map +1 -0
- package/dist/{mads → src/mads}/mads.js +6 -8
- package/dist/src/mads/mads.js.map +1 -0
- package/dist/src/mapie/mapie.d.ts +3680 -0
- package/dist/src/mapie/mapie.d.ts.map +1 -0
- package/dist/src/mapie/mapie.js +616 -0
- package/dist/src/mapie/mapie.js.map +1 -0
- package/dist/{ngboost → src/ngboost}/ngboost.d.ts +192 -142
- package/dist/src/ngboost/ngboost.d.ts.map +1 -0
- package/dist/{ngboost → src/ngboost}/ngboost.js +67 -14
- package/dist/src/ngboost/ngboost.js.map +1 -0
- package/dist/src/optimization/optimization.d.ts +420 -0
- package/dist/src/optimization/optimization.d.ts.map +1 -0
- package/dist/src/optimization/optimization.js +257 -0
- package/dist/src/optimization/optimization.js.map +1 -0
- package/dist/{optuna → src/optuna}/optuna.d.ts +374 -314
- package/dist/src/optuna/optuna.d.ts.map +1 -0
- package/dist/{optuna → src/optuna}/optuna.js +2 -0
- package/dist/src/optuna/optuna.js.map +1 -0
- package/dist/src/pymc/pymc.d.ts +2932 -0
- package/dist/src/pymc/pymc.d.ts.map +1 -0
- package/dist/src/pymc/pymc.js +688 -0
- package/dist/src/pymc/pymc.js.map +1 -0
- package/dist/src/scipy/scipy.d.ts +2205 -0
- package/dist/src/scipy/scipy.d.ts.map +1 -0
- package/dist/src/scipy/scipy.js +884 -0
- package/dist/src/scipy/scipy.js.map +1 -0
- package/dist/src/shap/shap.d.ts +2988 -0
- package/dist/src/shap/shap.d.ts.map +1 -0
- package/dist/src/shap/shap.js +500 -0
- package/dist/src/shap/shap.js.map +1 -0
- package/dist/{simanneal → src/simanneal}/simanneal.d.ts +257 -160
- package/dist/src/simanneal/simanneal.d.ts.map +1 -0
- package/dist/{simanneal → src/simanneal}/simanneal.js +105 -8
- package/dist/src/simanneal/simanneal.js.map +1 -0
- package/dist/src/simulation/simulation.d.ts +431 -0
- package/dist/src/simulation/simulation.d.ts.map +1 -0
- package/dist/src/simulation/simulation.js +306 -0
- package/dist/src/simulation/simulation.js.map +1 -0
- package/dist/src/sklearn/sklearn.d.ts +6362 -0
- package/dist/src/sklearn/sklearn.d.ts.map +1 -0
- package/dist/src/sklearn/sklearn.js +1508 -0
- package/dist/src/sklearn/sklearn.js.map +1 -0
- package/dist/src/torch/torch.d.ts +1205 -0
- package/dist/src/torch/torch.d.ts.map +1 -0
- package/dist/{torch → src/torch}/torch.js +109 -18
- package/dist/src/torch/torch.js.map +1 -0
- package/dist/src/types.d.ts +43 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +44 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/xgboost/xgboost.d.ts +1424 -0
- package/dist/src/xgboost/xgboost.d.ts.map +1 -0
- package/dist/src/xgboost/xgboost.js +432 -0
- package/dist/src/xgboost/xgboost.js.map +1 -0
- package/package.json +12 -12
- package/dist/gp/gp.d.ts.map +0 -1
- package/dist/gp/gp.js.map +0 -1
- package/dist/index.d.ts +0 -27
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -41
- package/dist/index.js.map +0 -1
- package/dist/lightgbm/lightgbm.d.ts +0 -494
- package/dist/lightgbm/lightgbm.d.ts.map +0 -1
- package/dist/lightgbm/lightgbm.js.map +0 -1
- package/dist/mads/mads.d.ts.map +0 -1
- package/dist/mads/mads.js.map +0 -1
- package/dist/ngboost/ngboost.d.ts.map +0 -1
- package/dist/ngboost/ngboost.js.map +0 -1
- package/dist/optuna/optuna.d.ts.map +0 -1
- package/dist/optuna/optuna.js.map +0 -1
- package/dist/scipy/scipy.d.ts +0 -1260
- package/dist/scipy/scipy.d.ts.map +0 -1
- package/dist/scipy/scipy.js +0 -413
- package/dist/scipy/scipy.js.map +0 -1
- package/dist/shap/shap.d.ts +0 -657
- package/dist/shap/shap.d.ts.map +0 -1
- package/dist/shap/shap.js +0 -241
- package/dist/shap/shap.js.map +0 -1
- package/dist/simanneal/simanneal.d.ts.map +0 -1
- package/dist/simanneal/simanneal.js.map +0 -1
- package/dist/sklearn/sklearn.d.ts +0 -2691
- package/dist/sklearn/sklearn.d.ts.map +0 -1
- package/dist/sklearn/sklearn.js +0 -524
- package/dist/sklearn/sklearn.js.map +0 -1
- package/dist/torch/torch.d.ts +0 -1081
- package/dist/torch/torch.d.ts.map +0 -1
- package/dist/torch/torch.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types.d.ts +0 -80
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -81
- package/dist/types.js.map +0 -1
- package/dist/xgboost/xgboost.d.ts +0 -504
- package/dist/xgboost/xgboost.d.ts.map +0 -1
- package/dist/xgboost/xgboost.js +0 -177
- package/dist/xgboost/xgboost.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shap.d.ts","sourceRoot":"","sources":["../../../src/shap/shap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAEH,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIrD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMrD,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB,uBAAwB,CAAC;AAMtD;;GAEG;AACH,eAAO,MAAM,cAAc;IACvB,iFAAiF;;IAEjF,oFAAoF;;EAEtF,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC1B,gEAAgE;;IAEhE,2DAA2D;;EAE7D,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc;IACvB,mEAAmE;;QApBnE,iFAAiF;;QAEjF,oFAAoF;;;IAoBpF,sDAAsD;;QAZtD,gEAAgE;;QAEhE,2DAA2D;;;IAY3D,oBAAoB;;EAEtB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAC9B,oBAAoB;;IAEpB,gDAAgD;;IAEhD,iDAAiD;;EAEnD,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC1B,+CAA+C;;QAE3C,uCAAuC;;QAEvC,+BAA+B;;;IAGnC,yCAAyC;;QAErC,uCAAuC;;QAEvC,+BAA+B;;;EAGrC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC1B,wBAAwB;;;;;;;IAOxB,yBAA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;YAQzB,yEAAyE;;;;;;;;YAQzE,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAMxD,wDAAwD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAMxD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAMtD,mDAAmD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8RnD,+CAA+C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiHzC,CAAC"}
|
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SHAP platform functions for East.
|
|
7
|
+
*
|
|
8
|
+
* Provides model-agnostic feature importance and explainability using SHAP values.
|
|
9
|
+
* Uses cloudpickle for explainer serialization.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { East, StructType, VariantType, OptionType, IntegerType, FloatType, StringType, ArrayType, BlobType, NullType, } from "@elaraai/east";
|
|
14
|
+
import { VectorType, MatrixType } from "../types.js";
|
|
15
|
+
import { MAPIEBaseModelDataType } from "../mapie/mapie.js";
|
|
16
|
+
// Re-export shared types for convenience
|
|
17
|
+
export { VectorType, MatrixType } from "../types.js";
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// Data Types
|
|
20
|
+
// ============================================================================
|
|
21
|
+
/** String vector type for feature names */
|
|
22
|
+
export const StringVectorType = ArrayType(StringType);
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// Result Types
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* SHAP values type - variant for 2D (regression/binary) or 3D (multi-class).
|
|
28
|
+
*/
|
|
29
|
+
export const ShapValuesType = VariantType({
|
|
30
|
+
/** 2D matrix for regression or binary classification (n_samples x n_features) */
|
|
31
|
+
matrix_2d: MatrixType(FloatType),
|
|
32
|
+
/** 3D tensor for multi-class classification (n_samples x n_features x n_classes) */
|
|
33
|
+
tensor_3d: ArrayType(MatrixType(FloatType)),
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Base value type - variant for single (regression/binary) or per-class (multi-class).
|
|
37
|
+
*/
|
|
38
|
+
export const ShapBaseValueType = VariantType({
|
|
39
|
+
/** Single base value for regression or binary classification */
|
|
40
|
+
single: FloatType,
|
|
41
|
+
/** Per-class base values for multi-class classification */
|
|
42
|
+
per_class: VectorType(FloatType),
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Result type for SHAP value computation.
|
|
46
|
+
*/
|
|
47
|
+
export const ShapResultType = StructType({
|
|
48
|
+
/** SHAP values - 2D matrix or 3D tensor depending on model type */
|
|
49
|
+
shap_values: ShapValuesType,
|
|
50
|
+
/** Base value(s) - single float or per-class array */
|
|
51
|
+
base_value: ShapBaseValueType,
|
|
52
|
+
/** Feature names */
|
|
53
|
+
feature_names: StringVectorType,
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Result type for feature importance.
|
|
57
|
+
*/
|
|
58
|
+
export const FeatureImportanceType = StructType({
|
|
59
|
+
/** Feature names */
|
|
60
|
+
feature_names: StringVectorType,
|
|
61
|
+
/** Mean absolute SHAP value for each feature */
|
|
62
|
+
importances: VectorType(FloatType),
|
|
63
|
+
/** Standard deviation of absolute SHAP values */
|
|
64
|
+
std: OptionType(VectorType(FloatType)),
|
|
65
|
+
});
|
|
66
|
+
// ============================================================================
|
|
67
|
+
// Model Blob Types
|
|
68
|
+
// ============================================================================
|
|
69
|
+
/**
|
|
70
|
+
* Model blob type for serialized SHAP explainers.
|
|
71
|
+
*/
|
|
72
|
+
export const ShapModelBlobType = VariantType({
|
|
73
|
+
/** SHAP TreeExplainer for tree-based models */
|
|
74
|
+
shap_tree_explainer: StructType({
|
|
75
|
+
/** Cloudpickle serialized explainer */
|
|
76
|
+
data: BlobType,
|
|
77
|
+
/** Number of input features */
|
|
78
|
+
n_features: IntegerType,
|
|
79
|
+
}),
|
|
80
|
+
/** SHAP KernelExplainer for any model */
|
|
81
|
+
shap_kernel_explainer: StructType({
|
|
82
|
+
/** Cloudpickle serialized explainer */
|
|
83
|
+
data: BlobType,
|
|
84
|
+
/** Number of input features */
|
|
85
|
+
n_features: IntegerType,
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Tree-based model blob type - accepts XGBoost models and MAPIE wrappers with XGBoost.
|
|
90
|
+
* Note: LightGBM is not supported for TreeExplainer due to SHAP compatibility issues.
|
|
91
|
+
* Use KernelExplainer for LightGBM models.
|
|
92
|
+
*/
|
|
93
|
+
export const TreeModelBlobType = VariantType({
|
|
94
|
+
/** XGBoost regressor */
|
|
95
|
+
xgboost_regressor: StructType({
|
|
96
|
+
data: BlobType,
|
|
97
|
+
n_features: IntegerType,
|
|
98
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
99
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
100
|
+
}),
|
|
101
|
+
/** XGBoost classifier */
|
|
102
|
+
xgboost_classifier: StructType({
|
|
103
|
+
data: BlobType,
|
|
104
|
+
n_features: IntegerType,
|
|
105
|
+
n_classes: IntegerType,
|
|
106
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
107
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
108
|
+
}),
|
|
109
|
+
/** XGBoost quantile regressor (uses median quantile for explanations) */
|
|
110
|
+
xgboost_quantile: StructType({
|
|
111
|
+
data: BlobType,
|
|
112
|
+
quantiles: VectorType(FloatType),
|
|
113
|
+
n_features: IntegerType,
|
|
114
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
115
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
116
|
+
}),
|
|
117
|
+
/** MAPIE split conformal regressor with XGBoost base */
|
|
118
|
+
mapie_split: StructType({
|
|
119
|
+
data: MAPIEBaseModelDataType,
|
|
120
|
+
n_features: IntegerType,
|
|
121
|
+
confidence_level: FloatType,
|
|
122
|
+
}),
|
|
123
|
+
/** MAPIE cross conformal regressor with XGBoost base */
|
|
124
|
+
mapie_cross: StructType({
|
|
125
|
+
data: MAPIEBaseModelDataType,
|
|
126
|
+
n_features: IntegerType,
|
|
127
|
+
confidence_level: FloatType,
|
|
128
|
+
}),
|
|
129
|
+
/** MAPIE CQR conformal regressor with XGBoost base */
|
|
130
|
+
mapie_cqr: StructType({
|
|
131
|
+
data: MAPIEBaseModelDataType,
|
|
132
|
+
n_features: IntegerType,
|
|
133
|
+
confidence_level: FloatType,
|
|
134
|
+
}),
|
|
135
|
+
/** MAPIE conformal classifier with XGBoost base */
|
|
136
|
+
mapie_classifier: StructType({
|
|
137
|
+
data: MAPIEBaseModelDataType,
|
|
138
|
+
n_features: IntegerType,
|
|
139
|
+
n_classes: IntegerType,
|
|
140
|
+
classes: VectorType(IntegerType),
|
|
141
|
+
confidence_level: FloatType,
|
|
142
|
+
}),
|
|
143
|
+
});
|
|
144
|
+
/**
|
|
145
|
+
* Any model blob type - accepts any model for kernel explainer.
|
|
146
|
+
* Includes all tree-based models plus NGBoost, GP, Torch, and sklearn models.
|
|
147
|
+
*/
|
|
148
|
+
export const AnyModelBlobType = VariantType({
|
|
149
|
+
// Tree-based
|
|
150
|
+
xgboost_regressor: StructType({
|
|
151
|
+
data: BlobType,
|
|
152
|
+
n_features: IntegerType,
|
|
153
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
154
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
155
|
+
}),
|
|
156
|
+
xgboost_classifier: StructType({
|
|
157
|
+
data: BlobType,
|
|
158
|
+
n_features: IntegerType,
|
|
159
|
+
n_classes: IntegerType,
|
|
160
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
161
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
162
|
+
}),
|
|
163
|
+
xgboost_quantile: StructType({
|
|
164
|
+
data: BlobType,
|
|
165
|
+
quantiles: VectorType(FloatType),
|
|
166
|
+
n_features: IntegerType,
|
|
167
|
+
categorical_features: OptionType(VectorType(IntegerType)),
|
|
168
|
+
categorical_n: OptionType(VectorType(IntegerType)),
|
|
169
|
+
}),
|
|
170
|
+
lightgbm_regressor: StructType({
|
|
171
|
+
data: BlobType,
|
|
172
|
+
n_features: IntegerType,
|
|
173
|
+
}),
|
|
174
|
+
lightgbm_classifier: StructType({
|
|
175
|
+
data: BlobType,
|
|
176
|
+
n_features: IntegerType,
|
|
177
|
+
n_classes: IntegerType,
|
|
178
|
+
}),
|
|
179
|
+
// NGBoost
|
|
180
|
+
ngboost_regressor: StructType({
|
|
181
|
+
data: BlobType,
|
|
182
|
+
distribution: VariantType({
|
|
183
|
+
normal: NullType,
|
|
184
|
+
lognormal: NullType,
|
|
185
|
+
}),
|
|
186
|
+
n_features: IntegerType,
|
|
187
|
+
}),
|
|
188
|
+
// GP
|
|
189
|
+
gp_regressor: StructType({
|
|
190
|
+
data: BlobType,
|
|
191
|
+
n_features: IntegerType,
|
|
192
|
+
kernel_type: StringType,
|
|
193
|
+
}),
|
|
194
|
+
// Torch
|
|
195
|
+
torch_mlp: StructType({
|
|
196
|
+
data: BlobType,
|
|
197
|
+
n_features: IntegerType,
|
|
198
|
+
hidden_layers: ArrayType(IntegerType),
|
|
199
|
+
output_dim: IntegerType,
|
|
200
|
+
}),
|
|
201
|
+
// Sklearn scalers (for compatibility with SklearnModelBlobType)
|
|
202
|
+
standard_scaler: StructType({
|
|
203
|
+
onnx: BlobType,
|
|
204
|
+
n_features: IntegerType,
|
|
205
|
+
}),
|
|
206
|
+
min_max_scaler: StructType({
|
|
207
|
+
onnx: BlobType,
|
|
208
|
+
n_features: IntegerType,
|
|
209
|
+
}),
|
|
210
|
+
robust_scaler: StructType({
|
|
211
|
+
onnx: BlobType,
|
|
212
|
+
n_features: IntegerType,
|
|
213
|
+
}),
|
|
214
|
+
label_encoder: StructType({
|
|
215
|
+
data: BlobType,
|
|
216
|
+
n_classes: IntegerType,
|
|
217
|
+
}),
|
|
218
|
+
ordinal_encoder: StructType({
|
|
219
|
+
data: BlobType,
|
|
220
|
+
n_features: IntegerType,
|
|
221
|
+
}),
|
|
222
|
+
gaussian_mixture: StructType({
|
|
223
|
+
data: BlobType,
|
|
224
|
+
n_features: IntegerType,
|
|
225
|
+
n_components: IntegerType,
|
|
226
|
+
}),
|
|
227
|
+
// Sklearn RegressorChain
|
|
228
|
+
regressor_chain: StructType({
|
|
229
|
+
data: BlobType,
|
|
230
|
+
n_features: IntegerType,
|
|
231
|
+
n_targets: IntegerType,
|
|
232
|
+
base_estimator_type: StringType,
|
|
233
|
+
}),
|
|
234
|
+
// MAPIE conformal regressors (uses nested variant pattern)
|
|
235
|
+
mapie_split: StructType({
|
|
236
|
+
data: MAPIEBaseModelDataType,
|
|
237
|
+
n_features: IntegerType,
|
|
238
|
+
confidence_level: FloatType,
|
|
239
|
+
}),
|
|
240
|
+
mapie_cross: StructType({
|
|
241
|
+
data: MAPIEBaseModelDataType,
|
|
242
|
+
n_features: IntegerType,
|
|
243
|
+
confidence_level: FloatType,
|
|
244
|
+
}),
|
|
245
|
+
mapie_cqr: StructType({
|
|
246
|
+
data: MAPIEBaseModelDataType,
|
|
247
|
+
n_features: IntegerType,
|
|
248
|
+
confidence_level: FloatType,
|
|
249
|
+
}),
|
|
250
|
+
// MAPIE conformal classifier (uses nested variant pattern)
|
|
251
|
+
mapie_classifier: StructType({
|
|
252
|
+
data: MAPIEBaseModelDataType,
|
|
253
|
+
n_features: IntegerType,
|
|
254
|
+
n_classes: IntegerType,
|
|
255
|
+
classes: VectorType(IntegerType),
|
|
256
|
+
confidence_level: FloatType,
|
|
257
|
+
}),
|
|
258
|
+
// MAPIE uncertainty predictors (for explaining interval width / set size)
|
|
259
|
+
mapie_interval_width: StructType({
|
|
260
|
+
data: BlobType,
|
|
261
|
+
n_features: IntegerType,
|
|
262
|
+
}),
|
|
263
|
+
mapie_set_size: StructType({
|
|
264
|
+
data: BlobType,
|
|
265
|
+
n_features: IntegerType,
|
|
266
|
+
}),
|
|
267
|
+
});
|
|
268
|
+
// ============================================================================
|
|
269
|
+
// MAPIE Model Types for SHAP
|
|
270
|
+
// ============================================================================
|
|
271
|
+
// Re-export MAPIE model types from mapie.ts for convenience
|
|
272
|
+
export { MAPIEBaseModelDataType } from "../mapie/mapie.js";
|
|
273
|
+
/**
|
|
274
|
+
* MAPIE regressor model blob type for SHAP.
|
|
275
|
+
* Accepts split, cross, or CQR conformal regressors.
|
|
276
|
+
* Must match MAPIERegressorBlobType from mapie.ts.
|
|
277
|
+
*/
|
|
278
|
+
export const MAPIERegressorBlobType = VariantType({
|
|
279
|
+
mapie_split: StructType({
|
|
280
|
+
data: MAPIEBaseModelDataType,
|
|
281
|
+
n_features: IntegerType,
|
|
282
|
+
confidence_level: FloatType,
|
|
283
|
+
}),
|
|
284
|
+
mapie_cross: StructType({
|
|
285
|
+
data: MAPIEBaseModelDataType,
|
|
286
|
+
n_features: IntegerType,
|
|
287
|
+
confidence_level: FloatType,
|
|
288
|
+
}),
|
|
289
|
+
mapie_cqr: StructType({
|
|
290
|
+
data: MAPIEBaseModelDataType,
|
|
291
|
+
n_features: IntegerType,
|
|
292
|
+
confidence_level: FloatType,
|
|
293
|
+
}),
|
|
294
|
+
});
|
|
295
|
+
/**
|
|
296
|
+
* MAPIE classifier model blob type for SHAP.
|
|
297
|
+
* Must match MAPIEClassifierBlobType from mapie.ts.
|
|
298
|
+
*/
|
|
299
|
+
export const MAPIEClassifierBlobType = StructType({
|
|
300
|
+
data: MAPIEBaseModelDataType,
|
|
301
|
+
n_features: IntegerType,
|
|
302
|
+
n_classes: IntegerType,
|
|
303
|
+
classes: VectorType(IntegerType),
|
|
304
|
+
confidence_level: FloatType,
|
|
305
|
+
});
|
|
306
|
+
// ============================================================================
|
|
307
|
+
// MAPIE SHAP Result Types
|
|
308
|
+
// ============================================================================
|
|
309
|
+
/**
|
|
310
|
+
* SHAP result for MAPIE regressors.
|
|
311
|
+
* Contains explanations for both point prediction and uncertainty (interval width).
|
|
312
|
+
*/
|
|
313
|
+
export const MapieRegressorShapResultType = StructType({
|
|
314
|
+
/** SHAP values for point prediction (what drives the predicted value) */
|
|
315
|
+
point_prediction: ShapResultType,
|
|
316
|
+
/** SHAP values for interval width (what drives uncertainty) */
|
|
317
|
+
interval_width: ShapResultType,
|
|
318
|
+
});
|
|
319
|
+
/**
|
|
320
|
+
* SHAP result for MAPIE classifiers.
|
|
321
|
+
* Contains explanations for both class probabilities and prediction set size.
|
|
322
|
+
*/
|
|
323
|
+
export const MapieClassifierShapResultType = StructType({
|
|
324
|
+
/** SHAP values for class probabilities (what drives each class probability) */
|
|
325
|
+
class_probabilities: ShapResultType,
|
|
326
|
+
/** SHAP values for prediction set size (what drives uncertainty) */
|
|
327
|
+
prediction_set_size: ShapResultType,
|
|
328
|
+
});
|
|
329
|
+
// ============================================================================
|
|
330
|
+
// Platform Functions
|
|
331
|
+
// ============================================================================
|
|
332
|
+
/**
|
|
333
|
+
* Create a SHAP TreeExplainer for tree-based models.
|
|
334
|
+
*
|
|
335
|
+
* Works with XGBoost and LightGBM models (regressor and classifier).
|
|
336
|
+
*
|
|
337
|
+
* @param model - Tree-based model blob (XGBoost or LightGBM)
|
|
338
|
+
* @returns SHAP TreeExplainer blob
|
|
339
|
+
*/
|
|
340
|
+
export const shap_tree_explainer_create = East.platform("shap_tree_explainer_create", [TreeModelBlobType], ShapModelBlobType);
|
|
341
|
+
/**
|
|
342
|
+
* Create a SHAP KernelExplainer for any model.
|
|
343
|
+
*
|
|
344
|
+
* Works with any model that has a predict method (NGBoost, GP, Torch, etc.).
|
|
345
|
+
* Requires background data for computing expected values.
|
|
346
|
+
*
|
|
347
|
+
* @param model - Any model blob
|
|
348
|
+
* @param X_background - Background data for computing expected values
|
|
349
|
+
* @returns SHAP KernelExplainer blob
|
|
350
|
+
*/
|
|
351
|
+
export const shap_kernel_explainer_create = East.platform("shap_kernel_explainer_create", [AnyModelBlobType, MatrixType(FloatType)], ShapModelBlobType);
|
|
352
|
+
/**
|
|
353
|
+
* Compute SHAP values for samples.
|
|
354
|
+
*
|
|
355
|
+
* @param explainer - SHAP explainer blob
|
|
356
|
+
* @param X - Feature matrix to explain
|
|
357
|
+
* @param feature_names - Names of features
|
|
358
|
+
* @returns SHAP values, base value, and feature names
|
|
359
|
+
*/
|
|
360
|
+
export const shap_compute_values = East.platform("shap_compute_values", [ShapModelBlobType, MatrixType(FloatType), StringVectorType], ShapResultType);
|
|
361
|
+
/**
|
|
362
|
+
* Compute global feature importance from SHAP values.
|
|
363
|
+
*
|
|
364
|
+
* @param shap_values - SHAP values (2D matrix or 3D tensor)
|
|
365
|
+
* @param feature_names - Names of features
|
|
366
|
+
* @returns Feature importance with mean |SHAP| values
|
|
367
|
+
*/
|
|
368
|
+
export const shap_feature_importance = East.platform("shap_feature_importance", [ShapValuesType, StringVectorType], FeatureImportanceType);
|
|
369
|
+
// ============================================================================
|
|
370
|
+
// Grouped Export
|
|
371
|
+
// ============================================================================
|
|
372
|
+
/**
|
|
373
|
+
* Type definitions for SHAP functions.
|
|
374
|
+
*/
|
|
375
|
+
export const ShapTypes = {
|
|
376
|
+
/** String vector type */
|
|
377
|
+
StringVectorType,
|
|
378
|
+
/** SHAP values variant type (2D or 3D) */
|
|
379
|
+
ShapValuesType,
|
|
380
|
+
/** SHAP base value variant type (single or per-class) */
|
|
381
|
+
ShapBaseValueType,
|
|
382
|
+
/** SHAP result type */
|
|
383
|
+
ShapResultType,
|
|
384
|
+
/** Feature importance type */
|
|
385
|
+
FeatureImportanceType,
|
|
386
|
+
/** SHAP explainer model blob type */
|
|
387
|
+
ShapModelBlobType,
|
|
388
|
+
/** Tree model blob type for input */
|
|
389
|
+
TreeModelBlobType,
|
|
390
|
+
/** Any model blob type for kernel explainer */
|
|
391
|
+
AnyModelBlobType,
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* SHAP explainability functions.
|
|
395
|
+
*
|
|
396
|
+
* Provides model-agnostic feature importance and SHAP value computation.
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```ts
|
|
400
|
+
* import { East, variant } from "@elaraai/east";
|
|
401
|
+
* import { Shap, LightGBM } from "@elaraai/east-py-datascience";
|
|
402
|
+
*
|
|
403
|
+
* const explain = East.function([LightGBM.Types.ModelBlobType, Shap.Types.MatrixType(FloatType)], Shap.Types.ShapResultType, ($, model, X) => {
|
|
404
|
+
* // Create explainer
|
|
405
|
+
* const explainer = $.let(Shap.treeExplainerCreate(model));
|
|
406
|
+
*
|
|
407
|
+
* // Compute SHAP values
|
|
408
|
+
* const feature_names = $.let(["feature1", "feature2"]);
|
|
409
|
+
* const result = $.let(Shap.computeValues(explainer, X, feature_names));
|
|
410
|
+
*
|
|
411
|
+
* return $.return(result);
|
|
412
|
+
* });
|
|
413
|
+
* ```
|
|
414
|
+
*/
|
|
415
|
+
export const Shap = {
|
|
416
|
+
/**
|
|
417
|
+
* Create a SHAP TreeExplainer for tree-based models (XGBoost, LightGBM).
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```ts
|
|
421
|
+
* import { East, FloatType, MatrixType } from "@elaraai/east";
|
|
422
|
+
* import { Shap, XGBoost } from "@elaraai/east-py-datascience";
|
|
423
|
+
*
|
|
424
|
+
* const explain = East.function(
|
|
425
|
+
* [XGBoost.Types.ModelBlobType],
|
|
426
|
+
* Shap.Types.ShapModelBlobType,
|
|
427
|
+
* ($, model) => {
|
|
428
|
+
* return $.return(Shap.treeExplainerCreate(model));
|
|
429
|
+
* }
|
|
430
|
+
* );
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
433
|
+
treeExplainerCreate: shap_tree_explainer_create,
|
|
434
|
+
/**
|
|
435
|
+
* Create a SHAP KernelExplainer for any model.
|
|
436
|
+
*
|
|
437
|
+
* Works with any model (NGBoost, GP, Torch, etc.). Requires background
|
|
438
|
+
* data for computing expected values.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* import { East, FloatType, MatrixType } from "@elaraai/east";
|
|
443
|
+
* import { Shap, NGBoost } from "@elaraai/east-py-datascience";
|
|
444
|
+
*
|
|
445
|
+
* const explain = East.function(
|
|
446
|
+
* [NGBoost.Types.ModelBlobType, MatrixType(FloatType)],
|
|
447
|
+
* Shap.Types.ShapModelBlobType,
|
|
448
|
+
* ($, model, X_background) => {
|
|
449
|
+
* return $.return(Shap.kernelExplainerCreate(model, X_background));
|
|
450
|
+
* }
|
|
451
|
+
* );
|
|
452
|
+
* ```
|
|
453
|
+
*/
|
|
454
|
+
kernelExplainerCreate: shap_kernel_explainer_create,
|
|
455
|
+
/**
|
|
456
|
+
* Compute SHAP values for samples.
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* ```ts
|
|
460
|
+
* import { East, FloatType, MatrixType, StringType, VectorType } from "@elaraai/east";
|
|
461
|
+
* import { Shap } from "@elaraai/east-py-datascience";
|
|
462
|
+
*
|
|
463
|
+
* const compute = East.function(
|
|
464
|
+
* [Shap.Types.ShapModelBlobType, MatrixType(FloatType)],
|
|
465
|
+
* Shap.Types.ShapResultType,
|
|
466
|
+
* ($, explainer, X) => {
|
|
467
|
+
* const feature_names = $.let(["feature_a", "feature_b"]);
|
|
468
|
+
* const result = $.let(Shap.computeValues(explainer, X, feature_names));
|
|
469
|
+
* // result.values => SHAP values matrix
|
|
470
|
+
* // result.base_value => expected value
|
|
471
|
+
* return $.return(result);
|
|
472
|
+
* }
|
|
473
|
+
* );
|
|
474
|
+
* ```
|
|
475
|
+
*/
|
|
476
|
+
computeValues: shap_compute_values,
|
|
477
|
+
/**
|
|
478
|
+
* Compute global feature importance from SHAP values.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* ```ts
|
|
482
|
+
* import { East, FloatType, MatrixType, StringType, VectorType } from "@elaraai/east";
|
|
483
|
+
* import { Shap } from "@elaraai/east-py-datascience";
|
|
484
|
+
*
|
|
485
|
+
* const importance = East.function(
|
|
486
|
+
* [Shap.Types.ShapModelBlobType, MatrixType(FloatType)],
|
|
487
|
+
* Shap.Types.FeatureImportanceType,
|
|
488
|
+
* ($, explainer, X) => {
|
|
489
|
+
* const feature_names = $.let(["feature_a", "feature_b"]);
|
|
490
|
+
* const shap_result = $.let(Shap.computeValues(explainer, X, feature_names));
|
|
491
|
+
* return $.return(Shap.featureImportance(shap_result.values, feature_names));
|
|
492
|
+
* }
|
|
493
|
+
* );
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
featureImportance: shap_feature_importance,
|
|
497
|
+
/** Type definitions */
|
|
498
|
+
Types: ShapTypes,
|
|
499
|
+
};
|
|
500
|
+
//# sourceMappingURL=shap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shap.js","sourceRoot":"","sources":["../../../src/shap/shap.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,IAAI,EACJ,UAAU,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,QAAQ,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,yCA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