• Stars
    star
    344
  • Rank 118,440 (Top 3 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

JavaScript implementation of UMAP

Build Status

UMAP-JS

This is a JavaScript reimplementation of UMAP from the python implementation found at https://github.com/lmcinnes/umap.

Uniform Manifold Approximation and Projection (UMAP) is a dimension reduction technique that can be used for visualisation similarly to t-SNE, but also for general non-linear dimension reduction.

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 specialized functionality for angular distances or sparse data representations.

Usage

Installation

yarn add umap-js

Synchronous fitting

import { UMAP } from 'umap-js';

const umap = new UMAP();
const embedding = umap.fit(data);

Asynchronous fitting

import { UMAP } from 'umap-js';

const umap = new UMAP();
const embedding = await umap.fitAsync(data, epochNumber => {
  // check progress and give user feedback, or return `false` to stop
});

Step-by-step fitting

import { UMAP } from 'umap-js';

const umap = new UMAP();
const nEpochs = umap.initializeFit(data);
for (let i = 0; i < nEpochs; i++) {
  umap.step();
}
const embedding = umap.getEmbedding();

Supervised projection using labels

import { UMAP } from 'umap-js';

const umap = new UMAP();
umap.setSupervisedProjection(labels);
const embedding = umap.fit(data);

Transforming additional points after fitting

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 hyperparameters via a UMAPParameters object, with the most common described below. See 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
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
distanceFn A custom distance function to use euclidean
const umap = new UMAP({
  nComponents: 2,
  nEpochs: 400,
  nNeighbors: 15,
});

Testing

umap-js uses jest for testing.

yarn test

This is not an officially supported Google product

More Repositories

1

facets

Visualizations for machine learning datasets
Jupyter Notebook
7,308
star
2

lit

The Learning Interpretability Tool: Interactively analyze ML models to understand their behavior in an extensible and framework agnostic interface.
TypeScript
3,386
star
3

saliency

Framework-agnostic implementation for state-of-the-art saliency methods (XRAI, BlurIG, SmoothGrad, and more).
Jupyter Notebook
927
star
4

what-if-tool

Source code/webpage/demos for the What-If Tool
HTML
881
star
5

knowyourdata

A tool to help researchers and product teams understand datasets with the goal of improving data quality, and mitigating fairness and bias issues.
CSS
273
star
6

wordcraft

✨✍️ Wordcraft is an AI-powered text editor with an emphasis on short story writing
TypeScript
208
star
7

federated-learning

Federated learning experiment using TensorFlow.js
TypeScript
159
star
8

datacardsplaybook

The Data Cards Playbook helps dataset producers and publishers adopt a people-centered approach to transparency in dataset documentation.
TypeScript
157
star
9

scatter-gl

Interactive 3D / 2D webgl-accelerated scatter plot point renderer
TypeScript
156
star
10

understanding-umap

Understanding the theory behind UMAP
JavaScript
150
star
11

interpretability

PAIR.withgoogle.com and friend's work on interpretability methods
JavaScript
109
star
12

ai-explorables

https://pair.withgoogle.com/explorables/
Jupyter Notebook
51
star
13

cococo

𝄑 Collaborative Convolutional Counterpoint
TypeScript
45
star
14

cam-scroller

Cam Scroller is an open-source Chrome extension that uses your webcam and deeplearn.js to enable scrolling through webpages using custom gestures that you define.
JavaScript
33
star
15

font-explorer

Font latent space explorer using tensorflow.js
Vue
31
star
16

clinical-vis

A javascript medical record visualization (https://arxiv.org/abs/1810.05798)
HTML
25
star
17

megaplot

TypeScript
19
star
18

pair-code.github.io

HTML
17
star
19

depth-maps-art-and-illusions

TypeScript
16
star
20

thehardway

Supplementary code repository to accompany Tic-Tac-Toe the Hard Way podcast
JavaScript
11
star
21

covid19_symptom_dataset

JavaScript
11
star
22

recommendation-rudders

TypeScript
10
star
23

jax-recommenders

Python
8
star
24

farsight

In situ interactive widgets for responsible AI 🌱
TypeScript
7
star
25

book-viz

Visualizing multilevel structure in books with sentence embeddings.
Jupyter Notebook
6
star
26

waterfall-of-meaning

TypeScript
4
star
27

tiny-transformers

Jupyter Notebook
4
star
28

deeplearnjs-legacy-loader

Deprecated: Legacy TensorFlow model loader for deeplearn.js
Python
3
star
29

colormap

JavaScript
3
star
30

ml-vis-experiments

Jupyter Notebook
1
star
31

deeplearnjs-docs

TypeScript
1
star
32

auto-histograms

Python
1
star