@iyulab/u-insight 0.3.1 → 0.4.0
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 +125 -0
- package/package.json +1 -1
- package/u_insight.d.ts +123 -0
- package/u_insight.js +1 -1
- package/u_insight_bg.js +218 -0
- package/u_insight_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -243,6 +243,131 @@ C header: auto-generated via cbindgen (20 structs, 32 functions)
|
|
|
243
243
|
- Rust 1.75+
|
|
244
244
|
- Dependencies: `u-analytics`, `u-numflow`
|
|
245
245
|
|
|
246
|
+
## WebAssembly / npm
|
|
247
|
+
|
|
248
|
+
Available as an npm package via [wasm-pack](https://rustwasm.github.io/wasm-pack/).
|
|
249
|
+
|
|
250
|
+
```bash
|
|
251
|
+
npm install @iyulab/u-insight
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Quick Start
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
import init, { describe, kmeans } from '@iyulab/u-insight';
|
|
258
|
+
|
|
259
|
+
await init();
|
|
260
|
+
const stats = describe({ col1: [1, 2, 3], col2: [4, 5, 6] });
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Functions
|
|
264
|
+
|
|
265
|
+
#### `describe(data) -> [ColumnResult]`
|
|
266
|
+
|
|
267
|
+
Descriptive statistics per column. Input: column-major `{ "col1": [1,2,3] }`.
|
|
268
|
+
|
|
269
|
+
**Output:** Array of `{ name, data_type, numeric: { count, min, max, mean, median, std_dev, variance, skewness, kurtosis, q1, q3, iqr, p5, p95, ... } }`.
|
|
270
|
+
|
|
271
|
+
#### `correlation_matrix(data) -> CorrelationResult`
|
|
272
|
+
|
|
273
|
+
Pearson correlation matrix. Input: column-major `{ "col1": [1,2,3], "col2": [4,5,6] }`.
|
|
274
|
+
|
|
275
|
+
**Output:**
|
|
276
|
+
```json
|
|
277
|
+
{ "names": ["col1","col2"], "matrix": [1,0.99,0.99,1], "n": 2, "high_pairs": [{ "col_a": "col1", "col_b": "col2", "r": 0.99, "p_value": 0.01 }] }
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
#### `kmeans(data, k) -> KMeansResult`
|
|
281
|
+
|
|
282
|
+
K-Means++ clustering on row-major data `[[x,y,...], ...]`.
|
|
283
|
+
|
|
284
|
+
**Output:**
|
|
285
|
+
```json
|
|
286
|
+
{ "k": 3, "labels": [0,0,1,1,2,2], "centroids": [[...]], "wcss": 5.2, "iterations": 12, "cluster_sizes": [2,2,2] }
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
#### `pca(data, n_components) -> PcaResult`
|
|
290
|
+
|
|
291
|
+
Principal Component Analysis on row-major data.
|
|
292
|
+
|
|
293
|
+
**Output:**
|
|
294
|
+
```json
|
|
295
|
+
{ "n_components": 2, "n_features": 4, "eigenvalues": [3.1,0.9], "explained_variance_ratio": [0.77,0.23], "cumulative_variance_ratio": [0.77,1.0], "loadings": [[...]], "scores": [[...]], "means": [...], "stds": [...] }
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### `dbscan(data, config) -> DbscanResult`
|
|
299
|
+
|
|
300
|
+
DBSCAN density-based clustering. `config`: `{ "epsilon": 1.5, "min_samples": 3 }`.
|
|
301
|
+
|
|
302
|
+
**Output:**
|
|
303
|
+
```json
|
|
304
|
+
{ "labels": [0,0,null,1,1], "n_clusters": 2, "noise_count": 1, "cluster_sizes": [2,2], "core_points": [true,true,false,true,true] }
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### `hierarchical(data, config) -> HierarchicalResult`
|
|
308
|
+
|
|
309
|
+
Hierarchical agglomerative clustering. `config`: `{ "linkage": "ward", "n_clusters": 3 }` or `{ "linkage": "single", "distance_threshold": 5.0 }`.
|
|
310
|
+
|
|
311
|
+
**Output:**
|
|
312
|
+
```json
|
|
313
|
+
{ "merges": [{ "cluster_a": 0, "cluster_b": 1, "distance": 1.2, "size": 2 }], "labels": [0,0,1,1,2], "n_clusters": 3 }
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
#### `isolation_forest(data, config) -> IsolationForestResult`
|
|
317
|
+
|
|
318
|
+
Isolation Forest anomaly detection. `config`: `{ "n_estimators": 100, "contamination": 0.1, "seed": 42 }`.
|
|
319
|
+
|
|
320
|
+
**Output:**
|
|
321
|
+
```json
|
|
322
|
+
{ "scores": [0.45, 0.82], "anomalies": [false, true], "threshold": 0.65, "anomaly_count": 1, "anomaly_fraction": 0.5 }
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
#### `lof(data, config) -> LofResult`
|
|
326
|
+
|
|
327
|
+
Local Outlier Factor anomaly detection. `config`: `{ "k": 20, "threshold": 1.5 }`.
|
|
328
|
+
|
|
329
|
+
**Output:**
|
|
330
|
+
```json
|
|
331
|
+
{ "scores": [1.0, 2.3], "anomalies": [false, true], "threshold": 1.5, "anomaly_count": 1, "anomaly_fraction": 0.5 }
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
#### `distribution_analysis(data, config) -> DistributionResult`
|
|
335
|
+
|
|
336
|
+
Distribution analysis on a 1-D array. `config`: `{ "bin_method": "freedman_diaconis", "significance_level": 0.05, "compute_ecdf": true, "compute_histogram": true, "compute_qq_plot": true, "fit_distributions": false }`.
|
|
337
|
+
|
|
338
|
+
**Output:**
|
|
339
|
+
```json
|
|
340
|
+
{ "n": 100, "ecdf": { "values": [...], "probabilities": [...] }, "histogram": { "n_bins": 10, "bin_width": 0.5, "edges": [...], "counts": [...] }, "qq_plot": { "theoretical": [...], "sample": [...] }, "normality": { "shapiro_wilk": { "statistic": 0.98, "p_value": 0.45, "rejected": false }, "is_normal": true }, "fits": [] }
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
#### `regression(data) -> RegressionResult`
|
|
344
|
+
|
|
345
|
+
OLS regression analysis.
|
|
346
|
+
|
|
347
|
+
**Input:**
|
|
348
|
+
```json
|
|
349
|
+
{ "predictors": { "x1": [1,2,3,4,5] }, "target": [2.1, 3.9, 6.1, 7.9, 10.1], "target_name": "y" }
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Output:**
|
|
353
|
+
```json
|
|
354
|
+
{ "target_name": "y", "predictor_names": ["x1"], "r_squared": 0.99, "adj_r_squared": 0.99, "coefficients": [0.1, 2.0], "p_values": [0.9, 0.0001], "vif": [1.0], "f_p_value": 0.0001 }
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### `feature_importance(data) -> FeatureImportanceResult`
|
|
358
|
+
|
|
359
|
+
Feature importance via permutation, ANOVA, or mutual information.
|
|
360
|
+
|
|
361
|
+
**Input:**
|
|
362
|
+
```json
|
|
363
|
+
{ "features": { "f1": [1,2,3], "f2": [5,4,3] }, "target": [0,0,1], "method": "permutation", "n_repeats": 5, "seed": 42 }
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Output:**
|
|
367
|
+
```json
|
|
368
|
+
{ "method": "permutation", "features": [{ "name": "f1", "index": 0, "score": 0.8, "std_dev": 0.1 }], "baseline_score": 0.5 }
|
|
369
|
+
```
|
|
370
|
+
|
|
246
371
|
## Related
|
|
247
372
|
|
|
248
373
|
- [u-analytics](https://github.com/iyulab/u-analytics) -- Statistical analytics
|
package/package.json
CHANGED
package/u_insight.d.ts
CHANGED
|
@@ -14,6 +14,21 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export function correlation_matrix(data_json: any): any;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Runs DBSCAN density-based clustering on row-major data.
|
|
19
|
+
*
|
|
20
|
+
* # Input
|
|
21
|
+
*
|
|
22
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
23
|
+
*
|
|
24
|
+
* `config_json`: `{ "epsilon": 1.5, "min_samples": 3 }`
|
|
25
|
+
*
|
|
26
|
+
* # Output
|
|
27
|
+
*
|
|
28
|
+
* `{ labels, n_clusters, noise_count, cluster_sizes, core_points }`
|
|
29
|
+
*/
|
|
30
|
+
export function dbscan(data_json: any, config_json: any): any;
|
|
31
|
+
|
|
17
32
|
/**
|
|
18
33
|
* Returns descriptive statistics for each column in a column-major dataset.
|
|
19
34
|
*
|
|
@@ -27,6 +42,79 @@ export function correlation_matrix(data_json: any): any;
|
|
|
27
42
|
*/
|
|
28
43
|
export function describe(data_json: any): any;
|
|
29
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Runs distribution analysis on a 1-D numeric array.
|
|
47
|
+
*
|
|
48
|
+
* # Input
|
|
49
|
+
*
|
|
50
|
+
* `data_json`: flat array `[1.0, 2.0, 3.0, ...]`
|
|
51
|
+
*
|
|
52
|
+
* `config_json`: `{ "bin_method": "freedman_diaconis", "significance_level": 0.05,
|
|
53
|
+
* "compute_ecdf": true, "compute_histogram": true, "compute_qq_plot": true,
|
|
54
|
+
* "fit_distributions": false }`
|
|
55
|
+
*
|
|
56
|
+
* # Output
|
|
57
|
+
*
|
|
58
|
+
* `{ n, ecdf, histogram, qq_plot, normality, fits }`
|
|
59
|
+
*/
|
|
60
|
+
export function distribution_analysis(data_json: any, config_json: any): any;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Computes feature importance using one of three methods.
|
|
64
|
+
*
|
|
65
|
+
* # Input
|
|
66
|
+
*
|
|
67
|
+
* `data_json`:
|
|
68
|
+
* ```json
|
|
69
|
+
* {
|
|
70
|
+
* "features": { "f1": [1,2,3,4,5], "f2": [5,4,3,2,1] },
|
|
71
|
+
* "target": [0, 0, 1, 1, 1],
|
|
72
|
+
* "method": "permutation",
|
|
73
|
+
* "n_repeats": 5,
|
|
74
|
+
* "seed": 42
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Methods: `"permutation"` (regression target), `"anova"` (class target),
|
|
79
|
+
* `"mutual_info"` (class target).
|
|
80
|
+
*
|
|
81
|
+
* # Output
|
|
82
|
+
*
|
|
83
|
+
* `{ method, features: [{ name, index, score, std_dev?, p_value? }], baseline_score?, selected_indices? }`
|
|
84
|
+
*/
|
|
85
|
+
export function feature_importance(data_json: any): any;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Runs hierarchical agglomerative clustering on row-major data.
|
|
89
|
+
*
|
|
90
|
+
* # Input
|
|
91
|
+
*
|
|
92
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
93
|
+
*
|
|
94
|
+
* `config_json`: `{ "linkage": "ward", "n_clusters": 3 }` or
|
|
95
|
+
* `{ "linkage": "single", "distance_threshold": 5.0 }`
|
|
96
|
+
*
|
|
97
|
+
* # Output
|
|
98
|
+
*
|
|
99
|
+
* `{ merges, labels, n_clusters }`
|
|
100
|
+
*/
|
|
101
|
+
export function hierarchical(data_json: any, config_json: any): any;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Runs Isolation Forest anomaly detection on row-major data.
|
|
105
|
+
*
|
|
106
|
+
* # Input
|
|
107
|
+
*
|
|
108
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
109
|
+
*
|
|
110
|
+
* `config_json`: `{ "n_estimators": 100, "contamination": 0.1, "seed": 42 }`
|
|
111
|
+
*
|
|
112
|
+
* # Output
|
|
113
|
+
*
|
|
114
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
115
|
+
*/
|
|
116
|
+
export function isolation_forest(data_json: any, config_json: any): any;
|
|
117
|
+
|
|
30
118
|
/**
|
|
31
119
|
* Runs K-Means++ clustering on row-major data.
|
|
32
120
|
*
|
|
@@ -40,6 +128,21 @@ export function describe(data_json: any): any;
|
|
|
40
128
|
*/
|
|
41
129
|
export function kmeans(data_json: any, k: number): any;
|
|
42
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Runs Local Outlier Factor anomaly detection on row-major data.
|
|
133
|
+
*
|
|
134
|
+
* # Input
|
|
135
|
+
*
|
|
136
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
137
|
+
*
|
|
138
|
+
* `config_json`: `{ "k": 20, "threshold": 1.5 }`
|
|
139
|
+
*
|
|
140
|
+
* # Output
|
|
141
|
+
*
|
|
142
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
143
|
+
*/
|
|
144
|
+
export function lof(data_json: any, config_json: any): any;
|
|
145
|
+
|
|
43
146
|
/**
|
|
44
147
|
* Runs Principal Component Analysis on row-major data.
|
|
45
148
|
*
|
|
@@ -52,3 +155,23 @@ export function kmeans(data_json: any, k: number): any;
|
|
|
52
155
|
* `{ n_components, n_features, eigenvalues, explained_variance_ratio, ... }`
|
|
53
156
|
*/
|
|
54
157
|
export function pca(data_json: any, n_components: number): any;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Runs OLS regression analysis.
|
|
161
|
+
*
|
|
162
|
+
* # Input
|
|
163
|
+
*
|
|
164
|
+
* `data_json`:
|
|
165
|
+
* ```json
|
|
166
|
+
* {
|
|
167
|
+
* "predictors": { "x1": [1,2,3,4,5], "x2": [2,4,6,8,10] },
|
|
168
|
+
* "target": [2.1, 3.9, 6.1, 7.9, 10.1],
|
|
169
|
+
* "target_name": "y"
|
|
170
|
+
* }
|
|
171
|
+
* ```
|
|
172
|
+
*
|
|
173
|
+
* # Output
|
|
174
|
+
*
|
|
175
|
+
* `{ target_name, predictor_names, r_squared, adj_r_squared, coefficients, p_values, vif, f_p_value }`
|
|
176
|
+
*/
|
|
177
|
+
export function regression(data_json: any): any;
|
package/u_insight.js
CHANGED
|
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./u_insight_bg.js";
|
|
|
5
5
|
__wbg_set_wasm(wasm);
|
|
6
6
|
wasm.__wbindgen_start();
|
|
7
7
|
export {
|
|
8
|
-
correlation_matrix, describe, kmeans, pca
|
|
8
|
+
correlation_matrix, dbscan, describe, distribution_analysis, feature_importance, hierarchical, isolation_forest, kmeans, lof, pca, regression
|
|
9
9
|
} from "./u_insight_bg.js";
|
package/u_insight_bg.js
CHANGED
|
@@ -19,6 +19,30 @@ export function correlation_matrix(data_json) {
|
|
|
19
19
|
return takeFromExternrefTable0(ret[0]);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Runs DBSCAN density-based clustering on row-major data.
|
|
24
|
+
*
|
|
25
|
+
* # Input
|
|
26
|
+
*
|
|
27
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
28
|
+
*
|
|
29
|
+
* `config_json`: `{ "epsilon": 1.5, "min_samples": 3 }`
|
|
30
|
+
*
|
|
31
|
+
* # Output
|
|
32
|
+
*
|
|
33
|
+
* `{ labels, n_clusters, noise_count, cluster_sizes, core_points }`
|
|
34
|
+
* @param {any} data_json
|
|
35
|
+
* @param {any} config_json
|
|
36
|
+
* @returns {any}
|
|
37
|
+
*/
|
|
38
|
+
export function dbscan(data_json, config_json) {
|
|
39
|
+
const ret = wasm.dbscan(data_json, config_json);
|
|
40
|
+
if (ret[2]) {
|
|
41
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
42
|
+
}
|
|
43
|
+
return takeFromExternrefTable0(ret[0]);
|
|
44
|
+
}
|
|
45
|
+
|
|
22
46
|
/**
|
|
23
47
|
* Returns descriptive statistics for each column in a column-major dataset.
|
|
24
48
|
*
|
|
@@ -40,6 +64,114 @@ export function describe(data_json) {
|
|
|
40
64
|
return takeFromExternrefTable0(ret[0]);
|
|
41
65
|
}
|
|
42
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Runs distribution analysis on a 1-D numeric array.
|
|
69
|
+
*
|
|
70
|
+
* # Input
|
|
71
|
+
*
|
|
72
|
+
* `data_json`: flat array `[1.0, 2.0, 3.0, ...]`
|
|
73
|
+
*
|
|
74
|
+
* `config_json`: `{ "bin_method": "freedman_diaconis", "significance_level": 0.05,
|
|
75
|
+
* "compute_ecdf": true, "compute_histogram": true, "compute_qq_plot": true,
|
|
76
|
+
* "fit_distributions": false }`
|
|
77
|
+
*
|
|
78
|
+
* # Output
|
|
79
|
+
*
|
|
80
|
+
* `{ n, ecdf, histogram, qq_plot, normality, fits }`
|
|
81
|
+
* @param {any} data_json
|
|
82
|
+
* @param {any} config_json
|
|
83
|
+
* @returns {any}
|
|
84
|
+
*/
|
|
85
|
+
export function distribution_analysis(data_json, config_json) {
|
|
86
|
+
const ret = wasm.distribution_analysis(data_json, config_json);
|
|
87
|
+
if (ret[2]) {
|
|
88
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
89
|
+
}
|
|
90
|
+
return takeFromExternrefTable0(ret[0]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Computes feature importance using one of three methods.
|
|
95
|
+
*
|
|
96
|
+
* # Input
|
|
97
|
+
*
|
|
98
|
+
* `data_json`:
|
|
99
|
+
* ```json
|
|
100
|
+
* {
|
|
101
|
+
* "features": { "f1": [1,2,3,4,5], "f2": [5,4,3,2,1] },
|
|
102
|
+
* "target": [0, 0, 1, 1, 1],
|
|
103
|
+
* "method": "permutation",
|
|
104
|
+
* "n_repeats": 5,
|
|
105
|
+
* "seed": 42
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* Methods: `"permutation"` (regression target), `"anova"` (class target),
|
|
110
|
+
* `"mutual_info"` (class target).
|
|
111
|
+
*
|
|
112
|
+
* # Output
|
|
113
|
+
*
|
|
114
|
+
* `{ method, features: [{ name, index, score, std_dev?, p_value? }], baseline_score?, selected_indices? }`
|
|
115
|
+
* @param {any} data_json
|
|
116
|
+
* @returns {any}
|
|
117
|
+
*/
|
|
118
|
+
export function feature_importance(data_json) {
|
|
119
|
+
const ret = wasm.feature_importance(data_json);
|
|
120
|
+
if (ret[2]) {
|
|
121
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
122
|
+
}
|
|
123
|
+
return takeFromExternrefTable0(ret[0]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Runs hierarchical agglomerative clustering on row-major data.
|
|
128
|
+
*
|
|
129
|
+
* # Input
|
|
130
|
+
*
|
|
131
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
132
|
+
*
|
|
133
|
+
* `config_json`: `{ "linkage": "ward", "n_clusters": 3 }` or
|
|
134
|
+
* `{ "linkage": "single", "distance_threshold": 5.0 }`
|
|
135
|
+
*
|
|
136
|
+
* # Output
|
|
137
|
+
*
|
|
138
|
+
* `{ merges, labels, n_clusters }`
|
|
139
|
+
* @param {any} data_json
|
|
140
|
+
* @param {any} config_json
|
|
141
|
+
* @returns {any}
|
|
142
|
+
*/
|
|
143
|
+
export function hierarchical(data_json, config_json) {
|
|
144
|
+
const ret = wasm.hierarchical(data_json, config_json);
|
|
145
|
+
if (ret[2]) {
|
|
146
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
147
|
+
}
|
|
148
|
+
return takeFromExternrefTable0(ret[0]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Runs Isolation Forest anomaly detection on row-major data.
|
|
153
|
+
*
|
|
154
|
+
* # Input
|
|
155
|
+
*
|
|
156
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
157
|
+
*
|
|
158
|
+
* `config_json`: `{ "n_estimators": 100, "contamination": 0.1, "seed": 42 }`
|
|
159
|
+
*
|
|
160
|
+
* # Output
|
|
161
|
+
*
|
|
162
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
163
|
+
* @param {any} data_json
|
|
164
|
+
* @param {any} config_json
|
|
165
|
+
* @returns {any}
|
|
166
|
+
*/
|
|
167
|
+
export function isolation_forest(data_json, config_json) {
|
|
168
|
+
const ret = wasm.isolation_forest(data_json, config_json);
|
|
169
|
+
if (ret[2]) {
|
|
170
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
171
|
+
}
|
|
172
|
+
return takeFromExternrefTable0(ret[0]);
|
|
173
|
+
}
|
|
174
|
+
|
|
43
175
|
/**
|
|
44
176
|
* Runs K-Means++ clustering on row-major data.
|
|
45
177
|
*
|
|
@@ -62,6 +194,30 @@ export function kmeans(data_json, k) {
|
|
|
62
194
|
return takeFromExternrefTable0(ret[0]);
|
|
63
195
|
}
|
|
64
196
|
|
|
197
|
+
/**
|
|
198
|
+
* Runs Local Outlier Factor anomaly detection on row-major data.
|
|
199
|
+
*
|
|
200
|
+
* # Input
|
|
201
|
+
*
|
|
202
|
+
* `data_json`: row-major points `[[x,y,...], ...]`
|
|
203
|
+
*
|
|
204
|
+
* `config_json`: `{ "k": 20, "threshold": 1.5 }`
|
|
205
|
+
*
|
|
206
|
+
* # Output
|
|
207
|
+
*
|
|
208
|
+
* `{ scores, anomalies, threshold, anomaly_count, anomaly_fraction }`
|
|
209
|
+
* @param {any} data_json
|
|
210
|
+
* @param {any} config_json
|
|
211
|
+
* @returns {any}
|
|
212
|
+
*/
|
|
213
|
+
export function lof(data_json, config_json) {
|
|
214
|
+
const ret = wasm.lof(data_json, config_json);
|
|
215
|
+
if (ret[2]) {
|
|
216
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
217
|
+
}
|
|
218
|
+
return takeFromExternrefTable0(ret[0]);
|
|
219
|
+
}
|
|
220
|
+
|
|
65
221
|
/**
|
|
66
222
|
* Runs Principal Component Analysis on row-major data.
|
|
67
223
|
*
|
|
@@ -83,10 +239,42 @@ export function pca(data_json, n_components) {
|
|
|
83
239
|
}
|
|
84
240
|
return takeFromExternrefTable0(ret[0]);
|
|
85
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Runs OLS regression analysis.
|
|
245
|
+
*
|
|
246
|
+
* # Input
|
|
247
|
+
*
|
|
248
|
+
* `data_json`:
|
|
249
|
+
* ```json
|
|
250
|
+
* {
|
|
251
|
+
* "predictors": { "x1": [1,2,3,4,5], "x2": [2,4,6,8,10] },
|
|
252
|
+
* "target": [2.1, 3.9, 6.1, 7.9, 10.1],
|
|
253
|
+
* "target_name": "y"
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* # Output
|
|
258
|
+
*
|
|
259
|
+
* `{ target_name, predictor_names, r_squared, adj_r_squared, coefficients, p_values, vif, f_p_value }`
|
|
260
|
+
* @param {any} data_json
|
|
261
|
+
* @returns {any}
|
|
262
|
+
*/
|
|
263
|
+
export function regression(data_json) {
|
|
264
|
+
const ret = wasm.regression(data_json);
|
|
265
|
+
if (ret[2]) {
|
|
266
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
267
|
+
}
|
|
268
|
+
return takeFromExternrefTable0(ret[0]);
|
|
269
|
+
}
|
|
86
270
|
export function __wbg_Error_83742b46f01ce22d(arg0, arg1) {
|
|
87
271
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
88
272
|
return ret;
|
|
89
273
|
}
|
|
274
|
+
export function __wbg_Number_a5a435bd7bbec835(arg0) {
|
|
275
|
+
const ret = Number(arg0);
|
|
276
|
+
return ret;
|
|
277
|
+
}
|
|
90
278
|
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
91
279
|
const ret = String(arg1);
|
|
92
280
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -94,6 +282,12 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
94
282
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
95
283
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
96
284
|
}
|
|
285
|
+
export function __wbg___wbindgen_bigint_get_as_i64_447a76b5c6ef7bda(arg0, arg1) {
|
|
286
|
+
const v = arg1;
|
|
287
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
288
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
289
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
290
|
+
}
|
|
97
291
|
export function __wbg___wbindgen_boolean_get_c0f3f60bac5a78d1(arg0) {
|
|
98
292
|
const v = arg0;
|
|
99
293
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
@@ -106,6 +300,14 @@ export function __wbg___wbindgen_debug_string_5398f5bb970e0daa(arg0, arg1) {
|
|
|
106
300
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
107
301
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
108
302
|
}
|
|
303
|
+
export function __wbg___wbindgen_in_41dbb8413020e076(arg0, arg1) {
|
|
304
|
+
const ret = arg0 in arg1;
|
|
305
|
+
return ret;
|
|
306
|
+
}
|
|
307
|
+
export function __wbg___wbindgen_is_bigint_e2141d4f045b7eda(arg0) {
|
|
308
|
+
const ret = typeof(arg0) === 'bigint';
|
|
309
|
+
return ret;
|
|
310
|
+
}
|
|
109
311
|
export function __wbg___wbindgen_is_function_3c846841762788c1(arg0) {
|
|
110
312
|
const ret = typeof(arg0) === 'function';
|
|
111
313
|
return ret;
|
|
@@ -115,6 +317,14 @@ export function __wbg___wbindgen_is_object_781bc9f159099513(arg0) {
|
|
|
115
317
|
const ret = typeof(val) === 'object' && val !== null;
|
|
116
318
|
return ret;
|
|
117
319
|
}
|
|
320
|
+
export function __wbg___wbindgen_is_undefined_52709e72fb9f179c(arg0) {
|
|
321
|
+
const ret = arg0 === undefined;
|
|
322
|
+
return ret;
|
|
323
|
+
}
|
|
324
|
+
export function __wbg___wbindgen_jsval_eq_ee31bfad3e536463(arg0, arg1) {
|
|
325
|
+
const ret = arg0 === arg1;
|
|
326
|
+
return ret;
|
|
327
|
+
}
|
|
118
328
|
export function __wbg___wbindgen_jsval_loose_eq_5bcc3bed3c69e72b(arg0, arg1) {
|
|
119
329
|
const ret = arg0 == arg1;
|
|
120
330
|
return ret;
|
|
@@ -160,6 +370,10 @@ export function __wbg_get_unchecked_329cfe50afab7352(arg0, arg1) {
|
|
|
160
370
|
const ret = arg0[arg1 >>> 0];
|
|
161
371
|
return ret;
|
|
162
372
|
}
|
|
373
|
+
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
374
|
+
const ret = arg0[arg1];
|
|
375
|
+
return ret;
|
|
376
|
+
}
|
|
163
377
|
export function __wbg_instanceof_ArrayBuffer_101e2bf31071a9f6(arg0) {
|
|
164
378
|
let result;
|
|
165
379
|
try {
|
|
@@ -184,6 +398,10 @@ export function __wbg_isArray_33b91feb269ff46e(arg0) {
|
|
|
184
398
|
const ret = Array.isArray(arg0);
|
|
185
399
|
return ret;
|
|
186
400
|
}
|
|
401
|
+
export function __wbg_isSafeInteger_ecd6a7f9c3e053cd(arg0) {
|
|
402
|
+
const ret = Number.isSafeInteger(arg0);
|
|
403
|
+
return ret;
|
|
404
|
+
}
|
|
187
405
|
export function __wbg_iterator_d8f549ec8fb061b1() {
|
|
188
406
|
const ret = Symbol.iterator;
|
|
189
407
|
return ret;
|
package/u_insight_bg.wasm
CHANGED
|
Binary file
|