msvana-tsne
v0.1.2
Published
tSNE is a dimension reduction and vector projection method. It's main use is in visualizing high-dimensional vectors, such as text embeddings, in 2D or 3D plots.
Maintainers
Readme
tSNE
This packages provides the JavaScript/TypeScript version of the t-SNE algorithm for projecting high-dimensional data into a lower number of dimensions. T-SNE is often used to visualize embeddings. At its core tSNE attempt to preserve distances between close points.
Check out the original paper to learn more.
One of the main benefits of this implementation is that it doesn't require any external dependencies.
Usage example
import {TSNE} from "TSNE";
const embeddings: number[][] = {
{0.123, 0.456, ...},
{0.123, 0.456, ...},
...
}
const tsne = new TSNE({ nIter: 200, perplexity: 30, learningRate: 10 });
const projectedEmbeddings: number[][] = tsne.transform(embeddings);You can find a simple MNIST visualization demo at https://github.com/msvana/tsne-demo
Configuration
The TSNE constructor accepts a configuration object. All properties of this object are optional and have default values:
nDims(default2): number of output dimensionsperplexity(default30): Roughly equivalent to the number of neighboring points to consider for distance preservation. A value between 10 and 50 is recommended.nIter(default100)learningRate(default1): recommended values are 1, 10, or even 100
