Skip to content

Commit

Permalink
Merge pull request #6 from PAIR-code/transform
Browse files Browse the repository at this point in the history
Implement transform method
  • Loading branch information
cannoneyed committed May 2, 2019
2 parents b5b0f90 + 941199b commit ff25ac3
Show file tree
Hide file tree
Showing 15 changed files with 2,330 additions and 1,298 deletions.
15 changes: 12 additions & 3 deletions README.md
Expand Up @@ -9,7 +9,6 @@ Uniform Manifold Approximation and Projection (UMAP) is a dimension reduction te
There are a few important differences between the python implementation and the JS port.

- The optimization step is seeded with a random embedding rather than a spectral embedding. This gives comparable results for smaller datasets. The spectral embedding computation relies on efficient eigenvalue / eigenvector computations that are not easily done in JS.
- There is no implementation of any supervised dimension reduction or adding new points to an existing embedding.
- The only distance function used is euclidean distance.
- There is no specialized functionality for angular distances or sparse data representations.

Expand Down Expand Up @@ -62,15 +61,25 @@ umap.setSupervisedProjection(labels);
const embedding = umap.fit(data);
```

#### Transforming additional points after fitting

```typescript
import { UMAP } from 'umap-js';

const umap = new UMAP();
umap.fit(data);
const transformed = umap.transform(additionalData);
```

#### Parameters

The UMAP constructor can accept a number of parameters via a `UMAPParameters` object:
The UMAP constructor can accept a number of hyperparameters via a `UMAPParameters` object, with the most common described below. See [umap.ts](./src/umap.ts) for more details.

| Parameter | Description | default |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------ |
| `nComponents` | The number of components (dimensions) to project the data to | 2 |
| `nEpochs` | The number of epochs to optimize embeddings via SGD | (computed automatically) |
| `nNeighbors` | The number of nearest neighbors to construct the fuzzy manifold | 15 |
| `nNeighbors` | The number of nearest neighbors to construct the fuzzy manifold | 15 |
| `minDist` | The effective minimum distance between embedded points, used with `spread` to control the clumped/dispersed nature of the embedding | 0.1 |
| `spread` | The effective scale of embedded points, used with `minDist` to control the clumped/dispersed nature of the embedding | 1.0 |
| `random` | A pseudo-random-number generator for controlling stochastic processes | `Math.random` |
Expand Down

0 comments on commit ff25ac3

Please sign in to comment.