wasm-bhtsne 0.2.0 → 0.3.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/README.md CHANGED
@@ -19,18 +19,23 @@ npm i wasm-bhtsne
19
19
  ### Example
20
20
 
21
21
  ```javascript
22
- import {tSNE} from "wasm-bhtsne";
22
+ import { tSNE } from "wasm-bhtsne";
23
23
 
24
- const data = [];
25
-
26
- for (let i = 0; i < 300; i++) {
27
- const randomNumber = Math.random();
28
- data.push(randomNumber);
24
+ function createRandomMatrix(rows, columns) {
25
+ return Array.from({ length: rows }, () =>
26
+ Array.from({ length: columns }, () => Math.random())
27
+ );
29
28
  }
30
29
 
31
- const tsne_encoder = new tSNE(data, 4);
32
- tsne_encoder.exact();
33
- const embedded_stuff = tsne_encoder.embedding();
30
+ // create random points and dimensions
31
+ const data = createRandomMatrix(5000, 512);
32
+
33
+ const tsne_encoder = new tSNE(data);
34
+
35
+ let compressed_vectors = []
36
+
37
+ // as argument the number of epochs,
38
+ compressed_vectors = tsne_encoder.barnes_hut(1000);
34
39
 
35
- console.log(embedded_stuff);
40
+ console.log("Compressed Vectors:", compressed_vectors);
36
41
  ```
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "lv291 <baiunco291@proton.me>"
5
5
  ],
6
6
  "description": "Exact and Barnes-Hut implementations of t-SNE in wasm",
7
- "version": "0.2.0",
7
+ "version": "0.3.1",
8
8
  "license": "MIT",
9
9
  "repository": {
10
10
  "type": "git",
package/wasm_bhtsne.d.ts CHANGED
@@ -11,20 +11,6 @@ export class tSNE {
11
11
  */
12
12
  constructor(vectors: Array<any>);
13
13
  /**
14
- * Performs a parallel exact version of the t-SNE algorithm. Pairwise distances between samples
15
- * in the input space will be computed accordingly to the supplied function `distance_f`.
16
- *
17
- * # Arguments
18
- *
19
- * `distance_f` - distance function.
20
- *
21
- * **Do note** that such a distance function needs not to be a metric distance, i.e. it is not
22
- * necessary for it so satisfy the triangle inequality. Consequently, the squared euclidean
23
- * distance, and many other, can be used.
24
- * @returns {Array<any>}
25
- */
26
- exact(): Array<any>;
27
- /**
28
14
  * Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
29
15
  *
30
16
  * # Arguments
@@ -40,10 +26,10 @@ export class tSNE {
40
26
  *
41
27
  * **Do note that** `metric_f` **must be a metric distance**, i.e. it must
42
28
  * satisfy the [triangle inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
43
- * @param {number} theta
29
+ * @param {number} epochs
44
30
  * @returns {Array<any>}
45
31
  */
46
- barnes_hut(theta: number): Array<any>;
32
+ barnes_hut(epochs: number): Array<any>;
47
33
  /**
48
34
  * Returns the computed embedding.
49
35
  * @returns {Array<any>}
@@ -58,14 +44,6 @@ export class tSNE {
58
44
  */
59
45
  embedding_dim: number;
60
46
  /**
61
- * Sets new epochs, i.e the maximum number of fitting iterations.
62
- *
63
- * # Arguments
64
- *
65
- * `epochs` - new value for the epochs.
66
- */
67
- epochs: number;
68
- /**
69
47
  * Sets a new final momentum.
70
48
  *
71
49
  * # Arguments
@@ -120,4 +98,7 @@ export class tSNE {
120
98
  * `stop_lying_epoch` - new value for the stop lying epoch.
121
99
  */
122
100
  stop_lying_epoch: number;
101
+ /**
102
+ */
103
+ theta: number;
123
104
  }
package/wasm_bhtsne_bg.js CHANGED
@@ -237,23 +237,6 @@ export class tSNE {
237
237
  return tSNE.__wrap(ret);
238
238
  }
239
239
  /**
240
- * Performs a parallel exact version of the t-SNE algorithm. Pairwise distances between samples
241
- * in the input space will be computed accordingly to the supplied function `distance_f`.
242
- *
243
- * # Arguments
244
- *
245
- * `distance_f` - distance function.
246
- *
247
- * **Do note** that such a distance function needs not to be a metric distance, i.e. it is not
248
- * necessary for it so satisfy the triangle inequality. Consequently, the squared euclidean
249
- * distance, and many other, can be used.
250
- * @returns {Array<any>}
251
- */
252
- exact() {
253
- const ret = wasm.tsne_exact(this.__wbg_ptr);
254
- return takeObject(ret);
255
- }
256
- /**
257
240
  * Performs a parallel Barnes-Hut approximation of the t-SNE algorithm.
258
241
  *
259
242
  * # Arguments
@@ -269,11 +252,11 @@ export class tSNE {
269
252
  *
270
253
  * **Do note that** `metric_f` **must be a metric distance**, i.e. it must
271
254
  * satisfy the [triangle inequality](https://en.wikipedia.org/wiki/Triangle_inequality).
272
- * @param {number} theta
255
+ * @param {number} epochs
273
256
  * @returns {Array<any>}
274
257
  */
275
- barnes_hut(theta) {
276
- const ret = wasm.tsne_barnes_hut(this.__wbg_ptr, theta);
258
+ barnes_hut(epochs) {
259
+ const ret = wasm.tsne_barnes_hut(this.__wbg_ptr, epochs);
277
260
  return takeObject(ret);
278
261
  }
279
262
  /**
@@ -288,15 +271,10 @@ export class tSNE {
288
271
  wasm.tsne_set_learning_rate(this.__wbg_ptr, learning_rate);
289
272
  }
290
273
  /**
291
- * Sets new epochs, i.e the maximum number of fitting iterations.
292
- *
293
- * # Arguments
294
- *
295
- * `epochs` - new value for the epochs.
296
- * @param {number} epochs
274
+ * @param {number} theta
297
275
  */
298
- set epochs(epochs) {
299
- wasm.tsne_set_epochs(this.__wbg_ptr, epochs);
276
+ set theta(theta) {
277
+ wasm.tsne_set_theta(this.__wbg_ptr, theta);
300
278
  }
301
279
  /**
302
280
  * Sets a new momentum.
Binary file