{"_id":"@arilotter/tsne-js","_rev":"3-8fa190d9f3bce0474c3a961ee68e4f7c","name":"@arilotter/tsne-js","description":"t-SNE implementation in JavaScript","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.3":{"name":"@arilotter/tsne-js","version":"1.0.3","description":"t-SNE implementation in JavaScript","main":"dist/index.js","scripts":{"build-browser":"rm -rf build && mkdir build && browserify src/index.js -t [ babelify --presets [ es2015 ] --plugins [ add-module-exports ] ] -p [minifyify --no-map] --standalone TSNE -o build/tsne.min.js","build-node":"rm -rf dist && babel src --out-dir dist","build":"npm run build-node && npm run build-browser","prepublish":"npm run build","test":"mocha --reporter spec --compilers js:babel-core/register"},"repository":{"type":"git","url":"git+https://github.com/aerobit/tsne-js.git"},"keywords":["Barnes-Hut","t-SNE","tSNE","tsne","t-distributed","stochastic","neighbor","embedding"],"author":{"name":"Leon Chen","email":"lchen3@gmail.com","url":"@transcranial"},"license":"Apache-2.0","bugs":{"url":"https://github.com/scienceai/tsne-js/issues"},"homepage":"https://github.com/scienceai/tsne-js#readme","devDependencies":{"babel-cli":"^6.5.1","babel-core":"^6.5.2","babel-eslint":"^5.0.0","babel-plugin-add-module-exports":"^0.1.2","babel-preset-es2015":"^6.5.0","babelify":"^7.2.0","browserify":"^13.0.0","eslint":"^2.2.0","minifyify":"^7.3.1","mocha":"^2.4.5"},"dependencies":{"cwise":"^1.0.9","ndarray":"^1.0.18","ndarray-ops":"^1.2.2","ndarray-pack":"^1.2.0","ndarray-unpack":"^1.0.0"},"gitHead":"e589cff1a3cb14d06e8639770f28d9d458a7a3dd","_id":"@arilotter/tsne-js@1.0.3","_shasum":"4a019fd49638b30dc03fd7629177813fe11043f2","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.2.2","_npmUser":{"name":"arilotter","email":"arilotter@gmail.com"},"dist":{"shasum":"4a019fd49638b30dc03fd7629177813fe11043f2","tarball":"https://registry.npmjs.org/@arilotter/tsne-js/-/tsne-js-1.0.3.tgz","integrity":"sha512-wtlh5VqCmGqZ26DkXtwuqI/1IhKpVBMkABFx8fbmWYQMaVN1ChqDskgn/134JvVOx+S0r0F09IdMMbr9U7pALw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAoLOW88ziQbxdYRRPHNMFEBryb9I5Ce8aCU/LrAYC6VAiEA7Bb3AxeJFuglGujJGISbE0UXXgVd4Jx4XI5nBEfotSg="}]},"maintainers":[{"name":"arilotter","email":"arilotter@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/tsne-js-1.0.3.tgz_1468445059319_0.7828071038238704"}}},"readme":"# t-SNE.js\n\n[![build status](https://img.shields.io/travis/scienceai/tsne-js/master.svg?style=flat-square)](https://travis-ci.org/scienceai/tsne-js)\n[![npm version](https://img.shields.io/npm/v/tsne-js.svg?style=flat-square)](https://www.npmjs.com/package/tsne-js)\n\nt-distributed stochastic neighbor embedding (t-SNE) algorithm implemented in JavaScript\n\n+ Runs in the browser (also runs in Web Workers)\n\n+ Runs in node.js\n\n+ Uses efficient in-place matrix operations via [ndarray](https://github.com/scijs/ndarray)\n\n+ Follows closely the API of [scikit-learn](http://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html), allowing specification of perplexity and early exaggeration factor, among other parameters.\n\n**[INTERACTIVE DEMO](https://scienceai.github.io/tsne-js)**\n\n### Background\n\nt-SNE is a powerful manifold technique for embedding data into low-dimensional space (typically 2-d or 3-d for visualization purposes) while preserving small pairwise distances or local data structures in the original high-dimensional space. In practice, this results in a much more intuitive layout within the low-dimensional space as compared to other techniques. The low-dimensional embedding is learned by minimizing the Kullback-Leibler divergence between the pairwise-similarity probability distribution over the original data space and distribution over the embedding space.\n\nAn important note is that the objective function is non-convex with numerous local minima, and thus the results are non-deterministic. There are a few model parameters which influence the learning and optimization process. Selecting appropriate parameters for the input data can significantly improve the chances the model converge on good solutions.\n\nCurrently implemented is the exact fomulation, which has computational complexity O(_dN^2_), where _d_ is the original dimensionality of the data and _N_ is the number of samples. Implementation of the O(_dN*logN_) Barnes-Hut approximation variant is planned (contributions welcome!).\n\n<p align=\"center\">\n  <img src=\"http://lvdmaaten.github.io/tsne/examples/caltech101_tsne.jpg\" width=\"400\" />\n</p>\n[source](http://lvdmaaten.github.io/tsne/)\n\n### Usage\n\nCan be run in node.js or the browser. In the browser, should ideally be run in a web worker.\n\n###### node.js\n\n```sh\n$ npm install tsne-js --save\n```\n\n```js\nimport TSNE from 'tsne-js';\n\nlet model = new TSNE({\n  dim: 2,\n  perplexity: 30.0,\n  earlyExaggeration: 4.0,\n  learningRate: 100.0,\n  nIter: 1000,\n  metric: 'euclidean'\n});\n\n// inputData is a nested array which can be converted into an ndarray\n// alternatively, it can be an array of coordinates (second argument should be specified as 'sparse')\nmodel.init({\n  data: inputData,\n  type: 'dense'\n});\n\n// `error`,  `iter`: final error and iteration number\n// note: computation-heavy action happens here\nlet [error, iter] = model.run();\n\n// rerun without re-calculating pairwise distances, etc.\nlet [error, iter] = model.rerun();\n\n// `output` is unpacked ndarray (regular nested javascript array)\nlet output = model.getOutput();\n\n// `outputScaled` is `output` scaled to a range of [-1, 1]\nlet outputScaled = model.getOutputScaled();\n```\n\n###### browser\n\n```html\n<script src=\"tsne.min.js\"></script>\n```\n\nThen it's the same API as above. A browser [example](https://scienceai.github.io/tsne-js) using Web Workers is in the `example/` folder.\n\n###### Model Parameters\n\n+ `dim`: number of embedding dimensions, typically 2 or 3\n\n+ `perplexity`: approximately related to number of nearest neighbors used during learning, typically between 5 and 50\n\n+ `earlyExaggeration`: parameter which influences spacing between clusters, must be at least 1.0\n\n+ `learningRate`: learning rate for gradient descent, typically between 100 and 1000\n\n+ `nIter`: maximum number of iterations, should be at least 200\n\n+ `metric`: distance measure to use for input data, currently implemented measures include\n  + `'euclidean'`\n  + `'manhattan'`\n  + `'jaccard'` (boolean data)\n  + `'dice'` (boolean data)\n\n  You can also pass a distance function to `metric`\n  ```js\n  import cwise from 'cwise';\n\n  // Operates on an n-dimensional array using the cwise module\n  let euclidean = cwise({\n    args: ['array', 'array'],\n    pre: function(a, b) {\n      this.sum = 0.0;\n    },\n    body: function(a, b) {\n      var d = a - b;\n      this.sum += d * d;\n    },\n    post: function(a, b) {\n      return Math.sqrt(this.sum);\n    }\n  });\n\n  let model = new TSNE({\n    metric: euclidean\n  });\n  ```\n\n### Build\n\nTo run build yourself, for both the browser (outputs to `build/tsne.min.js`) and node.js (outputs to `dist/`):\n\n```sh\n$ npm run build\n```\n\nTo build for just the browser, run `npm run build-browser`, and to build for just node.js, run `npm run build-node`.\n\n### Tests\n\n```sh\n$ npm test\n```\n\n### References\n\nThe original paper on t-SNE:\n\n```\nL.J.P. van der Maaten and G.E. Hinton.\nVisualizing High-Dimensional Data Using t-SNE.\nJournal of Machine Learning Research 9(Nov):2579-2605, 2008.\n```\n\nPaper on Barnes-Hut variant t-SNE:\n\n```\nL.J.P. van der Maaten.\nAccelerating t-SNE using Tree-Based Algorithms.\nJournal of Machine Learning Research 15(Oct):3221-3245, 2014.\n```\n\n### License\n\n[Apache 2.0](https://github.com/scienceai/tsne-js/blob/master/LICENSE)\n","maintainers":[{"name":"arilotter","email":"arilotter@gmail.com"}],"time":{"modified":"2022-06-12T14:47:44.704Z","created":"2016-07-13T21:24:21.303Z","1.0.3":"2016-07-13T21:24:21.303Z"},"homepage":"https://github.com/scienceai/tsne-js#readme","keywords":["Barnes-Hut","t-SNE","tSNE","tsne","t-distributed","stochastic","neighbor","embedding"],"repository":{"type":"git","url":"git+https://github.com/aerobit/tsne-js.git"},"author":{"name":"Leon Chen","email":"lchen3@gmail.com","url":"@transcranial"},"bugs":{"url":"https://github.com/scienceai/tsne-js/issues"},"license":"Apache-2.0","readmeFilename":"README.md"}