umap-web 0.2.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.
@@ -0,0 +1,373 @@
1
+ import { S as Matrix, _ as DenseInput, f as Pcg32, g as CSRInput, t as Csr, v as Embedding, x as Logger, y as KnnGraph } from "./sparse-BxSeVhO4.js";
2
+
3
+ //#region src/graph/ab.d.ts
4
+
5
+ /**
6
+ * find_ab_params (umap_.py:1393-1408): least-squares fit of
7
+ * curve(x) = 1 / (1 + a·x^(2b)) to the fuzzy-membership target built from
8
+ * (spread, minDist), via Levenberg–Marquardt from p0 = (1, 1) — mirroring
9
+ * scipy.optimize.curve_fit's default solver on the same 300-point grid.
10
+ */
11
+ interface ABParams {
12
+ a: number;
13
+ b: number;
14
+ }
15
+ declare function findABParams(spread: number, minDist: number): ABParams;
16
+ //#endregion
17
+ //#region src/graph/epochs.d.ts
18
+ declare function makeEpochsPerSample(weights: Float64Array | Float32Array, nEpochs: number): Float64Array;
19
+ /** Default epoch rule: 500 for n<=10000 else 200; +200 when densMAP (notes §6.2). */
20
+ declare function defaultNEpochs(nVertices: number, densmap: boolean): number;
21
+ /**
22
+ * Prune graph weights below max/n_epochs (in place on a copy) exactly like
23
+ * simplicial_set_embedding, returning the pruned graph.
24
+ */
25
+ declare function pruneGraphForEpochs(graph: Csr, nEpochsMax: number, defaultEpochs: number): Csr;
26
+ //#endregion
27
+ //#region src/graph/fuzzy.d.ts
28
+ interface MembershipStrengths {
29
+ rows: Int32Array;
30
+ cols: Int32Array;
31
+ vals: Float32Array;
32
+ dists: Float32Array | null;
33
+ }
34
+ declare function computeMembershipStrengths(knnIndices: Int32Array, knnDists: Float32Array, sigmas: Float32Array, rhos: Float32Array, nNeighbors: number, returnDists?: boolean, bipartite?: boolean): MembershipStrengths;
35
+ interface FuzzySimplicialSetResult {
36
+ graph: Csr;
37
+ sigmas: Float32Array;
38
+ rhos: Float32Array;
39
+ /** symmetrized (max) distances, only when returnDists */
40
+ dists: Csr | null;
41
+ }
42
+ interface FuzzySimplicialSetOptions {
43
+ setOpMixRatio?: number;
44
+ localConnectivity?: number;
45
+ applySetOperations?: boolean;
46
+ returnDists?: boolean;
47
+ bipartite?: boolean;
48
+ }
49
+ /**
50
+ * Build the fuzzy simplicial set from a kNN graph (knn indices+distances required;
51
+ * the estimator computes them per §5.2 backends).
52
+ */
53
+ declare function fuzzySimplicialSet(nSamples: number, nNeighbors: number, knnIndices: Int32Array, knnDists: Float32Array, {
54
+ setOpMixRatio,
55
+ localConnectivity,
56
+ applySetOperations,
57
+ returnDists
58
+ }?: FuzzySimplicialSetOptions): FuzzySimplicialSetResult;
59
+ //#endregion
60
+ //#region src/graph/smooth.d.ts
61
+ /**
62
+ * smooth_knn_dist — sigma/rho computation (umap_.py:143-253; notes §1).
63
+ *
64
+ * Python runs this in float32 fastmath; we compute in float64 (matches to ~1e-6,
65
+ * within the §3.3 tolerance policy).
66
+ */
67
+ declare const SMOOTH_K_TOLERANCE = 0.00001;
68
+ declare const MIN_K_DIST_SCALE = 0.001;
69
+ interface SmoothKnnResult {
70
+ sigmas: Float32Array;
71
+ rhos: Float32Array;
72
+ }
73
+ interface SmoothKnnOptions {
74
+ nIter?: number;
75
+ localConnectivity?: number;
76
+ bandwidth?: number;
77
+ }
78
+ /**
79
+ * @param distances (nSamples × nNeighbors) row-major, each row sorted ascending
80
+ * (includes self at column 0 for standard kNN).
81
+ * @param k the float number of neighbors (callers pass the integer k).
82
+ */
83
+ declare function smoothKnnDist(distances: Float32Array, nNeighbors: number, k: number, {
84
+ nIter,
85
+ localConnectivity,
86
+ bandwidth
87
+ }?: SmoothKnnOptions): SmoothKnnResult;
88
+ //#endregion
89
+ //#region src/init/index.d.ts
90
+ type InitMethod = 'spectral' | 'random' | 'pca' | Embedding;
91
+ /** noisy_scale_coords (umap_.py:928-935): scale abs-max to maxCoord, add N(0, noise). */
92
+ declare function noisyScaleCoords(coords: Float64Array, rng: Pcg32, maxCoord?: number, noise?: number): void;
93
+ /** Final rescale applied to EVERY init (umap_.py:1188-1192): per-dim min-max → [0,10]. */
94
+ declare function finalInitRescale(embedding: Float64Array, n: number, dim: number): Float32Array;
95
+ interface InitializeOptions {
96
+ logger?: Logger;
97
+ }
98
+ interface InitializeResult {
99
+ embedding: Float32Array;
100
+ spectralFallback: boolean;
101
+ }
102
+ /**
103
+ * Produce the initial embedding for `graph` (pruned fuzzy graph) and `data`.
104
+ * Data may be null when init doesn't need it (random / spectral without
105
+ * multi-component meta layout data).
106
+ */
107
+ declare function initializeEmbedding(init: InitMethod, data: Matrix | null, graph: Csr, dim: number, rng: Pcg32, {
108
+ logger
109
+ }?: InitializeOptions): InitializeResult;
110
+ //#endregion
111
+ //#region src/init/pca.d.ts
112
+ declare function pcaScores(X: Matrix, dim: number, rng: Pcg32, center?: boolean): Float64Array;
113
+ //#endregion
114
+ //#region src/init/spectral.d.ts
115
+ interface SpectralResult {
116
+ embedding: Float64Array;
117
+ usedFallback: boolean;
118
+ }
119
+ /** Connected components via BFS over an undirected CSR graph. */
120
+ declare function connectedComponents(graph: Csr): {
121
+ count: number;
122
+ labels: Int32Array;
123
+ };
124
+ interface LobpcgResult {
125
+ values: Float64Array;
126
+ /** col-major eigenvectors (m columns of length n) */
127
+ vectors: Float64Array;
128
+ converged: boolean;
129
+ iterations: number;
130
+ residuals: Float64Array;
131
+ }
132
+ /**
133
+ * LOBPCG for the m smallest eigenpairs of the normalized Laplacian of `graph`,
134
+ * with diagonal (Jacobi) preconditioner. X0 is col-major n×m.
135
+ */
136
+ declare function lobpcgSmallest(graph: Csr, dinvsqrt: Float64Array, X0: Float64Array, m: number, tol?: number, maxIter?: number): LobpcgResult;
137
+ /** Degree vector d_i = Σ_j A_ij and its inverse sqrt. */
138
+ declare function degreeInvSqrt(graph: Csr): {
139
+ deg: Float64Array;
140
+ dinvsqrt: Float64Array;
141
+ };
142
+ /**
143
+ * spectral_layout: normalized-Laplacian eigenmaps of the fuzzy graph with
144
+ * multi-component handling. Returns n×dim float64 (caller scales/noises/casts).
145
+ */
146
+ declare function spectralLayout(data: Matrix | null, graph: Csr, dim: number, rng: Pcg32, logger?: Logger): SpectralResult;
147
+ declare namespace metrics_d_exports {
148
+ export { ANGULAR_METRICS, MetricImpl, MetricOptions, NAMED_METRICS, Vec, brayCurtis, canberra, canonicalMetricName, chebyshev, correlation, cosine, dice, euclidean, hamming, haversine, hellinger, isNamedMetric, jaccard, kulsinski, llDirichlet, mahalanobis, manhattan, matching, minkowski, resolveMetric, rogersTanimoto, russellrao, sokalMichener, sokalSneath, sqeuclidean, standardisedEuclidean, symmetricKl, validateMetricOptionSizes, weightedMinkowski, yule };
149
+ }
150
+ /**
151
+ * Named distance metrics — faithful ports of `umap.distances` (vendored 0.5.9.post2).
152
+ * Every formula, branch, and edge case mirrors the Python source (see
153
+ * reference/notes/umap-internals.md and DECISIONS.md D-004 for the requirement set).
154
+ *
155
+ * Computation is float64 (JS Number); inputs are typically Float32Array views.
156
+ */
157
+ type Vec = Float32Array | Float64Array;
158
+ type MetricImpl = (x: Vec, y: Vec) => number;
159
+ interface MetricOptions {
160
+ /** minkowski / wminkowski exponent */
161
+ p?: number;
162
+ /** seuclidean variance vector */
163
+ V?: ArrayLike<number>;
164
+ /** wminkowski weight vector */
165
+ w?: ArrayLike<number>;
166
+ /** mahalanobis inverse covariance (row-major cols×cols) */
167
+ VInv?: ArrayLike<number>;
168
+ }
169
+ declare function euclidean(x: Vec, y: Vec): number;
170
+ /** Squared euclidean — used internally by the optimizer (rdist). */
171
+ declare function sqeuclidean(x: Vec, y: Vec): number;
172
+ declare function standardisedEuclidean(x: Vec, y: Vec, sigma: ArrayLike<number>): number;
173
+ declare function manhattan(x: Vec, y: Vec): number;
174
+ declare function chebyshev(x: Vec, y: Vec): number;
175
+ declare function minkowski(x: Vec, y: Vec, p: number): number;
176
+ declare function weightedMinkowski(x: Vec, y: Vec, w: ArrayLike<number>, p: number): number;
177
+ declare function mahalanobis(x: Vec, y: Vec, vinv: ArrayLike<number>): number;
178
+ declare function hamming(x: Vec, y: Vec): number;
179
+ declare function canberra(x: Vec, y: Vec): number;
180
+ declare function brayCurtis(x: Vec, y: Vec): number;
181
+ declare function jaccard(x: Vec, y: Vec): number;
182
+ declare function matching(x: Vec, y: Vec): number;
183
+ declare function dice(x: Vec, y: Vec): number;
184
+ declare function kulsinski(x: Vec, y: Vec): number;
185
+ declare function rogersTanimoto(x: Vec, y: Vec): number;
186
+ declare function russellrao(x: Vec, y: Vec): number;
187
+ declare function sokalMichener(x: Vec, y: Vec): number;
188
+ declare function sokalSneath(x: Vec, y: Vec): number;
189
+ declare function yule(x: Vec, y: Vec): number;
190
+ declare function cosine(x: Vec, y: Vec): number;
191
+ declare function correlation(x: Vec, y: Vec): number;
192
+ declare function hellinger(x: Vec, y: Vec): number;
193
+ declare function llDirichlet(data1: Vec, data2: Vec): number;
194
+ /**
195
+ * Symmetrized KL divergence. NOTE: the Python source mutates its inputs (adds z,
196
+ * normalizes in place); we copy to preserve the same numerics without side effects.
197
+ */
198
+ declare function symmetricKl(x: Vec, y: Vec, z?: number): number;
199
+ declare function haversine(x: Vec, y: Vec): number;
200
+ declare const NAMED_METRICS: readonly string[];
201
+ /** Metrics that auto-enable angular RP-forest (umap_.py:1938-1946). */
202
+ declare const ANGULAR_METRICS: Set<string>;
203
+ declare function isNamedMetric(name: string): boolean;
204
+ declare function canonicalMetricName(name: string): string;
205
+ declare function resolveMetric(name: string, options?: MetricOptions): MetricImpl;
206
+ /**
207
+ * Size/positivity checks for metricOptions once the data dimension is known —
208
+ * a wrong-sized V/w/VInv would otherwise read undefined and silently poison
209
+ * every distance with NaN.
210
+ */
211
+ declare function validateMetricOptionSizes(name: string, options: MetricOptions, dim: number): void;
212
+ //#endregion
213
+ //#region src/knn/exact.d.ts
214
+ interface ExactKnnOptions {
215
+ metricOptions?: MetricOptions;
216
+ /** distances >= this become inf / index -1 (disconnection pruning) */
217
+ disconnectionDistance?: number;
218
+ }
219
+ /** Row-wise exact kNN for dense data. Accepts a named metric or a custom MetricFn. */
220
+ declare function exactKnnDense(X: Matrix, k: number, metricName: string | ((a: Float32Array, b: Float32Array) => number), {
221
+ metricOptions,
222
+ disconnectionDistance
223
+ }?: ExactKnnOptions): KnnGraph;
224
+ /** Exact kNN for CSR input (euclidean or cosine). */
225
+ declare function exactKnnSparse(X: CSRInput, k: number, metricName: string): KnnGraph;
226
+ /**
227
+ * metric='precomputed': X is a dense n×n distance matrix; per-row argsort prefix
228
+ * (umap_.py:312-324); infinite distances → index -1.
229
+ */
230
+ declare function knnFromPrecomputed(X: Matrix, k: number): KnnGraph;
231
+ //#endregion
232
+ //#region src/knn/rpforest.d.ts
233
+ interface FlatTree {
234
+ /** nNodes × dim hyperplane vectors (dense) */
235
+ hyperplanes: Float32Array;
236
+ offsets: Float32Array;
237
+ /** nNodes × 2; internal: child node ids (>0); leaf: (-leafStart, -leafEnd) */
238
+ children: Int32Array;
239
+ /** concatenated leaf point indices (a permutation of all points) */
240
+ indices: Int32Array;
241
+ leafSize: number;
242
+ nNodes: number;
243
+ dim: number;
244
+ }
245
+ //#endregion
246
+ //#region src/knn/search.d.ts
247
+ type PairDist = (a: Float32Array, b: Float32Array) => number;
248
+ interface SearchIndex {
249
+ /** reordered connectivity graph (uint8 semantics: indices only) */
250
+ indptr: Int32Array;
251
+ indices: Int32Array;
252
+ tree: FlatTree;
253
+ /** reordered row idx → original idx */
254
+ vertexOrder: Int32Array;
255
+ /** reordered data rows */
256
+ data: Matrix;
257
+ dist: PairDist;
258
+ correction: (d: number) => number;
259
+ angular: boolean;
260
+ minDistance: number;
261
+ searchRngState: Int32Array;
262
+ nNeighbors: number;
263
+ }
264
+ /**
265
+ * Dense query (notes §7): tree init + random top-up + best-first expansion with
266
+ * bound d_k + ε(d_k − minDistance). Returns ORIGINAL indices and CORRECTED distances.
267
+ */
268
+ declare function searchKnn(index: SearchIndex, Q: Matrix, k: number, epsilon: number): KnnGraph;
269
+ //#endregion
270
+ //#region src/knn/index.d.ts
271
+ declare const SMALL_DATA_CUTOFF = 4096;
272
+ interface NearestNeighborsResult {
273
+ knn: KnnGraph;
274
+ /** present only for the approximate (NNDescent) dense path */
275
+ searchIndex: SearchIndex | null;
276
+ /** which path ran */
277
+ method: 'exact' | 'nndescent';
278
+ }
279
+ interface NearestNeighborsOptions {
280
+ metricOptions?: MetricOptions;
281
+ forceApproximation?: boolean;
282
+ /** accepted and ignored, matching the pinned pynndescent 0.6.0 (D-007) */
283
+ lowMemory?: boolean;
284
+ /** force angular RP-tree splits; ORed with the metric family like Python */
285
+ angularRpForest?: boolean;
286
+ disconnectionDistance?: number;
287
+ }
288
+ declare function nearestNeighborsDense(X: Matrix, nNeighbors: number, metricName: string, rng: Pcg32, {
289
+ metricOptions,
290
+ forceApproximation,
291
+ angularRpForest,
292
+ disconnectionDistance
293
+ }?: NearestNeighborsOptions): NearestNeighborsResult;
294
+ declare function nearestNeighborsSparse(X: CSRInput, nNeighbors: number, metricName: string, rng: Pcg32, {
295
+ forceApproximation,
296
+ angularRpForest,
297
+ disconnectionDistance
298
+ }?: NearestNeighborsOptions): NearestNeighborsResult;
299
+ //#endregion
300
+ //#region src/knn/heap.d.ts
301
+ /**
302
+ * pynndescent heap structure (utils.py:130-218, 352-533): per-row max-heap on
303
+ * distance rooted at column 0 (root = current worst). Rows: indices int32 (-1 empty),
304
+ * distances float32 (+inf empty), flags uint8.
305
+ */
306
+ interface NeighborHeap {
307
+ indices: Int32Array;
308
+ distances: Float32Array;
309
+ flags: Uint8Array;
310
+ n: number;
311
+ size: number;
312
+ }
313
+ //#endregion
314
+ //#region src/knn/nndescent.d.ts
315
+ type DistFn = (i: number, j: number) => number;
316
+ interface NnDescentOptions {
317
+ maxCandidates?: number;
318
+ nIters?: number;
319
+ delta?: number;
320
+ /** dense leaf init: d < max(tp,tq); sparse: d < tp or d < tq (notes §9) */
321
+ leafAcceptance?: 'max' | 'either';
322
+ /** per-iteration progress hook (the library never writes to the console) */
323
+ onIteration?: (iter: number, c: number) => void;
324
+ }
325
+ /**
326
+ * Full NN-descent. `leafArray` from the RP forest (or null to skip tree init).
327
+ * Returns the heap AFTER deheap_sort: ascending distances, (-1, inf) tails.
328
+ * Distances are in the INTERNAL metric space (corrections applied by the caller).
329
+ */
330
+ declare function nnDescent(n: number, nNeighbors: number, dist: DistFn, rngState: Int32Array, leafArray: {
331
+ data: Int32Array;
332
+ rows: number;
333
+ cols: number;
334
+ } | null, {
335
+ maxCandidates,
336
+ nIters,
337
+ delta,
338
+ leafAcceptance,
339
+ onIteration
340
+ }?: NnDescentOptions): NeighborHeap;
341
+ /** umap's NNDescent parameter rules (umap_.py:327-328). */
342
+ declare function umapNnDescentParams(n: number): {
343
+ nTrees: number;
344
+ nIters: number;
345
+ };
346
+ //#endregion
347
+ //#region src/linalg.d.ts
348
+ /**
349
+ * Small dense linear algebra (float64): cyclic Jacobi eigensolver for symmetric
350
+ * matrices, modified Gram–Schmidt, and dense helpers. Used by LOBPCG's Rayleigh–Ritz
351
+ * step (block sizes ≤ ~12) and the multi-component meta layout.
352
+ */
353
+ interface EigResult {
354
+ /** ascending eigenvalues */
355
+ values: Float64Array;
356
+ /** column-major eigenvectors: vectors[c * n + r] = component r of eigenvector c */
357
+ vectors: Float64Array;
358
+ }
359
+ /** Cyclic Jacobi for a symmetric n×n matrix (row-major input, not modified). */
360
+ declare function symmetricEigen(A: Float64Array, n: number, maxSweeps?: number): EigResult;
361
+ /**
362
+ * Modified Gram–Schmidt over columns stored contiguously (col-major: X[c*n..c*n+n)).
363
+ * Columns with norm below dropTol (relative to their original norm) are dropped.
364
+ * Returns the number of retained columns (retained columns are compacted in place).
365
+ */
366
+ declare function mgsOrthonormalize(X: Float64Array, n: number, cols: number, dropTol?: number): number;
367
+ //#endregion
368
+ //#region src/util.d.ts
369
+ /** Convert any DenseInput to a canonical float32 Matrix, validating finiteness (§4.1). */
370
+ declare function toMatrix(input: DenseInput, what?: string): Matrix;
371
+ //#endregion
372
+ export { noisyScaleCoords as A, degreeInvSqrt as C, InitMethod as D, pcaScores as E, fuzzySimplicialSet as F, defaultNEpochs as I, makeEpochsPerSample as L, SMOOTH_K_TOLERANCE as M, smoothKnnDist as N, finalInitRescale as O, computeMembershipStrengths as P, pruneGraphForEpochs as R, connectedComponents as S, spectralLayout as T, NAMED_METRICS as _, umapNnDescentParams as a, metrics_d_exports as b, nearestNeighborsDense as c, searchKnn as d, exactKnnDense as f, MetricOptions as g, ANGULAR_METRICS as h, nnDescent as i, MIN_K_DIST_SCALE as j, initializeEmbedding as k, nearestNeighborsSparse as l, knnFromPrecomputed as m, mgsOrthonormalize as n, NearestNeighborsResult as o, exactKnnSparse as p, symmetricEigen as r, SMALL_DATA_CUTOFF as s, toMatrix as t, SearchIndex as u, canonicalMetricName as v, lobpcgSmallest as w, resolveMetric as x, isNamedMetric as y, findABParams as z };
373
+ //# sourceMappingURL=core-IHdw-3yY.d.ts.map
package/dist/core.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { a as csrForEach, c as csrMaxAbsDiff, d as csrTranspose, f as Pcg32, h as tauRandInt, i as csrEliminateZeros, l as csrNnz, m as tauRand, n as csrBinaryOp, o as csrFromCoo, p as floorMod, r as csrCopy, s as csrMapValues, t as Csr, u as csrRowNormalizeMax } from "./sparse-BxSeVhO4.js";
2
+ import { A as noisyScaleCoords, C as degreeInvSqrt, D as InitMethod, E as pcaScores, F as fuzzySimplicialSet, I as defaultNEpochs, L as makeEpochsPerSample, M as SMOOTH_K_TOLERANCE, N as smoothKnnDist, O as finalInitRescale, P as computeMembershipStrengths, R as pruneGraphForEpochs, S as connectedComponents, T as spectralLayout, _ as NAMED_METRICS, a as umapNnDescentParams, b as metrics_d_exports, c as nearestNeighborsDense, d as searchKnn, f as exactKnnDense, h as ANGULAR_METRICS, i as nnDescent, j as MIN_K_DIST_SCALE, k as initializeEmbedding, l as nearestNeighborsSparse, m as knnFromPrecomputed, n as mgsOrthonormalize, o as NearestNeighborsResult, p as exactKnnSparse, r as symmetricEigen, s as SMALL_DATA_CUTOFF, t as toMatrix, u as SearchIndex, v as canonicalMetricName, w as lobpcgSmallest, x as resolveMetric, y as isNamedMetric, z as findABParams } from "./core-IHdw-3yY.js";
3
+ export { ANGULAR_METRICS, Csr, InitMethod, MIN_K_DIST_SCALE, NAMED_METRICS, NearestNeighborsResult, Pcg32, SMALL_DATA_CUTOFF, SMOOTH_K_TOLERANCE, SearchIndex, canonicalMetricName, computeMembershipStrengths, connectedComponents, csrBinaryOp, csrCopy, csrEliminateZeros, csrForEach, csrFromCoo, csrMapValues, csrMaxAbsDiff, csrNnz, csrRowNormalizeMax, csrTranspose, defaultNEpochs, degreeInvSqrt, exactKnnDense, exactKnnSparse, finalInitRescale, findABParams, floorMod, fuzzySimplicialSet, initializeEmbedding, isNamedMetric, knnFromPrecomputed, lobpcgSmallest, makeEpochsPerSample, metrics_d_exports as metrics, mgsOrthonormalize, nearestNeighborsDense, nearestNeighborsSparse, nnDescent, noisyScaleCoords, pcaScores, pruneGraphForEpochs, resolveMetric, searchKnn, smoothKnnDist, spectralLayout, symmetricEigen, tauRand, tauRandInt, toMatrix, umapNnDescentParams };
package/dist/core.js ADDED
@@ -0,0 +1,4 @@
1
+ import { B as csrCopy, D as isNamedMetric, E as canonicalMetricName, F as smoothKnnDist, G as csrMaxAbsDiff, H as csrForEach, I as defaultNEpochs, J as csrTranspose, K as csrNnz, L as makeEpochsPerSample, M as fuzzySimplicialSet, N as MIN_K_DIST_SCALE, O as metrics_exports, P as SMOOTH_K_TOLERANCE, R as pruneGraphForEpochs, S as knnFromPrecomputed, T as NAMED_METRICS, U as csrFromCoo, V as csrEliminateZeros, W as csrMapValues, Y as findABParams, _ as floorMod, a as SMALL_DATA_CUTOFF, b as exactKnnDense, d as umapNnDescentParams, g as Pcg32, j as computeMembershipStrengths, k as resolveMetric, l as searchKnn, o as nearestNeighborsDense, q as csrRowNormalizeMax, r as toMatrix, s as nearestNeighborsSparse, u as nnDescent, v as tauRand, w as ANGULAR_METRICS, x as exactKnnSparse, y as tauRandInt, z as csrBinaryOp } from "./core-BPpH5_PW.js";
2
+ import { a as degreeInvSqrt, c as spectralLayout, d as symmetricEigen, i as connectedComponents, l as pcaScores, n as initializeEmbedding, o as lobpcgSmallest, r as noisyScaleCoords, t as finalInitRescale, u as mgsOrthonormalize } from "./init-DLiEtGpx.js";
3
+
4
+ export { ANGULAR_METRICS, MIN_K_DIST_SCALE, NAMED_METRICS, Pcg32, SMALL_DATA_CUTOFF, SMOOTH_K_TOLERANCE, canonicalMetricName, computeMembershipStrengths, connectedComponents, csrBinaryOp, csrCopy, csrEliminateZeros, csrForEach, csrFromCoo, csrMapValues, csrMaxAbsDiff, csrNnz, csrRowNormalizeMax, csrTranspose, defaultNEpochs, degreeInvSqrt, exactKnnDense, exactKnnSparse, finalInitRescale, findABParams, floorMod, fuzzySimplicialSet, initializeEmbedding, isNamedMetric, knnFromPrecomputed, lobpcgSmallest, makeEpochsPerSample, metrics_exports as metrics, mgsOrthonormalize, nearestNeighborsDense, nearestNeighborsSparse, nnDescent, noisyScaleCoords, pcaScores, pruneGraphForEpochs, resolveMetric, searchKnn, smoothKnnDist, spectralLayout, symmetricEigen, tauRand, tauRandInt, toMatrix, umapNnDescentParams };
@@ -0,0 +1,261 @@
1
+ import { C as MetricFn, D as UmapError, E as UmapConvergenceWarning, O as UmapValidationError, S as Matrix, T as UmapBackendError, _ as DenseInput, a as csrForEach, b as Labels, c as csrMaxAbsDiff, d as csrTranspose, f as Pcg32, g as CSRInput, h as tauRandInt, i as csrEliminateZeros, l as csrNnz, m as tauRand, n as csrBinaryOp, o as csrFromCoo, p as floorMod, r as csrCopy, s as csrMapValues, t as Csr, u as csrRowNormalizeMax, v as Embedding, w as Target, x as Logger, y as KnnGraph } from "./sparse-BxSeVhO4.js";
2
+ import { A as noisyScaleCoords, C as degreeInvSqrt, D as InitMethod, E as pcaScores, F as fuzzySimplicialSet, I as defaultNEpochs, L as makeEpochsPerSample, M as SMOOTH_K_TOLERANCE, N as smoothKnnDist, O as finalInitRescale, P as computeMembershipStrengths, R as pruneGraphForEpochs, S as connectedComponents, T as spectralLayout, _ as NAMED_METRICS, a as umapNnDescentParams, b as metrics_d_exports, c as nearestNeighborsDense, d as searchKnn, f as exactKnnDense, g as MetricOptions, h as ANGULAR_METRICS, i as nnDescent, j as MIN_K_DIST_SCALE, k as initializeEmbedding, l as nearestNeighborsSparse, m as knnFromPrecomputed, n as mgsOrthonormalize, o as NearestNeighborsResult, p as exactKnnSparse, r as symmetricEigen, s as SMALL_DATA_CUTOFF, t as toMatrix, u as SearchIndex, v as canonicalMetricName, w as lobpcgSmallest, x as resolveMetric, y as isNamedMetric, z as findABParams } from "./core-IHdw-3yY.js";
3
+
4
+ //#region src/estimator/options.d.ts
5
+
6
+ interface UmapOptions {
7
+ nNeighbors?: number;
8
+ nComponents?: number;
9
+ metric?: string | MetricFn;
10
+ metricOptions?: MetricOptions;
11
+ outputMetric?: string;
12
+ outputMetricOptions?: Record<string, number>;
13
+ nEpochs?: number;
14
+ learningRate?: number;
15
+ init?: InitMethod;
16
+ minDist?: number;
17
+ spread?: number;
18
+ lowMemory?: boolean;
19
+ concurrency?: number | 'auto';
20
+ setOpMixRatio?: number;
21
+ localConnectivity?: number;
22
+ repulsionStrength?: number;
23
+ negativeSampleRate?: number;
24
+ transformQueueSize?: number;
25
+ a?: number;
26
+ b?: number;
27
+ seed?: number;
28
+ angularRpForest?: boolean;
29
+ targetNNeighbors?: number;
30
+ targetMetric?: string;
31
+ targetMetricOptions?: MetricOptions;
32
+ targetWeight?: number;
33
+ transformSeed?: number;
34
+ transformMode?: 'embedding' | 'graph';
35
+ forceApproximation?: boolean;
36
+ verbose?: boolean | Logger;
37
+ unique?: boolean;
38
+ densMap?: boolean;
39
+ densLambda?: number;
40
+ densFrac?: number;
41
+ densVarShift?: number;
42
+ outputDens?: boolean;
43
+ disconnectionDistance?: number;
44
+ precomputedKnn?: {
45
+ indices: Int32Array;
46
+ distances: Float32Array;
47
+ k: number;
48
+ };
49
+ backend?: 'auto' | 'cpu' | 'webgpu';
50
+ device?: unknown;
51
+ /**
52
+ * Explicit worker entry for the parallel CPU backend, for bundlers that do
53
+ * not detect the library's inline `new Worker(new URL(...))` pattern.
54
+ * Browser: an absolute URL/string (e.g. Vite's `'umap-web/worker?worker&url'`
55
+ * import). Node: a file:// URL or absolute path. When spawning from this URL
56
+ * fails, fit() warns and continues single-threaded. See README
57
+ * "Workers & bundlers".
58
+ */
59
+ workerUrl?: URL | string;
60
+ deterministic?: boolean;
61
+ /** GPU SGD accumulation strategy (§A2, D-011); default from measurements */
62
+ gpuLayoutStrategy?: 'vertexGather' | 'edgeAtomic';
63
+ onEpoch?: (e: {
64
+ epoch: number;
65
+ nEpochs: number;
66
+ phase: string;
67
+ embedding?: Float32Array;
68
+ }) => void;
69
+ }
70
+ /** DISCONNECTION_DISTANCES (umap_.py:61-68). */
71
+ declare const DISCONNECTION_DISTANCES: Record<string, number>;
72
+ interface FitCallOptions {
73
+ signal?: AbortSignal;
74
+ }
75
+ //#endregion
76
+ //#region src/estimator/aligned.d.ts
77
+ interface AlignedUmapOptions extends UmapOptions {
78
+ alignmentRegularisation?: number;
79
+ alignmentWindowSize?: number;
80
+ }
81
+ /** Row-index mapping from slice i to slice i+1. */
82
+ type Relation = Record<number, number> | Map<number, number>;
83
+ declare class AlignedUMAP {
84
+ readonly options: AlignedUmapOptions;
85
+ private _embeddings;
86
+ private _mappers;
87
+ private _relations;
88
+ constructor(options?: AlignedUmapOptions);
89
+ get embeddings(): Embedding[];
90
+ fit(XList: DenseInput[], yList?: (Labels | null)[] | null, relations?: Relation[], {
91
+ signal
92
+ }?: FitCallOptions): Promise<this>;
93
+ fitTransform(XList: DenseInput[], yList?: (Labels | null)[] | null, relations?: Relation[], opts?: FitCallOptions): Promise<Embedding[]>;
94
+ /** Append a new slice (aligned_umap.py:446-562): old slices frozen except pulls. */
95
+ update(Xnew: DenseInput, relation: Relation, {
96
+ signal
97
+ }?: FitCallOptions): Promise<this>;
98
+ }
99
+ //#endregion
100
+ //#region src/backends/cpu/pool.d.ts
101
+ type AnyRec = Record<string, any>;
102
+ /**
103
+ * Cross-origin retry (CDN / import-map consumers): fetch the sibling worker
104
+ * source and spawn it from a blob: URL. Valid only because dist/worker.js is
105
+ * built fully self-contained (no sibling-chunk imports; enforced by
106
+ * scripts/check-worker-selfcontained.mjs). Requires `worker-src blob:` under
107
+ * a strict CSP (documented in README).
108
+ */
109
+
110
+ declare class WorkerPool {
111
+ private workers;
112
+ private pending;
113
+ private nextId;
114
+ private failure;
115
+ private terminating;
116
+ private cleanup;
117
+ readonly size: number;
118
+ private constructor();
119
+ /**
120
+ * Spawn `size` workers from `source` (undefined → platform default resolution).
121
+ * `cleanup` runs once at terminate() (e.g. revoking a blob: URL). Partial
122
+ * spawn failures terminate the already-spawned workers before rethrowing.
123
+ */
124
+ static create(size: number, source?: URL | string, cleanup?: () => void): Promise<WorkerPool>;
125
+ /** A worker died: poison the pool and reject everything in flight. */
126
+ private markFailed;
127
+ private dispatch;
128
+ call<T>(worker: number, method: string, args: AnyRec, transfers?: Transferable[]): Promise<T>;
129
+ /** Run `method` on every worker with per-worker args; await all. */
130
+ mapAll<T>(method: string, argsFor: (w: number) => AnyRec, transfersFor?: (w: number) => Transferable[]): Promise<T[]>;
131
+ terminate(): Promise<void>;
132
+ }
133
+ //#endregion
134
+ //#region src/backends/cpu/workers.d.ts
135
+ interface ParallelContext {
136
+ pool: WorkerPool;
137
+ sab: boolean;
138
+ data: Float32Array;
139
+ rows: number;
140
+ cols: number;
141
+ dist: (a: Float32Array, b: Float32Array) => number;
142
+ }
143
+ //#endregion
144
+ //#region src/estimator/umap.d.ts
145
+ interface ResolvedBackendInfo {
146
+ knn: string;
147
+ layout: string;
148
+ }
149
+ declare class UMAP {
150
+ readonly options: UmapOptions;
151
+ protected logger: Logger;
152
+ _embedding: Embedding | null;
153
+ _embeddingUnique: Float32Array | null;
154
+ _graph: Csr | null;
155
+ _sigmas: Float32Array | null;
156
+ _rhos: Float32Array | null;
157
+ _knn: KnnGraph | null;
158
+ _searchIndex: SearchIndex | null;
159
+ _rawData: Matrix | null;
160
+ _rawCsr: CSRInput | null;
161
+ _uniqueIndex: Int32Array | null;
162
+ _uniqueInverse: Int32Array | null;
163
+ _a: number;
164
+ _b: number;
165
+ _nNeighborsUsed: number;
166
+ _smallData: boolean;
167
+ _disconnection: number;
168
+ _supervised: boolean;
169
+ _inputHash: string | null;
170
+ _radOrig: Float32Array | null;
171
+ _radEmb: Float32Array | null;
172
+ protected _backendInfo: ResolvedBackendInfo;
173
+ protected _timings: Record<string, number>;
174
+ protected _parallel: ParallelContext | null;
175
+ protected _gpu: any;
176
+ protected _gpuCtx: any;
177
+ protected _useGpuLayout: boolean;
178
+ /** name of the in-flight operation; guards against concurrent use */
179
+ private _busy;
180
+ constructor(options?: UmapOptions);
181
+ private validateOptions;
182
+ get embedding(): Embedding;
183
+ /** CSR fuzzy graph over the training data (unique rows when unique=true). */
184
+ get graph(): Csr;
185
+ get densities(): {
186
+ original: Float32Array;
187
+ embedded: Float32Array;
188
+ };
189
+ /** Which backend actually executed each stage (§5.2). */
190
+ get backendInfo(): ResolvedBackendInfo;
191
+ get phaseTimings(): Record<string, number>;
192
+ protected resolveMetricName(): string;
193
+ /** Serialize operations on one instance: concurrent calls are a caller bug. */
194
+ private withBusy;
195
+ private snapshotFittedState;
196
+ private restoreFittedState;
197
+ /** Discard fitted state so a running fit never exposes a mixed old/new model. */
198
+ private resetFittedState;
199
+ /** Stop using the GPU for the rest of this fit (typed failure → CPU, D-017). */
200
+ private dropGpu;
201
+ /** Always runs after fit (success, error, or abort): no leaked workers/devices. */
202
+ private releaseBackends;
203
+ fit(X: DenseInput | CSRInput, y?: Labels | Target | null, {
204
+ signal
205
+ }?: FitCallOptions): Promise<this>;
206
+ private fitInner;
207
+ protected embedGraph(graph: Csr, graphDists: Csr | null, dense: Matrix | null, nComponents: number, outputMetric: string, rng: Pcg32, {
208
+ densMap,
209
+ outputDens,
210
+ signal,
211
+ initOverride,
212
+ nEpochsOverride
213
+ }: {
214
+ densMap: boolean;
215
+ outputDens: boolean;
216
+ signal?: AbortSignal;
217
+ initOverride?: Float32Array;
218
+ nEpochsOverride?: number;
219
+ }): Promise<void>;
220
+ fitTransform(X: DenseInput | CSRInput, y?: Labels | Target | null, opts?: FitCallOptions): Promise<Embedding>;
221
+ transform(Xnew: DenseInput, {
222
+ signal
223
+ }?: FitCallOptions): Promise<Embedding>;
224
+ /** transformMode 'graph': the bipartite membership CSR (nNew × nTrain). */
225
+ transformGraph(Xnew: DenseInput, {
226
+ signal
227
+ }?: FitCallOptions): Promise<Csr>;
228
+ private transformInner;
229
+ /**
230
+ * Build the prepared search structure from the stored kNN graph (D-018):
231
+ * used when the fit produced no index (GPU kNN path, deserialized blobs
232
+ * without one). Internal-space distances are recomputed exactly via the
233
+ * internal metric — n·k evaluations, no correction inversion. The rng for
234
+ * hub-tree tie-breaks/query descent derives from transformSeed on its own
235
+ * PCG stream, so fit-time determinism (D-013) is untouched and transforms
236
+ * stay reproducible for a given transformSeed.
237
+ */
238
+ private buildSearchIndexFromKnn;
239
+ private uniqueTrainMatrix;
240
+ inverseTransform(points: DenseInput, {
241
+ signal
242
+ }?: FitCallOptions): Promise<Embedding>;
243
+ private inverseTransformInner;
244
+ update(Xmore: DenseInput, {
245
+ signal
246
+ }?: FitCallOptions): Promise<this>;
247
+ private updateInner;
248
+ serialize(): Uint8Array;
249
+ static deserialize(blob: Uint8Array): UMAP;
250
+ }
251
+ //#endregion
252
+ //#region src/index.d.ts
253
+ /**
254
+ * umap-web — standalone TypeScript UMAP for browsers and Node.js.
255
+ *
256
+ * Public entry point. See `umap-web/core` for the low-level functional API.
257
+ */
258
+ declare const VERSION = "0.1.0";
259
+ //#endregion
260
+ export { ANGULAR_METRICS, AlignedUMAP, type AlignedUmapOptions, type CSRInput, Csr, DISCONNECTION_DISTANCES, type DenseInput, type Embedding, type FitCallOptions, InitMethod, type KnnGraph, type Labels, type Logger, MIN_K_DIST_SCALE, type MetricFn, NAMED_METRICS, NearestNeighborsResult, Pcg32, type Relation, SMALL_DATA_CUTOFF, SMOOTH_K_TOLERANCE, SearchIndex, type Target, UMAP, UmapBackendError, UmapConvergenceWarning, UmapError, type UmapOptions, UmapValidationError, VERSION, canonicalMetricName, computeMembershipStrengths, connectedComponents, csrBinaryOp, csrCopy, csrEliminateZeros, csrForEach, csrFromCoo, csrMapValues, csrMaxAbsDiff, csrNnz, csrRowNormalizeMax, csrTranspose, defaultNEpochs, degreeInvSqrt, exactKnnDense, exactKnnSparse, finalInitRescale, findABParams, floorMod, fuzzySimplicialSet, initializeEmbedding, isNamedMetric, knnFromPrecomputed, lobpcgSmallest, makeEpochsPerSample, metrics_d_exports as metrics, mgsOrthonormalize, nearestNeighborsDense, nearestNeighborsSparse, nnDescent, noisyScaleCoords, pcaScores, pruneGraphForEpochs, resolveMetric, searchKnn, smoothKnnDist, spectralLayout, symmetricEigen, tauRand, tauRandInt, toMatrix, umapNnDescentParams };
261
+ //# sourceMappingURL=index.d.ts.map