@nirs4all/methods 1.3.14 → 1.3.16
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 +154 -2
- package/dist/LICENSES/AGPL-3.0-or-later.txt +235 -0
- package/dist/LICENSES/Apache-2.0.txt +73 -0
- package/dist/LICENSES/BSD-3-Clause.txt +11 -0
- package/dist/LICENSES/COMMERCIAL-LICENSE.md +14 -0
- package/dist/LICENSES/COMMERCIAL-LICENSE_FR.md +15 -0
- package/dist/LICENSES/CeCILL-2.1.txt +518 -0
- package/dist/LICENSES/MIT.txt +18 -0
- package/dist/LICENSES/mixeff-dependencies.txt +13459 -0
- package/dist/LICENSES/mixeff-rs.txt +21 -0
- package/dist/LICENSES/rfr-cereal.txt +24 -0
- package/dist/LICENSES/rfr-rapidjson.txt +57 -0
- package/dist/LICENSES/rfr.txt +33 -0
- package/dist/LICENSES/rust-standard-library.txt +8266 -0
- package/dist/THIRD_PARTY_LICENSES.md +7 -0
- package/dist/componentAnalysis.d.ts +61 -0
- package/dist/componentAnalysis.js +175 -0
- package/dist/estimatorRoles.js +17 -0
- package/dist/estimatorRolesGenerated.d.ts +58 -1
- package/dist/estimatorRolesGenerated.js +53 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/n4m.js +1 -1
- package/dist/n4m.wasm +0 -0
- package/dist/preprocessing.js +5 -1
- package/dist/ranking.d.ts +61 -0
- package/dist/ranking.js +110 -0
- package/package.json +4 -3
|
@@ -131,3 +131,10 @@ Licensed under the BSD-3-Clause license; the algorithms reproduced here are
|
|
|
131
131
|
attributed to the NumPy project. The n4m source files are CECILL-2.1 OR
|
|
132
132
|
AGPL-3.0-or-later (see the repository LICENSING.md); BSD-3 is permissive and compatible.
|
|
133
133
|
```
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
## Optional component-analysis static engines
|
|
137
|
+
|
|
138
|
+
The analysis-enabled artifacts statically link mixeff-rs 1.0.0-rc.5 (MIT, default features disabled; no NLopt) and the reviewed pyrfr/rfr header closure at 1ba17650e734edd3ea536efc91d32815c4874e72 (BSD-3-Clause, with cereal and RapidJSON notices). No code from the restricted-license Python fANOVA package is included.
|
|
139
|
+
|
|
140
|
+
Full binary redistribution notices are bundled in `LICENSES/mixeff-rs.txt`, `LICENSES/mixeff-dependencies.txt`, `LICENSES/rust-standard-library.txt`, `LICENSES/rfr.txt`, `LICENSES/rfr-cereal.txt` and `LICENSES/rfr-rapidjson.txt`. The Rust dependency manifest and exact header checksums live under `cpp/backends/` in the source distribution.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Matrix } from "./types.js";
|
|
2
|
+
export interface MixedEffectsOptions {
|
|
3
|
+
reml?: boolean;
|
|
4
|
+
max_evaluations?: number;
|
|
5
|
+
tolerance?: number;
|
|
6
|
+
rank_tolerance?: number;
|
|
7
|
+
boundary_tolerance?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface MixedEffectsResult {
|
|
10
|
+
schema_version: "n4m.mixed_effects/1";
|
|
11
|
+
state: "ready" | "unavailable";
|
|
12
|
+
reason: string | null;
|
|
13
|
+
beta: (number | null)[] | null;
|
|
14
|
+
standard_errors: (number | null)[] | null;
|
|
15
|
+
covariance: (number | null)[][] | null;
|
|
16
|
+
variances: (number | null)[] | null;
|
|
17
|
+
diagnostics: Record<string, number | string | null>;
|
|
18
|
+
options: Record<string, number | null>;
|
|
19
|
+
uncertainty_kind: "conditional_plugin_standard_error";
|
|
20
|
+
warnings: string[];
|
|
21
|
+
}
|
|
22
|
+
/** X includes any intercept explicitly. Group IDs preserve int64 with BigInt64Array. */
|
|
23
|
+
export declare function mixedEffects(X: Matrix, y: Matrix, groups: {
|
|
24
|
+
data: BigInt64Array;
|
|
25
|
+
rows: number;
|
|
26
|
+
cols: number;
|
|
27
|
+
}, options?: MixedEffectsOptions): MixedEffectsResult;
|
|
28
|
+
export interface FanovaOptions {
|
|
29
|
+
n_trees?: number;
|
|
30
|
+
max_depth?: number;
|
|
31
|
+
min_samples_leaf?: number;
|
|
32
|
+
max_features?: number;
|
|
33
|
+
seed?: number;
|
|
34
|
+
max_order?: number;
|
|
35
|
+
max_marginal_evaluations?: number;
|
|
36
|
+
X_valid?: Matrix;
|
|
37
|
+
y_valid?: Matrix;
|
|
38
|
+
}
|
|
39
|
+
export interface FanovaResult {
|
|
40
|
+
schema_version: "n4m.fanova/1";
|
|
41
|
+
state: "ready" | "unavailable";
|
|
42
|
+
reason: string | null;
|
|
43
|
+
feature_importance: {
|
|
44
|
+
index: number;
|
|
45
|
+
fraction: number | null;
|
|
46
|
+
tree_sd: number | null;
|
|
47
|
+
}[];
|
|
48
|
+
interactions: {
|
|
49
|
+
indices: [number, number];
|
|
50
|
+
fraction: number | null;
|
|
51
|
+
tree_sd: number | null;
|
|
52
|
+
}[];
|
|
53
|
+
diagnostics: Record<string, number | null>;
|
|
54
|
+
options: Record<string, number | null>;
|
|
55
|
+
domain_measure: "uniform_product";
|
|
56
|
+
aggregation: "mean_per_tree_normalized_components";
|
|
57
|
+
uncertainty_kind: "tree_dispersion_not_confidence";
|
|
58
|
+
warnings: string[];
|
|
59
|
+
}
|
|
60
|
+
export declare function fanova(X: Matrix, y: Matrix, featureTypes: Uint32Array, bounds: Matrix, options?: FanovaOptions): FanovaResult;
|
|
61
|
+
export declare function normalizeLoss(values: Float64Array, baselines: Float64Array): Float64Array;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// SPDX-License-Identifier: CECILL-2.1 OR AGPL-3.0-or-later
|
|
2
|
+
/** Matrix-only adapters. Numerical fitting and normalization stay in the C ABI. */
|
|
3
|
+
import { checkStatus, getModule, makeMatrixView } from "./ffi.js";
|
|
4
|
+
const nullable = (v) => Number.isFinite(v) ? v : null;
|
|
5
|
+
class Arena {
|
|
6
|
+
m = getModule();
|
|
7
|
+
ptrs = [];
|
|
8
|
+
views = [];
|
|
9
|
+
alloc(bytes) {
|
|
10
|
+
if (!Number.isSafeInteger(bytes) || bytes < 1 || bytes > 0x7fffffff)
|
|
11
|
+
throw new RangeError("analysis allocation exceeds WASM limit");
|
|
12
|
+
const p = this.m._malloc(bytes);
|
|
13
|
+
if (!p)
|
|
14
|
+
throw new Error("analysis allocation failed");
|
|
15
|
+
this.ptrs.push(p);
|
|
16
|
+
return p;
|
|
17
|
+
}
|
|
18
|
+
matrix(x) {
|
|
19
|
+
if (!Number.isSafeInteger(x.rows) || !Number.isSafeInteger(x.cols) || x.rows < 1 || x.cols < 1 ||
|
|
20
|
+
x.data.length !== x.rows * x.cols)
|
|
21
|
+
throw new Error("invalid nonempty matrix");
|
|
22
|
+
const v = makeMatrixView(x.data, x.rows, x.cols);
|
|
23
|
+
this.views.push(v);
|
|
24
|
+
return v.viewPtr;
|
|
25
|
+
}
|
|
26
|
+
free() { for (const v of this.views)
|
|
27
|
+
v.free(); for (const p of this.ptrs)
|
|
28
|
+
this.m._free(p); }
|
|
29
|
+
read(p, n) {
|
|
30
|
+
return Array.from(this.m.HEAPF64.subarray(p / 8, p / 8 + n), nullable);
|
|
31
|
+
}
|
|
32
|
+
options(init, size, fields, values) {
|
|
33
|
+
const p = this.alloc(size);
|
|
34
|
+
checkStatus(this.m.ccall(init, "number", ["number"], [p]));
|
|
35
|
+
for (const [key, value] of Object.entries(values)) {
|
|
36
|
+
if (value === undefined)
|
|
37
|
+
continue;
|
|
38
|
+
const field = fields.find(f => f[0] === key);
|
|
39
|
+
if (!field)
|
|
40
|
+
throw new Error(`unknown component analysis option ${key}`);
|
|
41
|
+
const [, offset, type] = field;
|
|
42
|
+
const v = key === "reml" && typeof value === "boolean" ? Number(value) : value;
|
|
43
|
+
if (typeof v !== "number" || !Number.isFinite(v))
|
|
44
|
+
throw new Error(`${key} must be finite`);
|
|
45
|
+
const d = new DataView(this.m.HEAPU8.buffer);
|
|
46
|
+
if (type === "f64")
|
|
47
|
+
d.setFloat64(p + offset, v, true);
|
|
48
|
+
else {
|
|
49
|
+
if (!Number.isSafeInteger(v))
|
|
50
|
+
throw new Error(`${key} must be a safe integer`);
|
|
51
|
+
if (type === "i32") {
|
|
52
|
+
if (v < -2147483648 || v > 2147483647)
|
|
53
|
+
throw new RangeError(`${key} exceeds int32 range`);
|
|
54
|
+
d.setInt32(p + offset, v, true);
|
|
55
|
+
}
|
|
56
|
+
else if (type === "u64") {
|
|
57
|
+
if (v < 0)
|
|
58
|
+
throw new RangeError(`${key} must be nonnegative`);
|
|
59
|
+
d.setBigUint64(p + offset, BigInt(v), true);
|
|
60
|
+
}
|
|
61
|
+
else
|
|
62
|
+
d.setBigInt64(p + offset, BigInt(v), true);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return p;
|
|
66
|
+
}
|
|
67
|
+
fields(p, fields) {
|
|
68
|
+
const d = new DataView(this.m.HEAPU8.buffer);
|
|
69
|
+
return Object.fromEntries(fields.map(([key, offset, type]) => [key,
|
|
70
|
+
type === "f64" ? nullable(d.getFloat64(p + offset, true)) : type === "i32" ? d.getInt32(p + offset, true) :
|
|
71
|
+
Number(type === "u64" ? d.getBigUint64(p + offset, true) : d.getBigInt64(p + offset, true))]));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const MIXED_OPTIONS = [["reml", 8, "i32"], ["max_evaluations", 16, "i64"],
|
|
75
|
+
["tolerance", 24, "f64"], ["rank_tolerance", 32, "f64"], ["boundary_tolerance", 40, "f64"]];
|
|
76
|
+
const MIXED_SUMMARY = [["fit_state", 8, "i32"], ["reason", 12, "i32"], ["converged", 16, "i32"],
|
|
77
|
+
["singular", 20, "i32"], ["boundary", 24, "i32"], ["optimizer_status", 28, "i32"],
|
|
78
|
+
["observations", 32, "i64"], ["fixed_effects", 40, "i64"], ["group_terms", 48, "i64"],
|
|
79
|
+
["design_rank", 56, "i64"], ["total_group_levels", 64, "i64"], ["evaluations", 72, "i64"],
|
|
80
|
+
["objective", 80, "f64"], ["log_likelihood", 88, "f64"], ["residual_df", 96, "f64"], ["condition_number", 104, "f64"]];
|
|
81
|
+
/** X includes any intercept explicitly. Group IDs preserve int64 with BigInt64Array. */
|
|
82
|
+
export function mixedEffects(X, y, groups, options = {}) {
|
|
83
|
+
const a = new Arena();
|
|
84
|
+
try {
|
|
85
|
+
const opt = a.options("n4m_mixed_effects_options_init_v1", 48, MIXED_OPTIONS, { ...options });
|
|
86
|
+
const base = { schema_version: "n4m.mixed_effects/1", options: a.fields(opt, MIXED_OPTIONS),
|
|
87
|
+
uncertainty_kind: "conditional_plugin_standard_error",
|
|
88
|
+
warnings: ["Gaussian random-intercept associations are not causal effects.", "Plug-in SE excludes variance-parameter uncertainty."] };
|
|
89
|
+
if (!a.m.ccall("n4m_mixed_effects_backend_available_v1", "number", [], [])) {
|
|
90
|
+
return { ...base, state: "unavailable", reason: "mixed_effects_backend_not_compiled", beta: null,
|
|
91
|
+
covariance: null, standard_errors: null, variances: null, diagnostics: {} };
|
|
92
|
+
}
|
|
93
|
+
const xv = a.matrix(X), yv = a.matrix(y);
|
|
94
|
+
if (!(groups.data instanceof BigInt64Array) || !Number.isSafeInteger(groups.rows) || !Number.isSafeInteger(groups.cols) ||
|
|
95
|
+
groups.rows < 1 || groups.cols < 1 || groups.data.length !== groups.rows * groups.cols)
|
|
96
|
+
throw new Error("invalid int64 group matrix");
|
|
97
|
+
const gp = a.alloc(groups.data.byteLength), gv = a.alloc(48);
|
|
98
|
+
a.m.HEAPU8.set(new Uint8Array(groups.data.buffer, groups.data.byteOffset, groups.data.byteLength), gp);
|
|
99
|
+
checkStatus(a.m.ccall("n4m_matrix_view_init_rowmajor", "number", ["number", "number", "i64", "i64", "number"], [gv, gp, BigInt(groups.rows), BigInt(groups.cols), 4]));
|
|
100
|
+
const p = X.cols, k = groups.cols, beta = a.alloc(p * 8), cov = a.alloc(p * p * 8), se = a.alloc(p * 8), variances = a.alloc((k + 1) * 8), summary = a.alloc(112);
|
|
101
|
+
new DataView(a.m.HEAPU8.buffer).setBigUint64(summary, 112n, true);
|
|
102
|
+
checkStatus(a.m.ccall("n4m_mixed_effects_fit_v1", "number", ["number", "number", "number", "number", "number", "i64", "number", "i64", "number", "i64", "number", "i64", "number"], [xv, yv, gv, opt, beta, BigInt(p), cov, BigInt(p * p), se, BigInt(p), variances, BigInt(k + 1), summary]));
|
|
103
|
+
const diagnostics = a.fields(summary, MIXED_SUMMARY);
|
|
104
|
+
const state = diagnostics.fit_state, reason = diagnostics.reason;
|
|
105
|
+
diagnostics.fit_state = ["fitted", "fitted_boundary", "rank_deficient", "unidentifiable", "nonconverged", "numerical_refusal"][state];
|
|
106
|
+
return { ...base, state: state <= 1 ? "ready" : "unavailable", reason: [null, "fixed_rank", "no_residual_df", "constant_response",
|
|
107
|
+
"insufficient_group_levels", "confounded_variances", "zero_residual", "optimizer_budget", "optimizer_roundoff",
|
|
108
|
+
"optimizer_failure", "nonfinite_result", "engine_rejected"][reason],
|
|
109
|
+
beta: a.read(beta, p), standard_errors: a.read(se, p), covariance: Array.from({ length: p }, (_, i) => a.read(cov + i * p * 8, p)),
|
|
110
|
+
variances: a.read(variances, k + 1), diagnostics };
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
a.free();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const FANOVA_OPTIONS = [["num_trees", 8, "i32"], ["max_depth", 12, "i32"], ["min_samples_leaf", 16, "i32"],
|
|
117
|
+
["max_features", 20, "i32"], ["seed", 24, "u64"], ["max_order", 32, "i32"], ["max_marginal_evaluations", 40, "i64"]];
|
|
118
|
+
const FANOVA_SUMMARY = [["fit_state", 8, "i32"], ["observations", 16, "i64"], ["features", 24, "i64"],
|
|
119
|
+
["trees", 32, "i64"], ["informative_trees", 40, "i64"], ["marginal_evaluations", 48, "i64"],
|
|
120
|
+
["total_variance_mean", 56, "f64"], ["remaining_fraction", 64, "f64"], ["train_rmse", 72, "f64"],
|
|
121
|
+
["validation_rmse", 80, "f64"], ["validation_r2", 88, "f64"]];
|
|
122
|
+
export function fanova(X, y, featureTypes, bounds, options = {}) {
|
|
123
|
+
const a = new Arena();
|
|
124
|
+
try {
|
|
125
|
+
const { n_trees = 32, X_valid, y_valid, ...rest } = options;
|
|
126
|
+
if ((X_valid === undefined) !== (y_valid === undefined))
|
|
127
|
+
throw new Error("X_valid and y_valid are required together");
|
|
128
|
+
const opt = a.options("n4m_fanova_options_init_v1", 48, FANOVA_OPTIONS, { num_trees: n_trees, ...rest });
|
|
129
|
+
const resolved = a.fields(opt, FANOVA_OPTIONS);
|
|
130
|
+
const base = { schema_version: "n4m.fanova/1", options: resolved, domain_measure: "uniform_product",
|
|
131
|
+
aggregation: "mean_per_tree_normalized_components", uncertainty_kind: "tree_dispersion_not_confidence",
|
|
132
|
+
warnings: ["Surrogate attribution under independent uniform domains is not causal.", "Tree dispersion is not a confidence interval."] };
|
|
133
|
+
if (!a.m.ccall("n4m_fanova_backend_available_v1", "number", [], []))
|
|
134
|
+
return { ...base, state: "unavailable",
|
|
135
|
+
reason: "fanova_backend_not_compiled", feature_importance: [], interactions: [], diagnostics: {} };
|
|
136
|
+
const xv = a.matrix(X), yv = a.matrix(y), bv = a.matrix(bounds), p = X.cols;
|
|
137
|
+
if (!(featureTypes instanceof Uint32Array) || featureTypes.length !== p)
|
|
138
|
+
throw new Error("one feature type is required per column");
|
|
139
|
+
const types = a.alloc(p * 4);
|
|
140
|
+
a.m.HEAPU8.set(new Uint8Array(featureTypes.buffer, featureTypes.byteOffset, featureTypes.byteLength), types);
|
|
141
|
+
const vx = X_valid ? a.matrix(X_valid) : 0, vy = y_valid ? a.matrix(y_valid) : 0;
|
|
142
|
+
const mains = a.alloc(p * 16), pairs = a.alloc(p * p * 16), summary = a.alloc(96);
|
|
143
|
+
new DataView(a.m.HEAPU8.buffer).setBigUint64(summary, 96n, true);
|
|
144
|
+
checkStatus(a.m.ccall("n4m_fanova_fit_v1", "number", ["number", "number", "number", "number", "number", "number", "number", "number", "i64", "number", "i64", "number"], [xv, yv, bv, types, vx, vy, opt, mains, BigInt(p * 2), pairs, BigInt(p * p * 2), summary]));
|
|
145
|
+
const diagnostics = a.fields(summary, FANOVA_SUMMARY), state = diagnostics.fit_state;
|
|
146
|
+
const feature_importance = Array.from({ length: p }, (_, i) => ({ index: i, fraction: a.read(mains + i * 16, 1)[0], tree_sd: a.read(mains + i * 16 + 8, 1)[0] }));
|
|
147
|
+
const interactions = [];
|
|
148
|
+
if (resolved.max_order === 2)
|
|
149
|
+
for (let i = 0; i < p; i++)
|
|
150
|
+
for (let j = i + 1; j < p; j++) {
|
|
151
|
+
const v = a.read(pairs + (i * p + j) * 16, 2);
|
|
152
|
+
interactions.push({ indices: [i, j], fraction: v[0], tree_sd: v[1] });
|
|
153
|
+
}
|
|
154
|
+
return { ...base, state: state === 0 ? "ready" : "unavailable", reason: [null, "zero_surrogate_variance", "zero_surrogate_variance", "numerical_refusal"][state],
|
|
155
|
+
feature_importance, interactions, diagnostics };
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
a.free();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
export function normalizeLoss(values, baselines) {
|
|
162
|
+
if (values.length !== baselines.length || values.length < 1)
|
|
163
|
+
throw new Error("values and baselines must have the same nonempty length");
|
|
164
|
+
const a = new Arena();
|
|
165
|
+
try {
|
|
166
|
+
const x = a.alloc(values.byteLength), b = a.alloc(baselines.byteLength), out = a.alloc(values.byteLength);
|
|
167
|
+
a.m.HEAPF64.set(values, x / 8);
|
|
168
|
+
a.m.HEAPF64.set(baselines, b / 8);
|
|
169
|
+
checkStatus(a.m.ccall("n4m_component_normalize_loss_v1", "number", ["number", "number", "i64", "number"], [x, b, BigInt(values.length), out]));
|
|
170
|
+
return a.m.HEAPF64.slice(out / 8, out / 8 + values.length);
|
|
171
|
+
}
|
|
172
|
+
finally {
|
|
173
|
+
a.free();
|
|
174
|
+
}
|
|
175
|
+
}
|
package/dist/estimatorRoles.js
CHANGED
|
@@ -61,8 +61,25 @@ export function cString(s) {
|
|
|
61
61
|
m.stringToUTF8(s, ptr, n);
|
|
62
62
|
return { ptr, free: () => m._free(ptr) };
|
|
63
63
|
}
|
|
64
|
+
/** SNV host types must survive marshalling without coercion or i32 overflow. */
|
|
65
|
+
function validateSnvParams(method) {
|
|
66
|
+
if (method.methodId !== "preprocessing.scatter.snv")
|
|
67
|
+
return;
|
|
68
|
+
for (const name of ["with_mean", "with_std"]) {
|
|
69
|
+
const value = method.params[name];
|
|
70
|
+
if (value !== undefined && typeof value !== "boolean") {
|
|
71
|
+
throw new TypeError(`SNV ${name} must be a boolean`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const ddof = method.params.ddof;
|
|
75
|
+
if (ddof !== undefined && (typeof ddof !== "number" ||
|
|
76
|
+
!Number.isSafeInteger(ddof) || ddof < 0 || ddof > 2147483647)) {
|
|
77
|
+
throw new TypeError("SNV ddof must be an integer number in [0, INT32_MAX]");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
64
80
|
/** Validated native parameters of a method; the caller destroys them. */
|
|
65
81
|
export function nativeParams(ctx, method) {
|
|
82
|
+
validateSnvParams(method);
|
|
66
83
|
const m = getModule();
|
|
67
84
|
const indexPtr = m._malloc(4);
|
|
68
85
|
const out = m._malloc(4);
|
|
@@ -2300,6 +2300,33 @@ export declare class KernelPLS extends NativeEstimator implements Regressor {
|
|
|
2300
2300
|
constructor(params?: KernelPLSParams);
|
|
2301
2301
|
predict(X: Matrix): Matrix;
|
|
2302
2302
|
}
|
|
2303
|
+
/** Parameters of OPLS; unset values take the native defaults. */
|
|
2304
|
+
export interface OPLSParams {
|
|
2305
|
+
/** Default 2. */
|
|
2306
|
+
n_components?: number;
|
|
2307
|
+
/** Default true. */
|
|
2308
|
+
center_x?: boolean;
|
|
2309
|
+
/** Default true. */
|
|
2310
|
+
scale_x?: boolean;
|
|
2311
|
+
/** Default true. */
|
|
2312
|
+
center_y?: boolean;
|
|
2313
|
+
/** Default true. */
|
|
2314
|
+
scale_y?: boolean;
|
|
2315
|
+
}
|
|
2316
|
+
/** Native `models.pls.opls` (transformer, regressor). */
|
|
2317
|
+
export declare class OPLS extends NativeEstimator implements Regressor, Transformer {
|
|
2318
|
+
readonly methodId = "models.pls.opls";
|
|
2319
|
+
readonly paramTypes: {
|
|
2320
|
+
readonly n_components: "int";
|
|
2321
|
+
readonly center_x: "bool";
|
|
2322
|
+
readonly scale_x: "bool";
|
|
2323
|
+
readonly center_y: "bool";
|
|
2324
|
+
readonly scale_y: "bool";
|
|
2325
|
+
};
|
|
2326
|
+
constructor(params?: OPLSParams);
|
|
2327
|
+
predict(X: Matrix): Matrix;
|
|
2328
|
+
transform(X: Matrix): Matrix;
|
|
2329
|
+
}
|
|
2303
2330
|
/** Parameters of PCR; unset values take the native defaults. */
|
|
2304
2331
|
export interface PCRParams {
|
|
2305
2332
|
/** Default 2. */
|
|
@@ -3321,6 +3348,16 @@ export declare class Normalize extends NativeEstimator implements Transformer {
|
|
|
3321
3348
|
constructor(params?: NormalizeParams);
|
|
3322
3349
|
transform(X: Matrix): Matrix;
|
|
3323
3350
|
}
|
|
3351
|
+
/** Parameters of RowL2Normalize; unset values take the native defaults. */
|
|
3352
|
+
export interface RowL2NormalizeParams {
|
|
3353
|
+
}
|
|
3354
|
+
/** Native `preprocessing.scaling.row_l2_normalize` (transformer). */
|
|
3355
|
+
export declare class RowL2Normalize extends NativeEstimator implements Transformer {
|
|
3356
|
+
readonly methodId = "preprocessing.scaling.row_l2_normalize";
|
|
3357
|
+
readonly paramTypes: {};
|
|
3358
|
+
constructor(params?: RowL2NormalizeParams);
|
|
3359
|
+
transform(X: Matrix): Matrix;
|
|
3360
|
+
}
|
|
3324
3361
|
/** Parameters of SimpleScale; unset values take the native defaults. */
|
|
3325
3362
|
export interface SimpleScaleParams {
|
|
3326
3363
|
}
|
|
@@ -3337,6 +3374,8 @@ export interface StandardScaleParams {
|
|
|
3337
3374
|
with_mean?: boolean;
|
|
3338
3375
|
/** Default true. */
|
|
3339
3376
|
with_std?: boolean;
|
|
3377
|
+
/** Default 0. */
|
|
3378
|
+
ddof?: number;
|
|
3340
3379
|
}
|
|
3341
3380
|
/** Native `preprocessing.scaling.standard_scale` (transformer). */
|
|
3342
3381
|
export declare class StandardScale extends NativeEstimator implements Transformer {
|
|
@@ -3344,6 +3383,7 @@ export declare class StandardScale extends NativeEstimator implements Transforme
|
|
|
3344
3383
|
readonly paramTypes: {
|
|
3345
3384
|
readonly with_mean: "bool";
|
|
3346
3385
|
readonly with_std: "bool";
|
|
3386
|
+
readonly ddof: "int";
|
|
3347
3387
|
};
|
|
3348
3388
|
constructor(params?: StandardScaleParams);
|
|
3349
3389
|
transform(X: Matrix): Matrix;
|
|
@@ -4599,14 +4639,17 @@ export declare class KBinsStratified extends NativeProcedure implements Splitter
|
|
|
4599
4639
|
}
|
|
4600
4640
|
/** Parameters of KennardStone; unset values take the native defaults. */
|
|
4601
4641
|
export interface KennardStoneParams {
|
|
4602
|
-
/**
|
|
4642
|
+
/** Optional: unset by default. */
|
|
4603
4643
|
test_size?: number;
|
|
4644
|
+
/** Optional: unset by default. */
|
|
4645
|
+
n_train?: number;
|
|
4604
4646
|
}
|
|
4605
4647
|
/** Native `splitters.kennard_stone` (splitter). */
|
|
4606
4648
|
export declare class KennardStone extends NativeProcedure implements Splitter {
|
|
4607
4649
|
readonly methodId = "splitters.kennard_stone";
|
|
4608
4650
|
readonly paramTypes: {
|
|
4609
4651
|
readonly test_size: "double";
|
|
4652
|
+
readonly n_train: "int";
|
|
4610
4653
|
};
|
|
4611
4654
|
constructor(params?: KennardStoneParams);
|
|
4612
4655
|
split(X: Matrix, y?: Float64Array | ArrayLike<number>, groups?: number[]): Fold[];
|
|
@@ -4716,6 +4759,20 @@ export declare class SystematicCircular extends NativeProcedure implements Split
|
|
|
4716
4759
|
constructor(params?: SystematicCircularParams);
|
|
4717
4760
|
split(X: Matrix, y?: Float64Array | ArrayLike<number>, groups?: number[]): Fold[];
|
|
4718
4761
|
}
|
|
4762
|
+
/** Parameters of FiniteColumnQuantiles; unset values take the native defaults. */
|
|
4763
|
+
export interface FiniteColumnQuantilesParams {
|
|
4764
|
+
/** Required. */
|
|
4765
|
+
probabilities?: number[];
|
|
4766
|
+
}
|
|
4767
|
+
/** Native `utilities.finite_column_quantiles` (generic). */
|
|
4768
|
+
export declare class FiniteColumnQuantiles extends NativeProcedure implements Procedure {
|
|
4769
|
+
readonly methodId = "utilities.finite_column_quantiles";
|
|
4770
|
+
readonly paramTypes: {
|
|
4771
|
+
readonly probabilities: "double_array";
|
|
4772
|
+
};
|
|
4773
|
+
constructor(params?: FiniteColumnQuantilesParams);
|
|
4774
|
+
run(X: Matrix, y?: Matrix | Float64Array | ArrayLike<number>, inputs?: FitInputs): Record<string, ProcedureOutput>;
|
|
4775
|
+
}
|
|
4719
4776
|
/** Parameters of HotellingT2; unset values take the native defaults. */
|
|
4720
4777
|
export interface HotellingT2Params {
|
|
4721
4778
|
/** Default 5. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: CECILL-2.1 OR AGPL-3.0-or-later
|
|
2
2
|
// Generated by scripts/generate_js_roles.py from `n4m_cli --manifest-json`. Do not edit.
|
|
3
|
-
// Native ABI 2.
|
|
3
|
+
// Native ABI 2.22.0.
|
|
4
4
|
import { NativeEstimator, NativeMethod, NativeProcedure, } from "./estimatorRoles.js";
|
|
5
5
|
/** Native `aom_pop.aom_chain_fixed_fit` (regressor). */
|
|
6
6
|
export class AOMFixedCandidate extends NativeEstimator {
|
|
@@ -1724,6 +1724,28 @@ export class KernelPLS extends NativeEstimator {
|
|
|
1724
1724
|
}
|
|
1725
1725
|
}
|
|
1726
1726
|
NativeMethod.register("models.pls.kernel", KernelPLS);
|
|
1727
|
+
/** Native `models.pls.opls` (transformer, regressor). */
|
|
1728
|
+
export class OPLS extends NativeEstimator {
|
|
1729
|
+
methodId = "models.pls.opls";
|
|
1730
|
+
paramTypes = {
|
|
1731
|
+
n_components: "int",
|
|
1732
|
+
center_x: "bool",
|
|
1733
|
+
scale_x: "bool",
|
|
1734
|
+
center_y: "bool",
|
|
1735
|
+
scale_y: "bool",
|
|
1736
|
+
};
|
|
1737
|
+
constructor(params = {}) {
|
|
1738
|
+
super();
|
|
1739
|
+
this.params = { ...params };
|
|
1740
|
+
}
|
|
1741
|
+
predict(X) {
|
|
1742
|
+
return this.predictMatrix(X);
|
|
1743
|
+
}
|
|
1744
|
+
transform(X) {
|
|
1745
|
+
return this.transformMatrix(X);
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
NativeMethod.register("models.pls.opls", OPLS);
|
|
1727
1749
|
/** Native `models.pls.pcr` (transformer, regressor). */
|
|
1728
1750
|
export class PCR extends NativeEstimator {
|
|
1729
1751
|
methodId = "models.pls.pcr";
|
|
@@ -2617,6 +2639,19 @@ export class Normalize extends NativeEstimator {
|
|
|
2617
2639
|
}
|
|
2618
2640
|
}
|
|
2619
2641
|
NativeMethod.register("preprocessing.scaling.normalize", Normalize);
|
|
2642
|
+
/** Native `preprocessing.scaling.row_l2_normalize` (transformer). */
|
|
2643
|
+
export class RowL2Normalize extends NativeEstimator {
|
|
2644
|
+
methodId = "preprocessing.scaling.row_l2_normalize";
|
|
2645
|
+
paramTypes = {};
|
|
2646
|
+
constructor(params = {}) {
|
|
2647
|
+
super();
|
|
2648
|
+
this.params = { ...params };
|
|
2649
|
+
}
|
|
2650
|
+
transform(X) {
|
|
2651
|
+
return this.transformMatrix(X);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
NativeMethod.register("preprocessing.scaling.row_l2_normalize", RowL2Normalize);
|
|
2620
2655
|
/** Native `preprocessing.scaling.simple_scale` (transformer). */
|
|
2621
2656
|
export class SimpleScale extends NativeEstimator {
|
|
2622
2657
|
methodId = "preprocessing.scaling.simple_scale";
|
|
@@ -2636,6 +2671,7 @@ export class StandardScale extends NativeEstimator {
|
|
|
2636
2671
|
paramTypes = {
|
|
2637
2672
|
with_mean: "bool",
|
|
2638
2673
|
with_std: "bool",
|
|
2674
|
+
ddof: "int",
|
|
2639
2675
|
};
|
|
2640
2676
|
constructor(params = {}) {
|
|
2641
2677
|
super();
|
|
@@ -3719,6 +3755,7 @@ export class KennardStone extends NativeProcedure {
|
|
|
3719
3755
|
methodId = "splitters.kennard_stone";
|
|
3720
3756
|
paramTypes = {
|
|
3721
3757
|
test_size: "double",
|
|
3758
|
+
n_train: "int",
|
|
3722
3759
|
};
|
|
3723
3760
|
constructor(params = {}) {
|
|
3724
3761
|
super();
|
|
@@ -3826,6 +3863,21 @@ export class SystematicCircular extends NativeProcedure {
|
|
|
3826
3863
|
}
|
|
3827
3864
|
}
|
|
3828
3865
|
NativeMethod.register("splitters.systematic_circular", SystematicCircular);
|
|
3866
|
+
/** Native `utilities.finite_column_quantiles` (generic). */
|
|
3867
|
+
export class FiniteColumnQuantiles extends NativeProcedure {
|
|
3868
|
+
methodId = "utilities.finite_column_quantiles";
|
|
3869
|
+
paramTypes = {
|
|
3870
|
+
probabilities: "double_array",
|
|
3871
|
+
};
|
|
3872
|
+
constructor(params = {}) {
|
|
3873
|
+
super();
|
|
3874
|
+
this.params = { ...params };
|
|
3875
|
+
}
|
|
3876
|
+
run(X, y, inputs = {}) {
|
|
3877
|
+
return this.runOutputs(X, y, inputs);
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
NativeMethod.register("utilities.finite_column_quantiles", FiniteColumnQuantiles);
|
|
3829
3881
|
/** Native `utilities.hotelling_t2` (generic). */
|
|
3830
3882
|
export class HotellingT2 extends NativeProcedure {
|
|
3831
3883
|
methodId = "utilities.hotelling_t2";
|
package/dist/index.d.ts
CHANGED
|
@@ -22,3 +22,5 @@ export { Status, Dtype, Algorithm, Solver, Deflation, ModelArray, N4mError, type
|
|
|
22
22
|
export declare function version(): string;
|
|
23
23
|
/** ABI MAJOR.MINOR.PATCH triple. */
|
|
24
24
|
export declare function abiVersion(): readonly [number, number, number];
|
|
25
|
+
export { rank, type RankingMethod, type RankingOptions, type RankingCandidate, type RankingResult } from "./ranking.js";
|
|
26
|
+
export { mixedEffects, fanova, normalizeLoss, type MixedEffectsOptions, type MixedEffectsResult, type FanovaOptions, type FanovaResult } from "./componentAnalysis.js";
|