function* fitdynamic({ N, precomputed, config }) {
const time = performance.now();
const umap = new UMAP(config);
umap.distanceFn = function distance(i, j) {
return precomputed[i][j];
};
yield {
result: Array.from({ length: N }, () => [Math.random(), Math.random()]),
time: performance.now() - time,
epoch: -1
};
const nEpochs = umap.initializeFit(Array.from({ length: N }, (_, i) => i));
yield {
result: Array.from({ length: N }, () => [Math.random(), Math.random()]),
time: performance.now() - time,
epoch: 0
};
var t = performance.now(),
t0 = t;
for (let i = 0; i < nEpochs; i++) {
umap.step();
t = performance.now();
if (t - t0 > 200) {
t0 = t;
yield {
result: umap.getEmbedding(),
time: performance.now() - time,
epoch: i
};
}
}
yield {
result: umap.getEmbedding(),
time: performance.now() - time,
epoch: nEpochs
};
}