Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
karpathy committed Oct 1, 2015
1 parent 4a043d5 commit f35e84a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ t-SNE is a visualization algorithm that embeds things in 2 or 3 dimensions. If y
## Online demo
The main project website has a [live example](https://cs.stanford.edu/people/karpathy/tsnejs/) and more description.

There is also the [t-SNE CSV demo](https://cs.stanford.edu/people/karpathy/tsnejs/csvdemo.html) that allows you to simply paste CSV data into a textbox and tSNEJS computes and visualizes the embedding on the fly (no coding needed).

## Research Paper
The algorithm was originally described in this paper:

Expand All @@ -21,18 +23,25 @@ You can find the PDF [here](https://jmlr.csail.mit.edu/papers/volume9/vandermaate
Import tsne.js into your document: `<script src="tsne.js"></script>`
And then here is some example code:

var opt = {epsilon: 10}; // epsilon is learning rate (10 = default)
var tsne = new tsnejs.tSNE(opt); // create a tSNE instance
```javascript

var opt = {}
opt.epsilon = 10; // epsilon is learning rate (10 = default)
opt.perplexity = 30; // roughly how many neighbors each point influences (30 = default)
opt.dim = 2; // dimensionality of the embedding (2 = default)

var tsne = new tsnejs.tSNE(opt); // create a tSNE instance

// initialize data. Here we have 3 points and some example pairwise dissimilarities
var dists = [[1.0, 0.1, 0.2], [0.1, 1.0, 0.3], [0.2, 0.1, 1.0]];
tsne.initDataDist(dists);
// initialize data. Here we have 3 points and some example pairwise dissimilarities
var dists = [[1.0, 0.1, 0.2], [0.1, 1.0, 0.3], [0.2, 0.1, 1.0]];
tsne.initDataDist(dists);

for(var k = 0; k < 500; k++) {
tsne.step(); // every time you call this, solution gets better
}
for(var k = 0; k < 500; k++) {
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
var Y = tsne.getSolution(); // Y is an array of 2-D points that you can plot
```

The data can be passed to tSNEJS as a set of high-dimensional points using the `tsne.initDataRaw(X)` function, where X is an array of arrays (high-dimensional points that need to be embedded). The algorithm computes the Gaussian kernel over these points and then finds the appropriate embedding.

Expand Down

0 comments on commit f35e84a

Please sign in to comment.