Published
Edited
Jul 29, 2020
7 stars
Insert cell
Insert cell
function distance(a, b) {
return Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
}
Insert cell
Insert cell
Insert cell
n = 25
Insert cell
data = (replay,
Array.from({ length: n }, (_, x) =>
Array.from({ length: n }, (_, y) => ({ x, y }))
).flat())
Insert cell
config = ({
nComponents: 2,
minDist: 0.1,
nNeighbors: 20
})
Insert cell
function fit({ data, config }) {
const umap = new UMAP(config);
umap.distanceFn = distance;
return {
result: umap.fit(data)
};
}
Insert cell
res = fit({ data, config })
Insert cell
UMAP = (await require("umap-js@1.3.2")).UMAP
Insert cell
Insert cell
color = d3
.scaleLinear()
.range(["orange", "lightblue"])
.domain([0, n * n])
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
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