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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more