Code
import numpy as np
import drnb.embed.pipeline as pl
from drnb.experiment import ExperimentSee part 1 for an introduction and default UMAP results.
Looking at the low-dimensional datasets (e.g. mammoth and scurvehole) there does still seem to be a tendency to break the data up a bit more than PaCMAP does. How much of the remaining variability is due to that? We can check this by using the Cauchy (t-distribution) kernel which is about as gentle as the standard UMAP cost function can get. This doesn’t reproduce the repulsive and attractive forces used by PaCMAP but it gets us closer.
experiment = Experiment(name="tumap-annealed-neighbors")
seeds = np.random.SeedSequence(42).generate_state(5)
for i, seed in enumerate(seeds, 1):
experiment.add_method(
[
pl.embedder(
"umap",
params={"random_state": seed, "n_neighbors": 150, "a": 1, "b": 1},
),
pl.embedder(
"umap", params={"random_state": seed, "n_neighbors": 50, "a": 1, "b": 1}
),
pl.embedder(
"umap", params={"random_state": seed, "n_neighbors": 15, "a": 1, "b": 1}
),
],
name=f"tumap-run-{i}",
)
experiment.add_datasets(
[
"curve2d",
"mammoth",
"scurvehole",
"isoswiss",
"hierarchical",
"spheres",
"coil20",
"coil100",
"mnist",
"fashion",
"ng20pacmap",
"macosko2015",
"tasic2018",
"lamanno2020",
"kazer",
"stuart",
"kang",
]
)
experiment.run()[20:38:04] INFO Running tumap-run-1 on curve2d experiment.py:67
[20:38:09] INFO Running tumap-run-1 on mammoth experiment.py:67
[20:40:17] INFO Running tumap-run-1 on scurvehole experiment.py:67
[20:40:48] INFO Running tumap-run-1 on isoswiss experiment.py:67
[20:41:19] INFO Running tumap-run-1 on hierarchical experiment.py:67
/home/james/dev/drnb3/.venv/lib/python3.12/site-packages/sklearn/manifold/_spectral_embedding.py:328: UserWarning:
Graph is not fully connected, spectral embedding may not work as expected.
[20:43:22] INFO Running tumap-run-1 on spheres experiment.py:67
[20:43:59] INFO Running tumap-run-1 on coil20 experiment.py:67
[20:44:06] INFO Running tumap-run-1 on coil100 experiment.py:67
[20:44:49] INFO Running tumap-run-1 on mnist experiment.py:67
[20:47:01] INFO Running tumap-run-1 on fashion experiment.py:67
[20:49:45] INFO Running tumap-run-1 on ng20pacmap experiment.py:67
[20:50:18] INFO Running tumap-run-1 on macosko2015 experiment.py:67
[20:51:55] INFO Running tumap-run-1 on tasic2018 experiment.py:67
[20:52:47] INFO Running tumap-run-1 on lamanno2020 experiment.py:67
[20:53:04] INFO Running tumap-run-1 on kazer experiment.py:67
[20:55:05] INFO Running tumap-run-1 on stuart experiment.py:67
[20:56:02] INFO Running tumap-run-1 on kang experiment.py:67
[20:56:27] INFO Running tumap-run-2 on curve2d experiment.py:67
[20:56:31] INFO Running tumap-run-2 on mammoth experiment.py:67
[20:58:26] INFO Running tumap-run-2 on scurvehole experiment.py:67
[20:58:55] INFO Running tumap-run-2 on isoswiss experiment.py:67
[20:59:25] INFO Running tumap-run-2 on hierarchical experiment.py:67
/home/james/dev/drnb3/.venv/lib/python3.12/site-packages/sklearn/manifold/_spectral_embedding.py:328: UserWarning:
Graph is not fully connected, spectral embedding may not work as expected.
[21:01:26] INFO Running tumap-run-2 on spheres experiment.py:67
[21:02:04] INFO Running tumap-run-2 on coil20 experiment.py:67
[21:02:10] INFO Running tumap-run-2 on coil100 experiment.py:67
[21:02:53] INFO Running tumap-run-2 on mnist experiment.py:67
[21:05:10] INFO Running tumap-run-2 on fashion experiment.py:67
[21:07:33] INFO Running tumap-run-2 on ng20pacmap experiment.py:67
[21:08:07] INFO Running tumap-run-2 on macosko2015 experiment.py:67
[21:09:48] INFO Running tumap-run-2 on tasic2018 experiment.py:67
[21:10:40] INFO Running tumap-run-2 on lamanno2020 experiment.py:67
[21:10:56] INFO Running tumap-run-2 on kazer experiment.py:67
[21:12:57] INFO Running tumap-run-2 on stuart experiment.py:67
[21:13:56] INFO Running tumap-run-2 on kang experiment.py:67
[21:14:25] INFO Running tumap-run-3 on curve2d experiment.py:67
[21:14:29] INFO Running tumap-run-3 on mammoth experiment.py:67
[21:16:36] INFO Running tumap-run-3 on scurvehole experiment.py:67
[21:17:07] INFO Running tumap-run-3 on isoswiss experiment.py:67
[21:17:42] INFO Running tumap-run-3 on hierarchical experiment.py:67
/home/james/dev/drnb3/.venv/lib/python3.12/site-packages/sklearn/manifold/_spectral_embedding.py:328: UserWarning:
Graph is not fully connected, spectral embedding may not work as expected.
[21:19:47] INFO Running tumap-run-3 on spheres experiment.py:67
[21:20:25] INFO Running tumap-run-3 on coil20 experiment.py:67
[21:20:32] INFO Running tumap-run-3 on coil100 experiment.py:67
[21:21:16] INFO Running tumap-run-3 on mnist experiment.py:67
[21:23:40] INFO Running tumap-run-3 on fashion experiment.py:67
[21:26:06] INFO Running tumap-run-3 on ng20pacmap experiment.py:67
[21:26:38] INFO Running tumap-run-3 on macosko2015 experiment.py:67
[21:28:15] INFO Running tumap-run-3 on tasic2018 experiment.py:67
[21:29:06] INFO Running tumap-run-3 on lamanno2020 experiment.py:67
[21:29:21] INFO Running tumap-run-3 on kazer experiment.py:67
[21:31:17] INFO Running tumap-run-3 on stuart experiment.py:67
[21:32:15] INFO Running tumap-run-3 on kang experiment.py:67
[21:32:39] INFO Running tumap-run-4 on curve2d experiment.py:67
[21:32:43] INFO Running tumap-run-4 on mammoth experiment.py:67
[21:34:40] INFO Running tumap-run-4 on scurvehole experiment.py:67
[21:35:10] INFO Running tumap-run-4 on isoswiss experiment.py:67
[21:35:40] INFO Running tumap-run-4 on hierarchical experiment.py:67
/home/james/dev/drnb3/.venv/lib/python3.12/site-packages/sklearn/manifold/_spectral_embedding.py:328: UserWarning:
Graph is not fully connected, spectral embedding may not work as expected.
[21:37:40] INFO Running tumap-run-4 on spheres experiment.py:67
[21:38:18] INFO Running tumap-run-4 on coil20 experiment.py:67
[21:38:24] INFO Running tumap-run-4 on coil100 experiment.py:67
[21:39:08] INFO Running tumap-run-4 on mnist experiment.py:67
[21:41:24] INFO Running tumap-run-4 on fashion experiment.py:67
[21:43:48] INFO Running tumap-run-4 on ng20pacmap experiment.py:67
[21:44:20] INFO Running tumap-run-4 on macosko2015 experiment.py:67
[21:45:59] INFO Running tumap-run-4 on tasic2018 experiment.py:67
[21:46:51] INFO Running tumap-run-4 on lamanno2020 experiment.py:67
[21:47:06] INFO Running tumap-run-4 on kazer experiment.py:67
[21:49:09] INFO Running tumap-run-4 on stuart experiment.py:67
[21:50:06] INFO Running tumap-run-4 on kang experiment.py:67
[21:50:30] INFO Running tumap-run-5 on curve2d experiment.py:67
[21:50:34] INFO Running tumap-run-5 on mammoth experiment.py:67
[21:52:30] INFO Running tumap-run-5 on scurvehole experiment.py:67
[21:53:00] INFO Running tumap-run-5 on isoswiss experiment.py:67
[21:53:31] INFO Running tumap-run-5 on hierarchical experiment.py:67
/home/james/dev/drnb3/.venv/lib/python3.12/site-packages/sklearn/manifold/_spectral_embedding.py:328: UserWarning:
Graph is not fully connected, spectral embedding may not work as expected.
[21:55:43] INFO Running tumap-run-5 on spheres experiment.py:67
[21:56:21] INFO Running tumap-run-5 on coil20 experiment.py:67
[21:56:27] INFO Running tumap-run-5 on coil100 experiment.py:67
[21:57:11] INFO Running tumap-run-5 on mnist experiment.py:67
[21:59:26] INFO Running tumap-run-5 on fashion experiment.py:67
[22:01:51] INFO Running tumap-run-5 on ng20pacmap experiment.py:67
[22:02:23] INFO Running tumap-run-5 on macosko2015 experiment.py:67
[22:04:00] INFO Running tumap-run-5 on tasic2018 experiment.py:67
[22:04:53] INFO Running tumap-run-5 on lamanno2020 experiment.py:67
[22:05:09] INFO Running tumap-run-5 on kazer experiment.py:67
[22:07:05] INFO Running tumap-run-5 on stuart experiment.py:67
[22:08:02] INFO Running tumap-run-5 on kang experiment.py:67
There are perhaps some small changes in consistency that favor the t-UMAP results here in mnist and fashion and the hole in scurvehole is more preserved. Otherwise not much to it.
In part 3, I’ll look at whether PCA initialization leads to more consistency than the spectral initialization.