Skip to content
/ tsne Public
forked from karpathy/tsnejs

t-SNE implementation in TypeScript.

License

Notifications You must be signed in to change notification settings

keckelt/tsne

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tSNE

npm (scoped)

Updated implementation of tSNEJS in TypeScript.
Published on NPM: npm install @keckelt/tsne.

Usage

import {TSNE} from '@keckelt/tsne-js';

const data = [...];

// TODO one hot encoding, normalization, ...

const opt = {
  epsilon: 10, // epsilon is learning rate (10 = default)
  perplexity: data.length ** 0.5, // roughly how many neighbors each point influences (30 = default)
  dim: 2 // dimensionality of the embedding (2 = default)
};

const tsne = new TSNE(opt);
tsne.initDataRaw(data);

const iterations = 500;
for(let i = 0; i < iterations; i++) {
  tsne.step(); // every time you call this, solution gets better
}

var Y = tsne.getSolution(); // Y is an array of 2-D points that you can plot

Worker

You can use Comlink, for example, to wrap the TSNE class and have the code executed in a worker thread:

import * as Comlink from 'comlink';
import { TSNE } from '@keckelt/tsne-js';

Comlink.expose(TSNE);

About

t-SNE implementation in TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%