linreg-core 0.7.0 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/linreg_core.d.ts CHANGED
@@ -263,6 +263,49 @@ export function elastic_net_prediction_intervals(y_json: string, x_vars_json: st
263
263
  */
264
264
  export function elastic_net_regression(y_json: string, x_vars_json: string, _variable_names: string, lambda: number, alpha: number, standardize: boolean, max_iter: number, tol: number): string;
265
265
 
266
+ /**
267
+ * Computes complete feature importance analysis for OLS regression.
268
+ *
269
+ * This combines standardized coefficients, SHAP values, VIF ranking,
270
+ * and permutation importance into a single call.
271
+ *
272
+ * # Arguments
273
+ *
274
+ * * `y_json` - JSON array of response values
275
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
276
+ * * `variable_names_json` - JSON array of variable names
277
+ * * `y_std` - Standard deviation of response variable
278
+ * * `n_permutations` - Number of permutation iterations
279
+ * * `seed` - Random seed (use 0 for no seed)
280
+ *
281
+ * # Returns
282
+ *
283
+ * JSON string with all feature importance metrics
284
+ *
285
+ * # Example
286
+ *
287
+ * ```javascript
288
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
289
+ * const x = [[1,2,3,4,5], [2,4,5,4,3]];
290
+ * const names = ["Temperature", "Pressure"];
291
+ *
292
+ * const result = JSON.parse(feature_importance_ols(
293
+ * JSON.stringify(y),
294
+ * JSON.stringify(x),
295
+ * JSON.stringify(names),
296
+ * 2.5, // y_std
297
+ * 50, // n_permutations
298
+ * 42 // seed
299
+ * ));
300
+ *
301
+ * console.log(result.standardized_coefficients);
302
+ * console.log(result.shap);
303
+ * console.log(result.permutation_importance);
304
+ * console.log(result.vif_ranking);
305
+ * ```
306
+ */
307
+ export function feature_importance_ols(y_json: string, x_json: string, variable_names_json: string, y_std: number, n_permutations: number, seed: bigint): string;
308
+
266
309
  /**
267
310
  * Extract metadata from a serialized model without deserializing the full model.
268
311
  *
@@ -724,6 +767,316 @@ export function ols_regression(y_json: string, x_vars_json: string, variable_nam
724
767
  */
725
768
  export function parse_csv(content: string): string;
726
769
 
770
+ /**
771
+ * Computes permutation importance for Elastic Net regression.
772
+ *
773
+ * # Arguments
774
+ *
775
+ * * `y_json` - JSON array of response values
776
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
777
+ * * `fit_json` - JSON string of Elastic Net fit result
778
+ * * `n_permutations` - Number of permutation iterations
779
+ * * `seed` - Random seed (use 0 for no seed)
780
+ * * `compute_intervals` - Whether to compute confidence intervals
781
+ * * `interval_confidence` - Confidence level for intervals (0-1)
782
+ *
783
+ * # Returns
784
+ *
785
+ * JSON string of [`PermutationImportanceOutput`]
786
+ *
787
+ * # Example
788
+ *
789
+ * ```javascript
790
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
791
+ * const x = [[1,2,3,4,5], [2,4,5,4,3]];
792
+ * const fit = JSON.parse(elastic_net_regression(...));
793
+ *
794
+ * const result = JSON.parse(permutation_importance_elastic_net(
795
+ * JSON.stringify(y),
796
+ * JSON.stringify(x),
797
+ * JSON.stringify(fit),
798
+ * 50, // n_permutations
799
+ * 42, // seed
800
+ * true, // compute_intervals
801
+ * 0.95 // interval_confidence
802
+ * ));
803
+ * console.log(result.importance);
804
+ * ```
805
+ */
806
+ export function permutation_importance_elastic_net(y_json: string, x_json: string, fit_json: string, n_permutations: number, seed: bigint, compute_intervals: boolean, interval_confidence: number): string;
807
+
808
+ /**
809
+ * Computes permutation importance for Lasso regression.
810
+ *
811
+ * # Arguments
812
+ *
813
+ * * `y_json` - JSON array of response values
814
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
815
+ * * `fit_json` - JSON string of Lasso fit result
816
+ * * `n_permutations` - Number of permutation iterations
817
+ * * `seed` - Random seed (use 0 for no seed)
818
+ * * `compute_intervals` - Whether to compute confidence intervals
819
+ * * `interval_confidence` - Confidence level for intervals (0-1)
820
+ *
821
+ * # Returns
822
+ *
823
+ * JSON string of [`PermutationImportanceOutput`]
824
+ *
825
+ * # Example
826
+ *
827
+ * ```javascript
828
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
829
+ * const x = [[1,2,3,4,5], [2,4,5,4,3]];
830
+ * const fit = JSON.parse(lasso_regression(...));
831
+ *
832
+ * const result = JSON.parse(permutation_importance_lasso(
833
+ * JSON.stringify(y),
834
+ * JSON.stringify(x),
835
+ * JSON.stringify(fit),
836
+ * 50, // n_permutations
837
+ * 42, // seed
838
+ * true, // compute_intervals
839
+ * 0.95 // interval_confidence
840
+ * ));
841
+ * console.log(result.importance);
842
+ * ```
843
+ */
844
+ export function permutation_importance_lasso(y_json: string, x_json: string, fit_json: string, n_permutations: number, seed: bigint, compute_intervals: boolean, interval_confidence: number): string;
845
+
846
+ /**
847
+ * Computes permutation importance for LOESS regression.
848
+ *
849
+ * # Arguments
850
+ *
851
+ * * `y_json` - JSON array of response values
852
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
853
+ * * `span` - Span parameter used in original fit
854
+ * * `degree` - Degree of polynomial used in original fit
855
+ * * `n_permutations` - Number of permutation iterations
856
+ * * `seed` - Random seed (use 0 for no seed)
857
+ *
858
+ * # Returns
859
+ *
860
+ * JSON string of [`PermutationImportanceOutput`]
861
+ *
862
+ * # Note
863
+ *
864
+ * This is computationally expensive as it re-fits the LOESS model
865
+ * for each permutation of each feature.
866
+ *
867
+ * # Example
868
+ *
869
+ * ```javascript
870
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
871
+ * const x = [[1,2,3,4,5]];
872
+ *
873
+ * const result = JSON.parse(permutation_importance_loess(
874
+ * JSON.stringify(y),
875
+ * JSON.stringify(x),
876
+ * 0.75, // span
877
+ * 1, // degree
878
+ * 20, // n_permutations (fewer for LOESS since it's slow)
879
+ * 42 // seed
880
+ * ));
881
+ * console.log(result.importance);
882
+ * ```
883
+ */
884
+ export function permutation_importance_loess(y_json: string, x_json: string, span: number, degree: number, n_permutations: number, seed: bigint): string;
885
+
886
+ /**
887
+ * Computes permutation importance for OLS regression.
888
+ *
889
+ * # Arguments
890
+ *
891
+ * * `y_json` - JSON array of response values
892
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
893
+ * * `fit_json` - JSON string of OLS fit result
894
+ * * `n_permutations` - Number of permutation iterations
895
+ * * `seed` - Random seed (use 0 for no seed)
896
+ *
897
+ * # Returns
898
+ *
899
+ * JSON string of [`PermutationImportanceOutput`]
900
+ *
901
+ * # Example
902
+ *
903
+ * ```javascript
904
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
905
+ * const x = [[1,2,3,4,5], [2,4,5,4,3]];
906
+ * const fit = JSON.parse(ols_regression(...)); // from regression module
907
+ *
908
+ * const result = JSON.parse(permutation_importance_ols(
909
+ * JSON.stringify(y),
910
+ * JSON.stringify(x),
911
+ * JSON.stringify(fit),
912
+ * 50, // n_permutations
913
+ * 42 // seed
914
+ * ));
915
+ * console.log(result.importance);
916
+ * ```
917
+ */
918
+ export function permutation_importance_ols(y_json: string, x_json: string, fit_json: string, n_permutations: number, seed: bigint): string;
919
+
920
+ /**
921
+ * Computes permutation importance for Ridge regression.
922
+ *
923
+ * # Arguments
924
+ *
925
+ * * `y_json` - JSON array of response values
926
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
927
+ * * `fit_json` - JSON string of Ridge fit result
928
+ * * `n_permutations` - Number of permutation iterations
929
+ * * `seed` - Random seed (use 0 for no seed)
930
+ * * `compute_intervals` - Whether to compute confidence intervals
931
+ * * `interval_confidence` - Confidence level for intervals (0-1)
932
+ *
933
+ * # Returns
934
+ *
935
+ * JSON string of [`PermutationImportanceOutput`]
936
+ *
937
+ * # Example
938
+ *
939
+ * ```javascript
940
+ * const y = [2.5, 3.7, 4.2, 5.1, 6.3];
941
+ * const x = [[1,2,3,4,5], [2,4,5,4,3]];
942
+ * const fit = JSON.parse(ridge_regression(...));
943
+ *
944
+ * const result = JSON.parse(permutation_importance_ridge(
945
+ * JSON.stringify(y),
946
+ * JSON.stringify(x),
947
+ * JSON.stringify(fit),
948
+ * 50, // n_permutations
949
+ * 42, // seed
950
+ * true, // compute_intervals
951
+ * 0.95 // interval_confidence
952
+ * ));
953
+ * console.log(result.importance);
954
+ * ```
955
+ */
956
+ export function permutation_importance_ridge(y_json: string, x_json: string, fit_json: string, n_permutations: number, seed: bigint, compute_intervals: boolean, interval_confidence: number): string;
957
+
958
+ /**
959
+ * Fit polynomial Elastic Net regression via WASM.
960
+ *
961
+ * Elastic Net combines L1 and L2 penalties, balancing variable selection
962
+ * with multicollinearity handling.
963
+ *
964
+ * # Arguments
965
+ *
966
+ * * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
967
+ * * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
968
+ * * `degree` - Polynomial degree (≥ 1)
969
+ * * `lambda` - Regularization strength (≥ 0)
970
+ * * `alpha` - Mixing parameter: 0 = Ridge, 1 = Lasso
971
+ * * `center` - Whether to center x before expansion (reduces multicollinearity)
972
+ * * `standardize` - Whether to standardize features (recommended)
973
+ *
974
+ * # Returns
975
+ *
976
+ * JSON string of the ElasticNetFit result, which includes:
977
+ * - `intercept`, `coefficients`
978
+ * - `fitted_values`, `residuals`
979
+ * - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
980
+ * - `n_nonzero`, `converged`, `n_iterations`
981
+ * - `log_likelihood`, `aic`, `bic`
982
+ */
983
+ export function polynomial_elastic_net_wasm(y_json: string, x_json: string, degree: number, lambda: number, alpha: number, center: boolean, standardize: boolean): string;
984
+
985
+ /**
986
+ * Fit polynomial Lasso regression via WASM.
987
+ *
988
+ * Lasso can perform variable selection among polynomial terms,
989
+ * potentially eliminating higher-order terms.
990
+ *
991
+ * # Arguments
992
+ *
993
+ * * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
994
+ * * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
995
+ * * `degree` - Polynomial degree (≥ 1)
996
+ * * `lambda` - Regularization strength (≥ 0)
997
+ * * `center` - Whether to center x before expansion (reduces multicollinearity)
998
+ * * `standardize` - Whether to standardize features (recommended)
999
+ *
1000
+ * # Returns
1001
+ *
1002
+ * JSON string of the LassoFit result, which includes:
1003
+ * - `intercept`, `coefficients`
1004
+ * - `fitted_values`, `residuals`
1005
+ * - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
1006
+ * - `n_nonzero`, `converged`, `n_iterations`
1007
+ * - `log_likelihood`, `aic`, `bic`
1008
+ */
1009
+ export function polynomial_lasso_wasm(y_json: string, x_json: string, degree: number, lambda: number, center: boolean, standardize: boolean): string;
1010
+
1011
+ /**
1012
+ * Predict using a fitted polynomial model via WASM.
1013
+ *
1014
+ * # Arguments
1015
+ *
1016
+ * * `fit_json` - JSON string of the `PolynomialFit` returned by [`polynomial_regression_wasm`]
1017
+ * * `x_new_json` - JSON array of new predictor values, e.g. `[6.0, 7.0]`
1018
+ *
1019
+ * # Returns
1020
+ *
1021
+ * JSON array of predicted values, or a JSON error object on failure.
1022
+ */
1023
+ export function polynomial_predict_wasm(fit_json: string, x_new_json: string): string;
1024
+
1025
+ /**
1026
+ * Fit polynomial regression via WASM.
1027
+ *
1028
+ * # Arguments
1029
+ *
1030
+ * * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
1031
+ * * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
1032
+ * * `degree` - Polynomial degree (≥ 1)
1033
+ * * `center` - Whether to center x before expanding (reduces multicollinearity)
1034
+ * * `standardize` - Whether to standardize polynomial features
1035
+ *
1036
+ * # Returns
1037
+ *
1038
+ * JSON string of the complete [`PolynomialFit`], which includes:
1039
+ * - `ols_output` — full OLS regression output (coefficients, R², F-stat, etc.)
1040
+ * - `degree`, `centered`, `x_mean`, `x_std`, `standardized`
1041
+ * - `feature_names`, `feature_means`, `feature_stds`
1042
+ *
1043
+ * The returned JSON can be passed directly to [`polynomial_predict_wasm`].
1044
+ *
1045
+ * # Errors
1046
+ *
1047
+ * Returns a JSON error object `{"error": "…"}` if:
1048
+ * - JSON parsing fails
1049
+ * - `degree` is 0
1050
+ * - `y` and `x` have different lengths
1051
+ * - Insufficient data
1052
+ * - Domain check fails
1053
+ */
1054
+ export function polynomial_regression_wasm(y_json: string, x_json: string, degree: number, center: boolean, standardize: boolean): string;
1055
+
1056
+ /**
1057
+ * Fit polynomial Ridge regression via WASM.
1058
+ *
1059
+ * Ridge regularization helps with multicollinearity in polynomial features.
1060
+ *
1061
+ * # Arguments
1062
+ *
1063
+ * * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
1064
+ * * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
1065
+ * * `degree` - Polynomial degree (≥ 1)
1066
+ * * `lambda` - Regularization strength (≥ 0)
1067
+ * * `center` - Whether to center x before expansion (reduces multicollinearity)
1068
+ * * `standardize` - Whether to standardize features (recommended)
1069
+ *
1070
+ * # Returns
1071
+ *
1072
+ * JSON string of the RidgeFit result, which includes:
1073
+ * - `intercept`, `coefficients`
1074
+ * - `fitted_values`, `residuals`
1075
+ * - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
1076
+ * - `effective_df`, `log_likelihood`, `aic`, `bic`
1077
+ */
1078
+ export function polynomial_ridge_wasm(y_json: string, x_json: string, degree: number, lambda: number, center: boolean, standardize: boolean): string;
1079
+
727
1080
  /**
728
1081
  * Performs the Python method White test for heteroscedasticity via WASM.
729
1082
  *
@@ -903,6 +1256,133 @@ export function ridge_regression(y_json: string, x_vars_json: string, _variable_
903
1256
  */
904
1257
  export function serialize_model(model_json: string, model_type: string, name?: string | null): string;
905
1258
 
1259
+ /**
1260
+ * Computes SHAP (SHapley Additive exPlanations) values for Elastic Net regression.
1261
+ *
1262
+ * # Arguments
1263
+ *
1264
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
1265
+ * * `fit_json` - JSON string of Elastic Net fit result
1266
+ *
1267
+ * # Returns
1268
+ *
1269
+ * JSON string of [`ShapOutput`]
1270
+ *
1271
+ * # Example
1272
+ *
1273
+ * ```javascript
1274
+ * const fit = JSON.parse(elastic_net_regression(...));
1275
+ * const result = JSON.parse(shap_values_elastic_net(
1276
+ * JSON.stringify([[1,2,3], [2,4,6]]),
1277
+ * JSON.stringify(fit)
1278
+ * ));
1279
+ * console.log(result.mean_abs_shap);
1280
+ * ```
1281
+ */
1282
+ export function shap_values_elastic_net(x_json: string, fit_json: string): string;
1283
+
1284
+ /**
1285
+ * Computes SHAP (SHapley Additive exPlanations) values for Lasso regression.
1286
+ *
1287
+ * # Arguments
1288
+ *
1289
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
1290
+ * * `fit_json` - JSON string of Lasso fit result
1291
+ *
1292
+ * # Returns
1293
+ *
1294
+ * JSON string of [`ShapOutput`]
1295
+ *
1296
+ * # Example
1297
+ *
1298
+ * ```javascript
1299
+ * const fit = JSON.parse(lasso_regression(...));
1300
+ * const result = JSON.parse(shap_values_lasso(
1301
+ * JSON.stringify([[1,2,3], [2,4,6]]),
1302
+ * JSON.stringify(fit)
1303
+ * ));
1304
+ * console.log(result.mean_abs_shap);
1305
+ * ```
1306
+ */
1307
+ export function shap_values_lasso(x_json: string, fit_json: string): string;
1308
+
1309
+ /**
1310
+ * Computes SHAP (SHapley Additive exPlanations) values for linear models.
1311
+ *
1312
+ * # Arguments
1313
+ *
1314
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
1315
+ * * `coefficients_json` - JSON array of coefficients including intercept
1316
+ * * `variable_names_json` - JSON array of variable names
1317
+ *
1318
+ * # Returns
1319
+ *
1320
+ * JSON string of [`ShapOutput`]
1321
+ *
1322
+ * # Example
1323
+ *
1324
+ * ```javascript
1325
+ * const result = JSON.parse(shap_values_linear(
1326
+ * JSON.stringify([[1,2,3], [2,4,6]]),
1327
+ * JSON.stringify([5, 2, 3]),
1328
+ * JSON.stringify(["X1", "X2"])
1329
+ * ));
1330
+ * console.log(result.mean_abs_shap); // Global importance
1331
+ * console.log(result.shap_values); // Local contributions
1332
+ * ```
1333
+ */
1334
+ export function shap_values_linear(x_json: string, coefficients_json: string, variable_names_json: string): string;
1335
+
1336
+ /**
1337
+ * Computes SHAP (SHapley Additive exPlanations) values for polynomial regression.
1338
+ *
1339
+ * # Arguments
1340
+ *
1341
+ * * `x_json` - JSON array of predictor values (single variable)
1342
+ * * `fit_json` - JSON string of Polynomial fit result
1343
+ *
1344
+ * # Returns
1345
+ *
1346
+ * JSON string of [`ShapOutput`]
1347
+ *
1348
+ * # Example
1349
+ *
1350
+ * ```javascript
1351
+ * const fit = JSON.parse(polynomial_regression_wasm(...));
1352
+ * const result = JSON.parse(shap_values_polynomial(
1353
+ * JSON.stringify([1, 2, 3, 4, 5]),
1354
+ * JSON.stringify(fit)
1355
+ * ));
1356
+ * console.log(result.variable_names); // ["X¹", "X²", ...]
1357
+ * ```
1358
+ */
1359
+ export function shap_values_polynomial(x_json: string, fit_json: string): string;
1360
+
1361
+ /**
1362
+ * Computes SHAP (SHapley Additive exPlanations) values for Ridge regression.
1363
+ *
1364
+ * # Arguments
1365
+ *
1366
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
1367
+ * * `fit_json` - JSON string of Ridge fit result
1368
+ *
1369
+ * # Returns
1370
+ *
1371
+ * JSON string of [`ShapOutput`]
1372
+ *
1373
+ * # Example
1374
+ *
1375
+ * ```javascript
1376
+ * const fit = JSON.parse(ridge_regression(...));
1377
+ * const result = JSON.parse(shap_values_ridge(
1378
+ * JSON.stringify([[1,2,3], [2,4,6]]),
1379
+ * JSON.stringify(fit)
1380
+ * ));
1381
+ * console.log(result.mean_abs_shap);
1382
+ * ```
1383
+ */
1384
+ export function shap_values_ridge(x_json: string, fit_json: string): string;
1385
+
906
1386
  /**
907
1387
  * Performs the Shapiro-Wilk test for normality via WASM.
908
1388
  *
@@ -926,6 +1406,34 @@ export function serialize_model(model_json: string, model_type: string, name?: s
926
1406
  */
927
1407
  export function shapiro_wilk_test(y_json: string, x_vars_json: string): string;
928
1408
 
1409
+ /**
1410
+ * Computes standardized coefficients for feature importance.
1411
+ *
1412
+ * # Arguments
1413
+ *
1414
+ * * `x_json` - JSON array of predictor arrays (each array is a column)
1415
+ * * `coefficients_json` - JSON array of coefficients including intercept
1416
+ * * `variable_names_json` - JSON array of variable names
1417
+ * * `y_std` - Standard deviation of response variable
1418
+ *
1419
+ * # Returns
1420
+ *
1421
+ * JSON string of [`StandardizedCoefficientsOutput`]
1422
+ *
1423
+ * # Example
1424
+ *
1425
+ * ```javascript
1426
+ * const result = JSON.parse(standardized_coefficients(
1427
+ * JSON.stringify([[1,2,3,4,5], [10,20,30,40,50]]),
1428
+ * JSON.stringify([1, 0.5, -0.3]),
1429
+ * JSON.stringify(["Temperature", "Pressure"]),
1430
+ * 2.5
1431
+ * ));
1432
+ * console.log(result.standardized_coefficients);
1433
+ * ```
1434
+ */
1435
+ export function standardized_coefficients(x_json: string, coefficients_json: string, variable_names_json: string, y_std: number): string;
1436
+
929
1437
  /**
930
1438
  * Computes the correlation coefficient between two JSON arrays of f64 values.
931
1439
  *
@@ -940,6 +1448,48 @@ export function shapiro_wilk_test(y_json: string, x_vars_json: string): string;
940
1448
  */
941
1449
  export function stats_correlation(x_json: string, y_json: string): string;
942
1450
 
1451
+ /**
1452
+ * Computes the five-number summary of a JSON array of f64 values.
1453
+ *
1454
+ * The five-number summary consists of: minimum, Q1 (25th percentile),
1455
+ * median (50th percentile), Q3 (75th percentile), and maximum.
1456
+ *
1457
+ * # Arguments
1458
+ *
1459
+ * * `data_json` - JSON string representing an array of f64 values
1460
+ *
1461
+ * # Returns
1462
+ *
1463
+ * JSON string with the five-number summary (min, q1, median, q3, max),
1464
+ * or error JSON if input is invalid/empty
1465
+ *
1466
+ * # Example
1467
+ *
1468
+ * ```javascript
1469
+ * const result = JSON.parse(stats_five_number_summary("[1, 2, 3, 4, 5, 6, 7, 8, 9]"));
1470
+ * console.log(result.min); // 1
1471
+ * console.log(result.q1); // ~3
1472
+ * console.log(result.median); // 5
1473
+ * console.log(result.q3); // ~7
1474
+ * console.log(result.max); // 9
1475
+ * console.log(result.iqr); // ~4 (calculated as q3 - q1)
1476
+ * ```
1477
+ */
1478
+ export function stats_five_number_summary(data_json: string): string;
1479
+
1480
+ /**
1481
+ * Computes the maximum value of a JSON array of f64 values.
1482
+ *
1483
+ * # Arguments
1484
+ *
1485
+ * * `data_json` - JSON string representing an array of f64 values
1486
+ *
1487
+ * # Returns
1488
+ *
1489
+ * JSON string with the maximum value, or "null" if input is invalid/empty
1490
+ */
1491
+ export function stats_max(data_json: string): string;
1492
+
943
1493
  /**
944
1494
  * Computes the arithmetic mean of a JSON array of f64 values.
945
1495
  *
@@ -966,6 +1516,43 @@ export function stats_mean(data_json: string): string;
966
1516
  */
967
1517
  export function stats_median(data_json: string): string;
968
1518
 
1519
+ /**
1520
+ * Computes the minimum value of a JSON array of f64 values.
1521
+ *
1522
+ * # Arguments
1523
+ *
1524
+ * * `data_json` - JSON string representing an array of f64 values
1525
+ *
1526
+ * # Returns
1527
+ *
1528
+ * JSON string with the minimum value, or "null" if input is invalid/empty
1529
+ */
1530
+ export function stats_min(data_json: string): string;
1531
+
1532
+ /**
1533
+ * Computes the mode(s) of a JSON array of f64 values.
1534
+ *
1535
+ * Returns all values that appear most frequently (handles ties).
1536
+ *
1537
+ * # Arguments
1538
+ *
1539
+ * * `data_json` - JSON string representing an array of f64 values
1540
+ *
1541
+ * # Returns
1542
+ *
1543
+ * JSON string with mode result containing modes array, frequency, and unique count,
1544
+ * or "null" if input is invalid/empty
1545
+ *
1546
+ * # Example
1547
+ *
1548
+ * ```javascript
1549
+ * const result = JSON.parse(stats_mode("[1, 2, 2, 3, 4]"));
1550
+ * console.log(result.modes); // [2]
1551
+ * console.log(result.frequency); // 2
1552
+ * ```
1553
+ */
1554
+ export function stats_mode(data_json: string): string;
1555
+
969
1556
  /**
970
1557
  * Computes a quantile of a JSON array of f64 values.
971
1558
  *
@@ -980,6 +1567,19 @@ export function stats_median(data_json: string): string;
980
1567
  */
981
1568
  export function stats_quantile(data_json: string, q: number): string;
982
1569
 
1570
+ /**
1571
+ * Computes the range (max - min) of a JSON array of f64 values.
1572
+ *
1573
+ * # Arguments
1574
+ *
1575
+ * * `data_json` - JSON string representing an array of f64 values
1576
+ *
1577
+ * # Returns
1578
+ *
1579
+ * JSON string with the range, or "null" if input is invalid/empty
1580
+ */
1581
+ export function stats_range(data_json: string): string;
1582
+
983
1583
  /**
984
1584
  * Computes the sample standard deviation of a JSON array of f64 values.
985
1585
  *
@@ -1066,6 +1666,27 @@ export function test_r_accuracy(): string;
1066
1666
  */
1067
1667
  export function test_t_critical(df: number, alpha: number): string;
1068
1668
 
1669
+ /**
1670
+ * Computes VIF (Variance Inflation Factor) ranking.
1671
+ *
1672
+ * # Arguments
1673
+ *
1674
+ * * `vif_json` - JSON array of VIF results from OLS output
1675
+ *
1676
+ * # Returns
1677
+ *
1678
+ * JSON string of [`VifRankingOutput`]
1679
+ *
1680
+ * # Example
1681
+ *
1682
+ * ```javascript
1683
+ * const fit = JSON.parse(ols_regression(...));
1684
+ * const result = JSON.parse(vif_ranking(JSON.stringify(fit.vif)));
1685
+ * console.log(result.ranking); // Sorted by VIF (lowest first)
1686
+ * ```
1687
+ */
1688
+ export function vif_ranking(vif_json: string): string;
1689
+
1069
1690
  /**
1070
1691
  * Performs Variance Inflation Factor (VIF) analysis via WASM.
1071
1692
  *
@@ -1175,6 +1796,7 @@ export interface InitOutput {
1175
1796
  readonly elastic_net_path_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
1176
1797
  readonly elastic_net_prediction_intervals: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
1177
1798
  readonly elastic_net_regression: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number];
1799
+ readonly feature_importance_ols: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: bigint) => [number, number];
1178
1800
  readonly get_model_metadata: (a: number, b: number) => [number, number];
1179
1801
  readonly get_version: () => [number, number];
1180
1802
  readonly harvey_collier_test: (a: number, b: number, c: number, d: number) => [number, number];
@@ -1191,6 +1813,16 @@ export interface InitOutput {
1191
1813
  readonly ols_prediction_intervals: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1192
1814
  readonly ols_regression: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1193
1815
  readonly parse_csv: (a: number, b: number) => [number, number];
1816
+ readonly permutation_importance_elastic_net: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: number, j: number) => [number, number];
1817
+ readonly permutation_importance_lasso: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: number, j: number) => [number, number];
1818
+ readonly permutation_importance_loess: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => [number, number];
1819
+ readonly permutation_importance_ols: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint) => [number, number];
1820
+ readonly permutation_importance_ridge: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: bigint, i: number, j: number) => [number, number];
1821
+ readonly polynomial_elastic_net_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
1822
+ readonly polynomial_lasso_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1823
+ readonly polynomial_predict_wasm: (a: number, b: number, c: number, d: number) => [number, number];
1824
+ readonly polynomial_regression_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1825
+ readonly polynomial_ridge_wasm: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1194
1826
  readonly python_white_test: (a: number, b: number, c: number, d: number) => [number, number];
1195
1827
  readonly r_white_test: (a: number, b: number, c: number, d: number) => [number, number];
1196
1828
  readonly rainbow_test: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
@@ -1198,11 +1830,22 @@ export interface InitOutput {
1198
1830
  readonly ridge_prediction_intervals: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
1199
1831
  readonly ridge_regression: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
1200
1832
  readonly serialize_model: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1833
+ readonly shap_values_elastic_net: (a: number, b: number, c: number, d: number) => [number, number];
1834
+ readonly shap_values_lasso: (a: number, b: number, c: number, d: number) => [number, number];
1835
+ readonly shap_values_linear: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1836
+ readonly shap_values_polynomial: (a: number, b: number, c: number, d: number) => [number, number];
1837
+ readonly shap_values_ridge: (a: number, b: number, c: number, d: number) => [number, number];
1201
1838
  readonly shapiro_wilk_test: (a: number, b: number, c: number, d: number) => [number, number];
1839
+ readonly standardized_coefficients: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
1202
1840
  readonly stats_correlation: (a: number, b: number, c: number, d: number) => [number, number];
1841
+ readonly stats_five_number_summary: (a: number, b: number) => [number, number];
1842
+ readonly stats_max: (a: number, b: number) => [number, number];
1203
1843
  readonly stats_mean: (a: number, b: number) => [number, number];
1204
1844
  readonly stats_median: (a: number, b: number) => [number, number];
1845
+ readonly stats_min: (a: number, b: number) => [number, number];
1846
+ readonly stats_mode: (a: number, b: number) => [number, number];
1205
1847
  readonly stats_quantile: (a: number, b: number, c: number) => [number, number];
1848
+ readonly stats_range: (a: number, b: number) => [number, number];
1206
1849
  readonly stats_stddev: (a: number, b: number) => [number, number];
1207
1850
  readonly stats_variance: (a: number, b: number) => [number, number];
1208
1851
  readonly test: () => [number, number];
@@ -1210,6 +1853,7 @@ export interface InitOutput {
1210
1853
  readonly test_housing_regression: () => [number, number];
1211
1854
  readonly test_r_accuracy: () => [number, number];
1212
1855
  readonly test_t_critical: (a: number, b: number) => [number, number];
1856
+ readonly vif_ranking: (a: number, b: number) => [number, number];
1213
1857
  readonly vif_test: (a: number, b: number, c: number, d: number) => [number, number];
1214
1858
  readonly white_test: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
1215
1859
  readonly wls_regression: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];