@iyulab/u-insight 0.12.0 → 0.12.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/README.md +13 -0
- package/node/u_insight.cjs +782 -0
- package/node/u_insight.d.cts +241 -0
- package/node/u_insight_bg.wasm +0 -0
- package/package.json +17 -4
- package/u_insight_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -399,6 +399,19 @@ Feature importance via permutation, ANOVA, or mutual information.
|
|
|
399
399
|
{ "method": "permutation", "features": [{ "name": "f1", "index": 0, "score": 0.8, "std_dev": 0.1 }], "baseline_score": 0.5 }
|
|
400
400
|
```
|
|
401
401
|
|
|
402
|
+
## npm (WebAssembly)
|
|
403
|
+
|
|
404
|
+
```bash
|
|
405
|
+
npm install @iyulab/u-insight
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
The package resolves per environment via a conditional `exports` map:
|
|
409
|
+
|
|
410
|
+
| Environment | Entry |
|
|
411
|
+
|---|---|
|
|
412
|
+
| Bundlers (webpack, Vite, …) | ESM + WebAssembly ESM-integration (`default` condition) |
|
|
413
|
+
| Node.js — `require()`, ESM `import`, CJS TS runners (`tsx`, `ts-node`) | CJS glue loading the wasm from the filesystem (`node` condition) — no loader hooks or flags |
|
|
414
|
+
|
|
402
415
|
## Related
|
|
403
416
|
|
|
404
417
|
- [u-analytics](https://github.com/iyulab/u-analytics) -- Statistical analytics
|
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
/* @ts-self-types="./u_insight.d.cts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 2-norm condition number of the sample covariance matrix.
|
|
5
|
+
*
|
|
6
|
+
* # Input
|
|
7
|
+
* ```json
|
|
8
|
+
* { "col1": [...], "col2": [...] }
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* # Output
|
|
12
|
+
* `{ condition_number, names }`
|
|
13
|
+
*
|
|
14
|
+
* Standard threshold: `cond > 30` indicates multicollinearity (Belsley 1991).
|
|
15
|
+
* Returns `Infinity` for numerically singular input.
|
|
16
|
+
* @param {any} data
|
|
17
|
+
* @returns {any}
|
|
18
|
+
*/
|
|
19
|
+
function condition_number_diagnostic(data) {
|
|
20
|
+
const ret = wasm.condition_number_diagnostic(data);
|
|
21
|
+
if (ret[2]) {
|
|
22
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
23
|
+
}
|
|
24
|
+
return takeFromExternrefTable0(ret[0]);
|
|
25
|
+
}
|
|
26
|
+
exports.condition_number_diagnostic = condition_number_diagnostic;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Computes a correlation matrix for a column-major dataset.
|
|
30
|
+
*
|
|
31
|
+
* # Input
|
|
32
|
+
* ```json
|
|
33
|
+
* { "col1": [1.0, 2.0, 3.0], "col2": [4.0, 5.0, 6.0], "_method": "pearson" }
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* `_method` ∈ `{"pearson", "spearman", "kendall"}` — optional, defaults
|
|
37
|
+
* to `"pearson"`. Reserved key (prefix `_`) so it never collides with a
|
|
38
|
+
* column name.
|
|
39
|
+
*
|
|
40
|
+
* # Output
|
|
41
|
+
* `{ names, matrix (flattened n×n), n, high_pairs }`
|
|
42
|
+
* @param {any} data
|
|
43
|
+
* @returns {any}
|
|
44
|
+
*/
|
|
45
|
+
function correlation_matrix(data) {
|
|
46
|
+
const ret = wasm.correlation_matrix(data);
|
|
47
|
+
if (ret[2]) {
|
|
48
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
49
|
+
}
|
|
50
|
+
return takeFromExternrefTable0(ret[0]);
|
|
51
|
+
}
|
|
52
|
+
exports.correlation_matrix = correlation_matrix;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Runs DBSCAN density-based clustering on row-major data.
|
|
56
|
+
*
|
|
57
|
+
* # Input
|
|
58
|
+
*
|
|
59
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
60
|
+
*
|
|
61
|
+
* `config`: `{ "epsilon": 1.5, "min_samples": 3 }`
|
|
62
|
+
*
|
|
63
|
+
* # Output
|
|
64
|
+
*
|
|
65
|
+
* `{ labels, n_clusters, noise_count, cluster_sizes, core_points }`
|
|
66
|
+
* @param {any} data
|
|
67
|
+
* @param {any} config
|
|
68
|
+
* @returns {any}
|
|
69
|
+
*/
|
|
70
|
+
function dbscan(data, config) {
|
|
71
|
+
const ret = wasm.dbscan(data, config);
|
|
72
|
+
if (ret[2]) {
|
|
73
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
74
|
+
}
|
|
75
|
+
return takeFromExternrefTable0(ret[0]);
|
|
76
|
+
}
|
|
77
|
+
exports.dbscan = dbscan;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns descriptive statistics for each column in a column-major dataset.
|
|
81
|
+
*
|
|
82
|
+
* # Input
|
|
83
|
+
*
|
|
84
|
+
* Accepts mixed-type columns (numbers, booleans, strings, null):
|
|
85
|
+
* ```json
|
|
86
|
+
* { "age": [30, 25, null], "name": ["Alice", "Bob", null], "active": [true, false, true] }
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* Also accepts numeric-only columns (backward-compatible):
|
|
90
|
+
* ```json
|
|
91
|
+
* { "col1": [1.0, 2.0, 3.0], "col2": [4.0, 5.0, 6.0] }
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* # Output
|
|
95
|
+
* Array of column profile objects, one per column.
|
|
96
|
+
* @param {any} data
|
|
97
|
+
* @returns {any}
|
|
98
|
+
*/
|
|
99
|
+
function describe(data) {
|
|
100
|
+
const ret = wasm.describe(data);
|
|
101
|
+
if (ret[2]) {
|
|
102
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
103
|
+
}
|
|
104
|
+
return takeFromExternrefTable0(ret[0]);
|
|
105
|
+
}
|
|
106
|
+
exports.describe = describe;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {any} data
|
|
110
|
+
* @returns {any}
|
|
111
|
+
*/
|
|
112
|
+
function detect_univariate_outliers(data) {
|
|
113
|
+
const ret = wasm.detect_univariate_outliers(data);
|
|
114
|
+
if (ret[2]) {
|
|
115
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
116
|
+
}
|
|
117
|
+
return takeFromExternrefTable0(ret[0]);
|
|
118
|
+
}
|
|
119
|
+
exports.detect_univariate_outliers = detect_univariate_outliers;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Runs distribution analysis on a 1-D numeric array.
|
|
123
|
+
*
|
|
124
|
+
* # Input
|
|
125
|
+
*
|
|
126
|
+
* `data`: flat array `[1.0, 2.0, 3.0, ...]`
|
|
127
|
+
*
|
|
128
|
+
* `config`: `{ "bin_method": "freedman_diaconis", "bins": null,
|
|
129
|
+
* "significance_level": 0.05, "compute_ecdf": true, "compute_histogram": true,
|
|
130
|
+
* "compute_qq_plot": true, "fit_distributions": false }`
|
|
131
|
+
*
|
|
132
|
+
* `bins` (optional, >= 1): explicit histogram bin count; when set it takes
|
|
133
|
+
* precedence over `bin_method`. The histogram `method` field echoes
|
|
134
|
+
* `"Fixed(n)"` in that case.
|
|
135
|
+
*
|
|
136
|
+
* # Output
|
|
137
|
+
*
|
|
138
|
+
* `{ n, ecdf, histogram, qq_plot, normality, fits }`
|
|
139
|
+
* @param {any} data
|
|
140
|
+
* @param {any} config
|
|
141
|
+
* @returns {any}
|
|
142
|
+
*/
|
|
143
|
+
function distribution_analysis(data, config) {
|
|
144
|
+
const ret = wasm.distribution_analysis(data, config);
|
|
145
|
+
if (ret[2]) {
|
|
146
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
147
|
+
}
|
|
148
|
+
return takeFromExternrefTable0(ret[0]);
|
|
149
|
+
}
|
|
150
|
+
exports.distribution_analysis = distribution_analysis;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Computes feature importance using one of three methods.
|
|
154
|
+
*
|
|
155
|
+
* # Input
|
|
156
|
+
*
|
|
157
|
+
* `data`:
|
|
158
|
+
* ```json
|
|
159
|
+
* {
|
|
160
|
+
* "features": { "f1": [1,2,3,4,5], "f2": [5,4,3,2,1] },
|
|
161
|
+
* "target": [0, 0, 1, 1, 1],
|
|
162
|
+
* "method": "permutation",
|
|
163
|
+
* "n_repeats": 5,
|
|
164
|
+
* "seed": 42
|
|
165
|
+
* }
|
|
166
|
+
* ```
|
|
167
|
+
*
|
|
168
|
+
* Methods: `"permutation"` (regression target), `"anova"` (class target),
|
|
169
|
+
* `"mutual_info"` (class target).
|
|
170
|
+
*
|
|
171
|
+
* # Output
|
|
172
|
+
*
|
|
173
|
+
* `{ method, features: [{ name, index, score, std_dev?, p_value? }], baseline_score?, selected_indices? }`
|
|
174
|
+
* @param {any} data
|
|
175
|
+
* @returns {any}
|
|
176
|
+
*/
|
|
177
|
+
function feature_importance(data) {
|
|
178
|
+
const ret = wasm.feature_importance(data);
|
|
179
|
+
if (ret[2]) {
|
|
180
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
181
|
+
}
|
|
182
|
+
return takeFromExternrefTable0(ret[0]);
|
|
183
|
+
}
|
|
184
|
+
exports.feature_importance = feature_importance;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Runs hierarchical agglomerative clustering on row-major data.
|
|
188
|
+
*
|
|
189
|
+
* # Input
|
|
190
|
+
*
|
|
191
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
192
|
+
*
|
|
193
|
+
* `config`: `{ "linkage": "ward", "n_clusters": 3 }` or
|
|
194
|
+
* `{ "linkage": "single", "distance_threshold": 5.0 }`
|
|
195
|
+
*
|
|
196
|
+
* # Output
|
|
197
|
+
*
|
|
198
|
+
* `{ merges, labels, n_clusters }`
|
|
199
|
+
* @param {any} data
|
|
200
|
+
* @param {any} config
|
|
201
|
+
* @returns {any}
|
|
202
|
+
*/
|
|
203
|
+
function hierarchical(data, config) {
|
|
204
|
+
const ret = wasm.hierarchical(data, config);
|
|
205
|
+
if (ret[2]) {
|
|
206
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
207
|
+
}
|
|
208
|
+
return takeFromExternrefTable0(ret[0]);
|
|
209
|
+
}
|
|
210
|
+
exports.hierarchical = hierarchical;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Runs Isolation Forest anomaly detection on row-major data.
|
|
214
|
+
*
|
|
215
|
+
* # Input
|
|
216
|
+
*
|
|
217
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
218
|
+
*
|
|
219
|
+
* `config`: `{ "n_estimators": 100, "contamination": 0.1, "seed": 42 }`
|
|
220
|
+
*
|
|
221
|
+
* # Output
|
|
222
|
+
*
|
|
223
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
224
|
+
* @param {any} data
|
|
225
|
+
* @param {any} config
|
|
226
|
+
* @returns {any}
|
|
227
|
+
*/
|
|
228
|
+
function isolation_forest(data, config) {
|
|
229
|
+
const ret = wasm.isolation_forest(data, config);
|
|
230
|
+
if (ret[2]) {
|
|
231
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
232
|
+
}
|
|
233
|
+
return takeFromExternrefTable0(ret[0]);
|
|
234
|
+
}
|
|
235
|
+
exports.isolation_forest = isolation_forest;
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Runs K-Means++ clustering on row-major data.
|
|
239
|
+
*
|
|
240
|
+
* # Input
|
|
241
|
+
* ```json
|
|
242
|
+
* [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* # Output
|
|
246
|
+
* `{ k, labels, centroids, wcss, iterations, cluster_sizes }`
|
|
247
|
+
* @param {any} data
|
|
248
|
+
* @param {number} k
|
|
249
|
+
* @returns {any}
|
|
250
|
+
*/
|
|
251
|
+
function kmeans(data, k) {
|
|
252
|
+
const ret = wasm.kmeans(data, k);
|
|
253
|
+
if (ret[2]) {
|
|
254
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
255
|
+
}
|
|
256
|
+
return takeFromExternrefTable0(ret[0]);
|
|
257
|
+
}
|
|
258
|
+
exports.kmeans = kmeans;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Runs Local Outlier Factor anomaly detection on row-major data.
|
|
262
|
+
*
|
|
263
|
+
* # Input
|
|
264
|
+
*
|
|
265
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
266
|
+
*
|
|
267
|
+
* `config`: `{ "k": 20, "threshold": 1.5 }`
|
|
268
|
+
*
|
|
269
|
+
* # Output
|
|
270
|
+
*
|
|
271
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
272
|
+
* @param {any} data
|
|
273
|
+
* @param {any} config
|
|
274
|
+
* @returns {any}
|
|
275
|
+
*/
|
|
276
|
+
function lof(data, config) {
|
|
277
|
+
const ret = wasm.lof(data, config);
|
|
278
|
+
if (ret[2]) {
|
|
279
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
280
|
+
}
|
|
281
|
+
return takeFromExternrefTable0(ret[0]);
|
|
282
|
+
}
|
|
283
|
+
exports.lof = lof;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Runs Principal Component Analysis on row-major data.
|
|
287
|
+
*
|
|
288
|
+
* # Input
|
|
289
|
+
* ```json
|
|
290
|
+
* [[1.0, 0.1], [2.0, 0.2], [3.0, 0.3]]
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* # Output
|
|
294
|
+
* `{ n_components, n_features, eigenvalues, explained_variance_ratio, ... }`
|
|
295
|
+
* @param {any} data
|
|
296
|
+
* @param {number} n_components
|
|
297
|
+
* @returns {any}
|
|
298
|
+
*/
|
|
299
|
+
function pca(data, n_components) {
|
|
300
|
+
const ret = wasm.pca(data, n_components);
|
|
301
|
+
if (ret[2]) {
|
|
302
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
303
|
+
}
|
|
304
|
+
return takeFromExternrefTable0(ret[0]);
|
|
305
|
+
}
|
|
306
|
+
exports.pca = pca;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Runs OLS regression analysis.
|
|
310
|
+
*
|
|
311
|
+
* # Input
|
|
312
|
+
*
|
|
313
|
+
* `data`:
|
|
314
|
+
* ```json
|
|
315
|
+
* {
|
|
316
|
+
* "predictors": { "x1": [1,2,3,4,5], "x2": [2,4,6,8,10] },
|
|
317
|
+
* "target": [2.1, 3.9, 6.1, 7.9, 10.1],
|
|
318
|
+
* "target_name": "y"
|
|
319
|
+
* }
|
|
320
|
+
* ```
|
|
321
|
+
*
|
|
322
|
+
* # Output
|
|
323
|
+
*
|
|
324
|
+
* `{ target_name, predictor_names, r_squared, adj_r_squared, coefficients, p_values, vif, f_p_value }`
|
|
325
|
+
* @param {any} data
|
|
326
|
+
* @returns {any}
|
|
327
|
+
*/
|
|
328
|
+
function regression(data) {
|
|
329
|
+
const ret = wasm.regression(data);
|
|
330
|
+
if (ret[2]) {
|
|
331
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
332
|
+
}
|
|
333
|
+
return takeFromExternrefTable0(ret[0]);
|
|
334
|
+
}
|
|
335
|
+
exports.regression = regression;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Computes silhouette scores for an existing clustering assignment.
|
|
339
|
+
*
|
|
340
|
+
* # Input
|
|
341
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
342
|
+
* `labels`: cluster id per sample `[0, 0, 1, 1, ...]` (each value `< k`)
|
|
343
|
+
* `k`: number of distinct clusters
|
|
344
|
+
*
|
|
345
|
+
* # Output
|
|
346
|
+
* `{ avg, per_sample }` — `avg` is the mean silhouette across samples that
|
|
347
|
+
* had a defined silhouette; `per_sample[i]` is the silhouette of sample `i`
|
|
348
|
+
* (0.0 for singleton-cluster points).
|
|
349
|
+
*
|
|
350
|
+
* O(n²) — use sparingly on very large inputs.
|
|
351
|
+
* @param {any} data
|
|
352
|
+
* @param {any} labels
|
|
353
|
+
* @param {number} k
|
|
354
|
+
* @returns {any}
|
|
355
|
+
*/
|
|
356
|
+
function silhouette(data, labels, k) {
|
|
357
|
+
const ret = wasm.silhouette(data, labels, k);
|
|
358
|
+
if (ret[2]) {
|
|
359
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
360
|
+
}
|
|
361
|
+
return takeFromExternrefTable0(ret[0]);
|
|
362
|
+
}
|
|
363
|
+
exports.silhouette = silhouette;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Variance Inflation Factor diagnostics for column-major numeric data.
|
|
367
|
+
*
|
|
368
|
+
* # Input
|
|
369
|
+
* ```json
|
|
370
|
+
* { "col1": [...], "col2": [...], "_threshold": 10.0 }
|
|
371
|
+
* ```
|
|
372
|
+
* `_threshold` is optional (default 10.0).
|
|
373
|
+
*
|
|
374
|
+
* # Output
|
|
375
|
+
* `{ vif_per_column, high_vif_columns, threshold, names }`
|
|
376
|
+
* @param {any} data
|
|
377
|
+
* @returns {any}
|
|
378
|
+
*/
|
|
379
|
+
function vif_diagnostic(data) {
|
|
380
|
+
const ret = wasm.vif_diagnostic(data);
|
|
381
|
+
if (ret[2]) {
|
|
382
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
383
|
+
}
|
|
384
|
+
return takeFromExternrefTable0(ret[0]);
|
|
385
|
+
}
|
|
386
|
+
exports.vif_diagnostic = vif_diagnostic;
|
|
387
|
+
function __wbg_get_imports() {
|
|
388
|
+
const import0 = {
|
|
389
|
+
__proto__: null,
|
|
390
|
+
__wbg_Error_ef53bc310eb298a0: function(arg0, arg1) {
|
|
391
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
392
|
+
return ret;
|
|
393
|
+
},
|
|
394
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
395
|
+
const ret = String(arg1);
|
|
396
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
397
|
+
const len1 = WASM_VECTOR_LEN;
|
|
398
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
399
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
400
|
+
},
|
|
401
|
+
__wbg___wbindgen_bigint_get_as_i64_38130e98eecd467d: function(arg0, arg1) {
|
|
402
|
+
const v = arg1;
|
|
403
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
404
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
405
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
406
|
+
},
|
|
407
|
+
__wbg___wbindgen_boolean_get_1a45e2c38d4d41b9: function(arg0) {
|
|
408
|
+
const v = arg0;
|
|
409
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
410
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
411
|
+
},
|
|
412
|
+
__wbg___wbindgen_debug_string_0accd80f45e5faa2: function(arg0, arg1) {
|
|
413
|
+
const ret = debugString(arg1);
|
|
414
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
415
|
+
const len1 = WASM_VECTOR_LEN;
|
|
416
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
417
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
418
|
+
},
|
|
419
|
+
__wbg___wbindgen_in_70a403a56e771704: function(arg0, arg1) {
|
|
420
|
+
const ret = arg0 in arg1;
|
|
421
|
+
return ret;
|
|
422
|
+
},
|
|
423
|
+
__wbg___wbindgen_is_bigint_6ffd6468a9bc44b9: function(arg0) {
|
|
424
|
+
const ret = typeof(arg0) === 'bigint';
|
|
425
|
+
return ret;
|
|
426
|
+
},
|
|
427
|
+
__wbg___wbindgen_is_function_754e9f305ff6029e: function(arg0) {
|
|
428
|
+
const ret = typeof(arg0) === 'function';
|
|
429
|
+
return ret;
|
|
430
|
+
},
|
|
431
|
+
__wbg___wbindgen_is_object_56732c2bc353f41d: function(arg0) {
|
|
432
|
+
const val = arg0;
|
|
433
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
434
|
+
return ret;
|
|
435
|
+
},
|
|
436
|
+
__wbg___wbindgen_jsval_eq_1068e624fa87f6ab: function(arg0, arg1) {
|
|
437
|
+
const ret = arg0 === arg1;
|
|
438
|
+
return ret;
|
|
439
|
+
},
|
|
440
|
+
__wbg___wbindgen_jsval_loose_eq_2c56564c75129511: function(arg0, arg1) {
|
|
441
|
+
const ret = arg0 == arg1;
|
|
442
|
+
return ret;
|
|
443
|
+
},
|
|
444
|
+
__wbg___wbindgen_number_get_9bb1761122181af2: function(arg0, arg1) {
|
|
445
|
+
const obj = arg1;
|
|
446
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
447
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
448
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
449
|
+
},
|
|
450
|
+
__wbg___wbindgen_string_get_72bdf95d3ae505b1: function(arg0, arg1) {
|
|
451
|
+
const obj = arg1;
|
|
452
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
453
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
454
|
+
var len1 = WASM_VECTOR_LEN;
|
|
455
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
456
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
457
|
+
},
|
|
458
|
+
__wbg___wbindgen_throw_1506f2235d1bdba0: function(arg0, arg1) {
|
|
459
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
460
|
+
},
|
|
461
|
+
__wbg_call_8a89609d89f6608a: function() { return handleError(function (arg0, arg1) {
|
|
462
|
+
const ret = arg0.call(arg1);
|
|
463
|
+
return ret;
|
|
464
|
+
}, arguments); },
|
|
465
|
+
__wbg_done_60cf307fcc680536: function(arg0) {
|
|
466
|
+
const ret = arg0.done;
|
|
467
|
+
return ret;
|
|
468
|
+
},
|
|
469
|
+
__wbg_entries_04b37a02507f1713: function(arg0) {
|
|
470
|
+
const ret = Object.entries(arg0);
|
|
471
|
+
return ret;
|
|
472
|
+
},
|
|
473
|
+
__wbg_get_1f8f054ddbaa7db2: function() { return handleError(function (arg0, arg1) {
|
|
474
|
+
const ret = Reflect.get(arg0, arg1);
|
|
475
|
+
return ret;
|
|
476
|
+
}, arguments); },
|
|
477
|
+
__wbg_get_2b48c7d0d006a781: function(arg0, arg1) {
|
|
478
|
+
const ret = arg0[arg1 >>> 0];
|
|
479
|
+
return ret;
|
|
480
|
+
},
|
|
481
|
+
__wbg_get_unchecked_33f6e5c9e2f2d6b2: function(arg0, arg1) {
|
|
482
|
+
const ret = arg0[arg1 >>> 0];
|
|
483
|
+
return ret;
|
|
484
|
+
},
|
|
485
|
+
__wbg_instanceof_ArrayBuffer_8f49811467741499: function(arg0) {
|
|
486
|
+
let result;
|
|
487
|
+
try {
|
|
488
|
+
result = arg0 instanceof ArrayBuffer;
|
|
489
|
+
} catch (_) {
|
|
490
|
+
result = false;
|
|
491
|
+
}
|
|
492
|
+
const ret = result;
|
|
493
|
+
return ret;
|
|
494
|
+
},
|
|
495
|
+
__wbg_instanceof_Map_9fc06d9a951bcee6: function(arg0) {
|
|
496
|
+
let result;
|
|
497
|
+
try {
|
|
498
|
+
result = arg0 instanceof Map;
|
|
499
|
+
} catch (_) {
|
|
500
|
+
result = false;
|
|
501
|
+
}
|
|
502
|
+
const ret = result;
|
|
503
|
+
return ret;
|
|
504
|
+
},
|
|
505
|
+
__wbg_instanceof_Uint8Array_86f30649f63ef9c2: function(arg0) {
|
|
506
|
+
let result;
|
|
507
|
+
try {
|
|
508
|
+
result = arg0 instanceof Uint8Array;
|
|
509
|
+
} catch (_) {
|
|
510
|
+
result = false;
|
|
511
|
+
}
|
|
512
|
+
const ret = result;
|
|
513
|
+
return ret;
|
|
514
|
+
},
|
|
515
|
+
__wbg_isArray_67c2c9c4313f4448: function(arg0) {
|
|
516
|
+
const ret = Array.isArray(arg0);
|
|
517
|
+
return ret;
|
|
518
|
+
},
|
|
519
|
+
__wbg_isSafeInteger_66acec27e09e99a7: function(arg0) {
|
|
520
|
+
const ret = Number.isSafeInteger(arg0);
|
|
521
|
+
return ret;
|
|
522
|
+
},
|
|
523
|
+
__wbg_iterator_8732428d309e270e: function() {
|
|
524
|
+
const ret = Symbol.iterator;
|
|
525
|
+
return ret;
|
|
526
|
+
},
|
|
527
|
+
__wbg_length_4a591ecaa01354d9: function(arg0) {
|
|
528
|
+
const ret = arg0.length;
|
|
529
|
+
return ret;
|
|
530
|
+
},
|
|
531
|
+
__wbg_length_66f1a4b2e9026940: function(arg0) {
|
|
532
|
+
const ret = arg0.length;
|
|
533
|
+
return ret;
|
|
534
|
+
},
|
|
535
|
+
__wbg_new_578aeef4b6b94378: function(arg0) {
|
|
536
|
+
const ret = new Uint8Array(arg0);
|
|
537
|
+
return ret;
|
|
538
|
+
},
|
|
539
|
+
__wbg_new_ce1ab61c1c2b300d: function() {
|
|
540
|
+
const ret = new Object();
|
|
541
|
+
return ret;
|
|
542
|
+
},
|
|
543
|
+
__wbg_new_d90091b82fdf5b91: function() {
|
|
544
|
+
const ret = new Array();
|
|
545
|
+
return ret;
|
|
546
|
+
},
|
|
547
|
+
__wbg_next_9e03acdf51c4960d: function(arg0) {
|
|
548
|
+
const ret = arg0.next;
|
|
549
|
+
return ret;
|
|
550
|
+
},
|
|
551
|
+
__wbg_next_eb8ca7351fa27906: function() { return handleError(function (arg0) {
|
|
552
|
+
const ret = arg0.next();
|
|
553
|
+
return ret;
|
|
554
|
+
}, arguments); },
|
|
555
|
+
__wbg_prototypesetcall_3249fc62a0fafa30: function(arg0, arg1, arg2) {
|
|
556
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
557
|
+
},
|
|
558
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
559
|
+
arg0[arg1] = arg2;
|
|
560
|
+
},
|
|
561
|
+
__wbg_set_dca99999bba88a9a: function(arg0, arg1, arg2) {
|
|
562
|
+
arg0[arg1 >>> 0] = arg2;
|
|
563
|
+
},
|
|
564
|
+
__wbg_value_f3625092ee4b37f4: function(arg0) {
|
|
565
|
+
const ret = arg0.value;
|
|
566
|
+
return ret;
|
|
567
|
+
},
|
|
568
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
569
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
570
|
+
const ret = arg0;
|
|
571
|
+
return ret;
|
|
572
|
+
},
|
|
573
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
574
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
575
|
+
const ret = arg0;
|
|
576
|
+
return ret;
|
|
577
|
+
},
|
|
578
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
579
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
580
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
581
|
+
return ret;
|
|
582
|
+
},
|
|
583
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
584
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
585
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
586
|
+
return ret;
|
|
587
|
+
},
|
|
588
|
+
__wbindgen_init_externref_table: function() {
|
|
589
|
+
const table = wasm.__wbindgen_externrefs;
|
|
590
|
+
const offset = table.grow(4);
|
|
591
|
+
table.set(0, undefined);
|
|
592
|
+
table.set(offset + 0, undefined);
|
|
593
|
+
table.set(offset + 1, null);
|
|
594
|
+
table.set(offset + 2, true);
|
|
595
|
+
table.set(offset + 3, false);
|
|
596
|
+
},
|
|
597
|
+
};
|
|
598
|
+
return {
|
|
599
|
+
__proto__: null,
|
|
600
|
+
"./u_insight_bg.js": import0,
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
function addToExternrefTable0(obj) {
|
|
605
|
+
const idx = wasm.__externref_table_alloc();
|
|
606
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
607
|
+
return idx;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
function debugString(val) {
|
|
611
|
+
// primitive types
|
|
612
|
+
const type = typeof val;
|
|
613
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
614
|
+
return `${val}`;
|
|
615
|
+
}
|
|
616
|
+
if (type == 'string') {
|
|
617
|
+
return `"${val}"`;
|
|
618
|
+
}
|
|
619
|
+
if (type == 'symbol') {
|
|
620
|
+
const description = val.description;
|
|
621
|
+
if (description == null) {
|
|
622
|
+
return 'Symbol';
|
|
623
|
+
} else {
|
|
624
|
+
return `Symbol(${description})`;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
if (type == 'function') {
|
|
628
|
+
const name = val.name;
|
|
629
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
630
|
+
return `Function(${name})`;
|
|
631
|
+
} else {
|
|
632
|
+
return 'Function';
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
// objects
|
|
636
|
+
if (Array.isArray(val)) {
|
|
637
|
+
const length = val.length;
|
|
638
|
+
let debug = '[';
|
|
639
|
+
if (length > 0) {
|
|
640
|
+
debug += debugString(val[0]);
|
|
641
|
+
}
|
|
642
|
+
for(let i = 1; i < length; i++) {
|
|
643
|
+
debug += ', ' + debugString(val[i]);
|
|
644
|
+
}
|
|
645
|
+
debug += ']';
|
|
646
|
+
return debug;
|
|
647
|
+
}
|
|
648
|
+
// Test for built-in
|
|
649
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
650
|
+
let className;
|
|
651
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
652
|
+
className = builtInMatches[1];
|
|
653
|
+
} else {
|
|
654
|
+
// Failed to match the standard '[object ClassName]'
|
|
655
|
+
return toString.call(val);
|
|
656
|
+
}
|
|
657
|
+
if (className == 'Object') {
|
|
658
|
+
// we're a user defined class or Object
|
|
659
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
660
|
+
// easier than looping through ownProperties of `val`.
|
|
661
|
+
try {
|
|
662
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
663
|
+
} catch (_) {
|
|
664
|
+
return 'Object';
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
// errors
|
|
668
|
+
if (val instanceof Error) {
|
|
669
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
670
|
+
}
|
|
671
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
672
|
+
return className;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
676
|
+
ptr = ptr >>> 0;
|
|
677
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
let cachedDataViewMemory0 = null;
|
|
681
|
+
function getDataViewMemory0() {
|
|
682
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
683
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
684
|
+
}
|
|
685
|
+
return cachedDataViewMemory0;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
function getStringFromWasm0(ptr, len) {
|
|
689
|
+
return decodeText(ptr >>> 0, len);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
let cachedUint8ArrayMemory0 = null;
|
|
693
|
+
function getUint8ArrayMemory0() {
|
|
694
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
695
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
696
|
+
}
|
|
697
|
+
return cachedUint8ArrayMemory0;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function handleError(f, args) {
|
|
701
|
+
try {
|
|
702
|
+
return f.apply(this, args);
|
|
703
|
+
} catch (e) {
|
|
704
|
+
const idx = addToExternrefTable0(e);
|
|
705
|
+
wasm.__wbindgen_exn_store(idx);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
function isLikeNone(x) {
|
|
710
|
+
return x === undefined || x === null;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
714
|
+
if (realloc === undefined) {
|
|
715
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
716
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
717
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
718
|
+
WASM_VECTOR_LEN = buf.length;
|
|
719
|
+
return ptr;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
let len = arg.length;
|
|
723
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
724
|
+
|
|
725
|
+
const mem = getUint8ArrayMemory0();
|
|
726
|
+
|
|
727
|
+
let offset = 0;
|
|
728
|
+
|
|
729
|
+
for (; offset < len; offset++) {
|
|
730
|
+
const code = arg.charCodeAt(offset);
|
|
731
|
+
if (code > 0x7F) break;
|
|
732
|
+
mem[ptr + offset] = code;
|
|
733
|
+
}
|
|
734
|
+
if (offset !== len) {
|
|
735
|
+
if (offset !== 0) {
|
|
736
|
+
arg = arg.slice(offset);
|
|
737
|
+
}
|
|
738
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
739
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
740
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
741
|
+
|
|
742
|
+
offset += ret.written;
|
|
743
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
WASM_VECTOR_LEN = offset;
|
|
747
|
+
return ptr;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function takeFromExternrefTable0(idx) {
|
|
751
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
752
|
+
wasm.__externref_table_dealloc(idx);
|
|
753
|
+
return value;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
757
|
+
cachedTextDecoder.decode();
|
|
758
|
+
function decodeText(ptr, len) {
|
|
759
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
const cachedTextEncoder = new TextEncoder();
|
|
763
|
+
|
|
764
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
765
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
766
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
767
|
+
view.set(buf);
|
|
768
|
+
return {
|
|
769
|
+
read: arg.length,
|
|
770
|
+
written: buf.length
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
let WASM_VECTOR_LEN = 0;
|
|
776
|
+
|
|
777
|
+
const wasmPath = `${__dirname}/u_insight_bg.wasm`;
|
|
778
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
779
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
780
|
+
let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
|
|
781
|
+
let wasm = wasmInstance.exports;
|
|
782
|
+
wasm.__wbindgen_start();
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 2-norm condition number of the sample covariance matrix.
|
|
6
|
+
*
|
|
7
|
+
* # Input
|
|
8
|
+
* ```json
|
|
9
|
+
* { "col1": [...], "col2": [...] }
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* # Output
|
|
13
|
+
* `{ condition_number, names }`
|
|
14
|
+
*
|
|
15
|
+
* Standard threshold: `cond > 30` indicates multicollinearity (Belsley 1991).
|
|
16
|
+
* Returns `Infinity` for numerically singular input.
|
|
17
|
+
*/
|
|
18
|
+
export function condition_number_diagnostic(data: any): any;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Computes a correlation matrix for a column-major dataset.
|
|
22
|
+
*
|
|
23
|
+
* # Input
|
|
24
|
+
* ```json
|
|
25
|
+
* { "col1": [1.0, 2.0, 3.0], "col2": [4.0, 5.0, 6.0], "_method": "pearson" }
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* `_method` ∈ `{"pearson", "spearman", "kendall"}` — optional, defaults
|
|
29
|
+
* to `"pearson"`. Reserved key (prefix `_`) so it never collides with a
|
|
30
|
+
* column name.
|
|
31
|
+
*
|
|
32
|
+
* # Output
|
|
33
|
+
* `{ names, matrix (flattened n×n), n, high_pairs }`
|
|
34
|
+
*/
|
|
35
|
+
export function correlation_matrix(data: any): any;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Runs DBSCAN density-based clustering on row-major data.
|
|
39
|
+
*
|
|
40
|
+
* # Input
|
|
41
|
+
*
|
|
42
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
43
|
+
*
|
|
44
|
+
* `config`: `{ "epsilon": 1.5, "min_samples": 3 }`
|
|
45
|
+
*
|
|
46
|
+
* # Output
|
|
47
|
+
*
|
|
48
|
+
* `{ labels, n_clusters, noise_count, cluster_sizes, core_points }`
|
|
49
|
+
*/
|
|
50
|
+
export function dbscan(data: any, config: any): any;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns descriptive statistics for each column in a column-major dataset.
|
|
54
|
+
*
|
|
55
|
+
* # Input
|
|
56
|
+
*
|
|
57
|
+
* Accepts mixed-type columns (numbers, booleans, strings, null):
|
|
58
|
+
* ```json
|
|
59
|
+
* { "age": [30, 25, null], "name": ["Alice", "Bob", null], "active": [true, false, true] }
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* Also accepts numeric-only columns (backward-compatible):
|
|
63
|
+
* ```json
|
|
64
|
+
* { "col1": [1.0, 2.0, 3.0], "col2": [4.0, 5.0, 6.0] }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* # Output
|
|
68
|
+
* Array of column profile objects, one per column.
|
|
69
|
+
*/
|
|
70
|
+
export function describe(data: any): any;
|
|
71
|
+
|
|
72
|
+
export function detect_univariate_outliers(data: any): any;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Runs distribution analysis on a 1-D numeric array.
|
|
76
|
+
*
|
|
77
|
+
* # Input
|
|
78
|
+
*
|
|
79
|
+
* `data`: flat array `[1.0, 2.0, 3.0, ...]`
|
|
80
|
+
*
|
|
81
|
+
* `config`: `{ "bin_method": "freedman_diaconis", "bins": null,
|
|
82
|
+
* "significance_level": 0.05, "compute_ecdf": true, "compute_histogram": true,
|
|
83
|
+
* "compute_qq_plot": true, "fit_distributions": false }`
|
|
84
|
+
*
|
|
85
|
+
* `bins` (optional, >= 1): explicit histogram bin count; when set it takes
|
|
86
|
+
* precedence over `bin_method`. The histogram `method` field echoes
|
|
87
|
+
* `"Fixed(n)"` in that case.
|
|
88
|
+
*
|
|
89
|
+
* # Output
|
|
90
|
+
*
|
|
91
|
+
* `{ n, ecdf, histogram, qq_plot, normality, fits }`
|
|
92
|
+
*/
|
|
93
|
+
export function distribution_analysis(data: any, config: any): any;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Computes feature importance using one of three methods.
|
|
97
|
+
*
|
|
98
|
+
* # Input
|
|
99
|
+
*
|
|
100
|
+
* `data`:
|
|
101
|
+
* ```json
|
|
102
|
+
* {
|
|
103
|
+
* "features": { "f1": [1,2,3,4,5], "f2": [5,4,3,2,1] },
|
|
104
|
+
* "target": [0, 0, 1, 1, 1],
|
|
105
|
+
* "method": "permutation",
|
|
106
|
+
* "n_repeats": 5,
|
|
107
|
+
* "seed": 42
|
|
108
|
+
* }
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* Methods: `"permutation"` (regression target), `"anova"` (class target),
|
|
112
|
+
* `"mutual_info"` (class target).
|
|
113
|
+
*
|
|
114
|
+
* # Output
|
|
115
|
+
*
|
|
116
|
+
* `{ method, features: [{ name, index, score, std_dev?, p_value? }], baseline_score?, selected_indices? }`
|
|
117
|
+
*/
|
|
118
|
+
export function feature_importance(data: any): any;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Runs hierarchical agglomerative clustering on row-major data.
|
|
122
|
+
*
|
|
123
|
+
* # Input
|
|
124
|
+
*
|
|
125
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
126
|
+
*
|
|
127
|
+
* `config`: `{ "linkage": "ward", "n_clusters": 3 }` or
|
|
128
|
+
* `{ "linkage": "single", "distance_threshold": 5.0 }`
|
|
129
|
+
*
|
|
130
|
+
* # Output
|
|
131
|
+
*
|
|
132
|
+
* `{ merges, labels, n_clusters }`
|
|
133
|
+
*/
|
|
134
|
+
export function hierarchical(data: any, config: any): any;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Runs Isolation Forest anomaly detection on row-major data.
|
|
138
|
+
*
|
|
139
|
+
* # Input
|
|
140
|
+
*
|
|
141
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
142
|
+
*
|
|
143
|
+
* `config`: `{ "n_estimators": 100, "contamination": 0.1, "seed": 42 }`
|
|
144
|
+
*
|
|
145
|
+
* # Output
|
|
146
|
+
*
|
|
147
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
148
|
+
*/
|
|
149
|
+
export function isolation_forest(data: any, config: any): any;
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Runs K-Means++ clustering on row-major data.
|
|
153
|
+
*
|
|
154
|
+
* # Input
|
|
155
|
+
* ```json
|
|
156
|
+
* [[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]
|
|
157
|
+
* ```
|
|
158
|
+
*
|
|
159
|
+
* # Output
|
|
160
|
+
* `{ k, labels, centroids, wcss, iterations, cluster_sizes }`
|
|
161
|
+
*/
|
|
162
|
+
export function kmeans(data: any, k: number): any;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Runs Local Outlier Factor anomaly detection on row-major data.
|
|
166
|
+
*
|
|
167
|
+
* # Input
|
|
168
|
+
*
|
|
169
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
170
|
+
*
|
|
171
|
+
* `config`: `{ "k": 20, "threshold": 1.5 }`
|
|
172
|
+
*
|
|
173
|
+
* # Output
|
|
174
|
+
*
|
|
175
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
176
|
+
*/
|
|
177
|
+
export function lof(data: any, config: any): any;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Runs Principal Component Analysis on row-major data.
|
|
181
|
+
*
|
|
182
|
+
* # Input
|
|
183
|
+
* ```json
|
|
184
|
+
* [[1.0, 0.1], [2.0, 0.2], [3.0, 0.3]]
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* # Output
|
|
188
|
+
* `{ n_components, n_features, eigenvalues, explained_variance_ratio, ... }`
|
|
189
|
+
*/
|
|
190
|
+
export function pca(data: any, n_components: number): any;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Runs OLS regression analysis.
|
|
194
|
+
*
|
|
195
|
+
* # Input
|
|
196
|
+
*
|
|
197
|
+
* `data`:
|
|
198
|
+
* ```json
|
|
199
|
+
* {
|
|
200
|
+
* "predictors": { "x1": [1,2,3,4,5], "x2": [2,4,6,8,10] },
|
|
201
|
+
* "target": [2.1, 3.9, 6.1, 7.9, 10.1],
|
|
202
|
+
* "target_name": "y"
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* # Output
|
|
207
|
+
*
|
|
208
|
+
* `{ target_name, predictor_names, r_squared, adj_r_squared, coefficients, p_values, vif, f_p_value }`
|
|
209
|
+
*/
|
|
210
|
+
export function regression(data: any): any;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Computes silhouette scores for an existing clustering assignment.
|
|
214
|
+
*
|
|
215
|
+
* # Input
|
|
216
|
+
* `data`: row-major points `[[x,y,...], ...]`
|
|
217
|
+
* `labels`: cluster id per sample `[0, 0, 1, 1, ...]` (each value `< k`)
|
|
218
|
+
* `k`: number of distinct clusters
|
|
219
|
+
*
|
|
220
|
+
* # Output
|
|
221
|
+
* `{ avg, per_sample }` — `avg` is the mean silhouette across samples that
|
|
222
|
+
* had a defined silhouette; `per_sample[i]` is the silhouette of sample `i`
|
|
223
|
+
* (0.0 for singleton-cluster points).
|
|
224
|
+
*
|
|
225
|
+
* O(n²) — use sparingly on very large inputs.
|
|
226
|
+
*/
|
|
227
|
+
export function silhouette(data: any, labels: any, k: number): any;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Variance Inflation Factor diagnostics for column-major numeric data.
|
|
231
|
+
*
|
|
232
|
+
* # Input
|
|
233
|
+
* ```json
|
|
234
|
+
* { "col1": [...], "col2": [...], "_threshold": 10.0 }
|
|
235
|
+
* ```
|
|
236
|
+
* `_threshold` is optional (default 10.0).
|
|
237
|
+
*
|
|
238
|
+
* # Output
|
|
239
|
+
* `{ vif_per_column, high_vif_columns, threshold, names }`
|
|
240
|
+
*/
|
|
241
|
+
export function vif_diagnostic(data: any): any;
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"iyulab"
|
|
6
6
|
],
|
|
7
7
|
"description": "Statistical analysis and data profiling engine with C FFI bindings.",
|
|
8
|
-
"version": "0.12.
|
|
8
|
+
"version": "0.12.2",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -15,18 +15,31 @@
|
|
|
15
15
|
"u_insight_bg.wasm",
|
|
16
16
|
"u_insight.js",
|
|
17
17
|
"u_insight_bg.js",
|
|
18
|
-
"u_insight.d.ts"
|
|
18
|
+
"u_insight.d.ts",
|
|
19
|
+
"node"
|
|
19
20
|
],
|
|
20
21
|
"main": "u_insight.js",
|
|
21
22
|
"types": "u_insight.d.ts",
|
|
22
23
|
"sideEffects": [
|
|
23
24
|
"./u_insight.js",
|
|
24
|
-
"./snippets/*"
|
|
25
|
+
"./snippets/*",
|
|
26
|
+
"./node/u_insight.cjs"
|
|
25
27
|
],
|
|
26
28
|
"keywords": [
|
|
27
29
|
"statistics",
|
|
28
30
|
"profiling",
|
|
29
31
|
"analytics",
|
|
30
32
|
"ffi"
|
|
31
|
-
]
|
|
33
|
+
],
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"node": {
|
|
37
|
+
"types": "./node/u_insight.d.cts",
|
|
38
|
+
"default": "./node/u_insight.cjs"
|
|
39
|
+
},
|
|
40
|
+
"types": "./u_insight.d.ts",
|
|
41
|
+
"default": "./u_insight.js"
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
}
|
|
32
45
|
}
|
package/u_insight_bg.wasm
CHANGED
|
Binary file
|