Public
Edited
Aug 9, 2023
1 fork
Importers
15 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
positions = Generators.observe(
worker(
fit,
{ data, show_dynamic, config },
`
const window = {};
importScripts("https://unpkg.com/umap-js@1.3.3/lib/umap-js.js");
importScripts("https://unpkg.com/d3-random@2");
const UMAP = window.UMAP;
Math.random = d3.randomLcg(${seed});
`
)
)
Insert cell
config = ({
nComponents: 2,
minDist: 0.1,
nNeighbors: 15
})
Insert cell
fit = function* fit({ data, show_dynamic, config }) {
//When initializing return something
yield [];

const umap = new UMAP(config),
nEpochs = config.nEpochs || umap.initializeFit(data);

yield umap.getEmbedding();
for (let i = 0; i < nEpochs; i++) {
umap.step();
if (show_dynamic) yield umap.getEmbedding();
}
yield umap.getEmbedding();
}
Insert cell
Insert cell
UMAP = "🌶" // fake symbol to make Observable happy (the real UMAP is loaded inside the worker)
Insert cell
import {worker} from "@fil/worker"
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more