drnb notebooks
  • Notebooks
  • GitHub
  1. Articles
  2. How Does Dimensionality Reduction Transform Distances?
  • Experiments in Dimensionality Reduction
  • Articles
    • Do Hubs Hurt?
    • How Does Dimensionality Reduction Transform Distances?
    • Hubness
    • Heavy-tailed UMAP
    • Leopold: Lightweight Estimate of Preservation of Local Density
    • Measuring Media Bias
    • Normalized Compression Distance with 20 Newsgroups
    • PaCMAP: local scaling vs. k-nearest neighbors
    • PaCMAP Repeats
    • Neighbor Overlap and PCA
    • Neighbor Recall: UMAP vs t-SNE
    • Approximating Isomap with k-Nearest Neighbors and Stochastic Metric Multidimensional Scaling
    • Stochastic Metric Multidimensional Scaling
    • Renormalizing after TF-IDF + SVD
    • t-SNE Consistency with Random Initialization
    • UMAP with Annealed Neighbors. 1: Defaults
    • UMAP with Annealed Neighbors. 2: t-UMAP
    • UMAP with Annealed Neighbors. 3: PCA Initialization
    • Spectral Embedding
    • UMATO Evaluation
    • t-SNE Affinity: Gaussian vs. Uniform

On this page

  • Gaussians
    • Concentration of Ambient Distances
    • PCA on Gaussians
    • Stochastic Metric MDS
  • UMAP on Gaussians
    • t-SNE
  • MNIST
  • FMNIST (Fashion)
  • s-curve with a hole
  1. Articles
  2. How Does Dimensionality Reduction Transform Distances?

How Does Dimensionality Reduction Transform Distances?

  • Show All Code
  • Hide All Code
Code
%load_ext lab_black
%load_ext autotime
import numpy as np
import pandas as pd
time: 1.86 ms (started: 2023-07-23 14:48:23 -07:00)

In terms of distances in the ambient and embedded space, how do methods that are successful at uncovering clusters in high-dimensional data (e.g. UMAP, t-SNE) differ from methods like PCA?

Some more specific questions:

  • As the intrinsic dimensionality of a dataset increases, how does the distribution of nearest neighbor distances change?
  • As the intrinsic dimensionality of a dataset increases, how does the distribution of random neighbor distances change?
  • How does applying PCA affect the distribution of those distances?
  • How does applying UMAP or t-SNE affect the distribution of those distances?
  • What sort of transformation is applied to a given near or random distance when applying those DR techniques?

To answer those questions here are some functions to:

  • Calculate the distances between nearest neighbors in a dataset.
  • Calculate the distances for randomly chosen items in a dataset.
  • Plot a histogram of those distances.
  • Carry out dimensionality reduction on the dataset. The default transformation is PCA.
  • Recalculate the nearest neighbor and random distances (using the same items).
  • Plot a histogram of the embedded distances.
  • Plot a scatterplot showing how these distances are transformed by the dimensionality reduction.
  • Report some summary statistics on those distance distributions.

The results below are for embedded into 2D. I do not show the actual results of the embedding.

Code
from dataclasses import dataclass

import matplotlib.pyplot as plt
import seaborn as sns

import drnb.embed.pipeline as pl
from drnb.io.dataset import read_data
from drnb.neighbors import calculate_neighbors
from drnb.neighbors.distances import neighbor_distances
from drnb.neighbors.hubness import describe
from drnb.neighbors.nbrinfo import NearestNeighbors
from drnb.neighbors.random import random_neighbors
from drnb.plot import sns_embed_plot


def dof_nbrs(name):
    dnbrs = data_nbrs(name)
    for dof in [2, 1, 0.5]:
        dnbrs.embed("leopold", params=dict(dof=dof), name=f"leo{dof}")
    dnbrs.embed("pca")
    dnbrs.dhist("ambient", "pca", "leo2", "leo1", "leo0.5", sharex=False)
    dnbrs.embed_plot("leo0.5")
    return dnbrs


def data_nbrs(name):
    data = read_data(name)
    return DataNeighbors(data, data_name=name)


def embed_nbrs(data, method, params, ambient_nbrs):
    embedded = pl.embed(data, method=method, params=params)
    ennd = neighbor_distances(
        embedded, ambient_nbrs.near.idx, distance="euclidean"
    ).ravel()
    ernnd = neighbor_distances(
        embedded, ambient_nbrs.random.idx, distance="euclidean"
    ).ravel()
    return ennd, ernnd, embedded


def init_fig(num_rows, figsize=None, title=None, sharex=False, sharey=False):
    if figsize is None:
        figsize = (10, 4)
    figure, axes = plt.subplots(
        num_rows,
        2,
        figsize=(figsize[0], figsize[1] * num_rows),
        sharex=sharex,
        sharey=sharey,
        layout="constrained",
    )
    if title is not None:
        figure.suptitle(title)
    if num_rows == 1:
        axes = axes.reshape((1, axes.shape[0]))
    return figure, axes


def norm_reqs(*plot_reqs):
    # make sure all args are of the form (DataNeighbor, [method_name...])
    nreqs = []
    for req in plot_reqs:
        if isinstance(req[1], str):
            nreqs.append((req[0], [req[1]]))
        else:
            nreqs.append(req)
    return nreqs


def show(*plot_reqs, title=None, figsize=None, sharex=False):
    nreqs = norm_reqs(*plot_reqs)
    num_rows = sum(len(req[1]) for req in nreqs)
    _, axes = init_fig(num_rows=num_rows, title=title, figsize=figsize, sharex=sharex)
    i = 0
    for data_nbr, methods in nreqs:
        data_nbr.dhist(*methods, axes=axes[i : i + len(methods)])
        i += len(methods)


def show_all(*data_nbrs, method="ambient", title=None, figsize=None, sharex=False):
    args = [(data_nbr, method) for data_nbr in data_nbrs]
    show(*args, title=title, figsize=figsize, sharex=sharex)


def show_scatter(
    *data_nbrs,
    name,
    title=None,
    figsize=None,
    sharex=False,
    sharey=False,
    s=0.1,
    alpha=1.0,
):
    num_rows = len(data_nbrs)
    _, axes = init_fig(
        num_rows=num_rows, title=title, figsize=figsize, sharex=sharex, sharey=sharey
    )
    for i, data_nbr in enumerate(data_nbrs):
        data_nbr.dscatter(name, axes=axes[i : i + 1], s=s, alpha=alpha)


@dataclass
class AmbientNeighbors:
    near: NearestNeighbors = None
    random: NearestNeighbors = None


class DataNeighbors:
    def __init__(
        self,
        data,
        n_neighbors=15,
        nn_method="exact",
        data_name=None,
        metric="euclidean",
    ):
        self.data = data
        self.embedded = {}
        nn = calculate_neighbors(
            data,
            n_neighbors=n_neighbors,
            method=nn_method,
            include_self=False,
            metric=metric,
        )
        nn.dist = nn.dist.ravel()

        rnn = random_neighbors(data, n_neighbors=n_neighbors, distance=metric)
        rnn.dist = rnn.dist.ravel()

        self.ambient = AmbientNeighbors(nn, rnn)

        if data_name is None:
            data_name = f"{data.shape[1]}D"
        self.data_name = data_name

        self.n_neighbors = n_neighbors

    def embed(self, method, params=None, name=None):
        if name is None:
            name = method
        result = embed_nbrs(self.data, method, params, self.ambient)
        self.embedded[name] = result

    def distances(self, name="ambient"):
        if name == "ambient":
            return self._ambn, self._ambr
        return self.embedded[name][:2]

    def describe(self, names=None):
        if names is None:
            names = ["ambient"] + list(self.embedded.keys())
        if isinstance(names, str):
            names = [names]
        data_dict = {}
        for name in names:
            if name == "ambient":
                data_dict["ambient_near"] = self._ambn
                data_dict["ambient_random"] = self._ambr
            else:
                ennd, ernd = self.distances(name)
                data_dict[f"{name}_near"] = ennd
                data_dict[f"{name}_random"] = ernd
        df = pd.DataFrame(data_dict)
        return describe(
            df,
            count_zeros=False,
        ).rename_axis(index=self.data_name)

    @property
    def _ambn(self):
        return self.ambient.near.dist

    @property
    def _ambr(self):
        return self.ambient.random.dist

    def dscatter(
        self,
        *names,
        axes=None,
        s=0.1,
        alpha=1.0,
        figsize=(9, 4),
        sharex=False,
        sharey=False,
    ):
        ann, arnn = self.distances("ambient")
        if isinstance(names, str):
            names = [names]

        if axes is None:
            _, axes = init_fig(
                num_rows=len(names),
                title=self.data_name,
                figsize=figsize,
                sharex=sharex,
                sharey=sharey,
            )

        for i, name in enumerate(names):
            enn, ernn = self.distances(name)

            axes[i, 0].set_title(f"{self.data_name} {name} {self.n_neighbors}-nearest")
            axes[i, 0].set_xlabel("ambient distance")
            axes[i, 0].set_ylabel(f"{name} distance")
            sns.scatterplot(x=ann, y=enn, ax=axes[i, 0], s=s, alpha=alpha)

            axes[i, 1].set_title(f"{self.data_name} {name} {self.n_neighbors}-random")
            axes[i, 1].set_xlabel("ambient distance")
            axes[i, 1].set_ylabel(f"{name} distance")
            sns.scatterplot(x=arnn, y=ernn, ax=axes[i, 1], s=s, alpha=alpha)

    def dhist(self, *names, axes=None, figsize=(9, 3), sharex=False, show=None):
        if not names:
            names = ["ambient"]
        if isinstance(names, str):
            names = [names]

        if axes is None:
            _, axes = init_fig(
                num_rows=len(names),
                title=self.data_name,
                figsize=figsize,
                sharex=sharex,
            )

        for i, name in enumerate(names):
            nn, rnn = self.distances(name)

            axes[i, 0].set_title(f"{self.data_name} {name} {self.n_neighbors}-nearest")
            sns.histplot(nn, ax=axes[i, 0])

            axes[i, 1].set_title(f"{self.data_name} {name} {self.n_neighbors}-random")
            sns.histplot(rnn, ax=axes[i, 1])

    def embed_plot(self, name, **kwargs):
        coords = self.embedded[name][2]
        kwargs["coords"] = coords
        sns_embed_plot(**kwargs)
time: 66.8 ms (started: 2023-07-23 14:48:23 -07:00)

Gaussians

To start, let’s look at some gaussians of various dimensionality: 2D, 3D, 5D, 10D and 50D.

Code
from drnb.dataset import gaussnd
time: 4.28 ms (started: 2023-06-30 16:27:34 -07:00)
Code
g2dnbrs = DataNeighbors(gaussnd(10000, 2))
g3dnbrs = DataNeighbors(gaussnd(10000, 3))
g5dnbrs = DataNeighbors(gaussnd(10000, 5))
g10dnbrs = DataNeighbors(gaussnd(10000, 10))
g50dnbrs = DataNeighbors(gaussnd(10000, 50))
[11:27:41] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Could not load library with AVX2 support due to:                                   loader.py:58
                    ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")                                  
           INFO     Loading faiss.                                                                     loader.py:64
           INFO     Successfully loaded faiss.                                                         loader.py:66
time: 4.06 s (started: 2023-04-15 11:27:41 -07:00)

Concentration of Ambient Distances

Beyer and co-workers demonstrated a particular manifestation of the curse of dimensionality for nearest neighbor search: as dimensionality increases, the contrast between the distance to nearest neighbors and others begins to disappear, i.e. all distances start to be the same, which calls into question the concept the usefulness of how near a “near” neighbor really is. Pestov relates this to the “concentration of measure”. You will see variations of vocabulary around this, but I’ll call it “distance concentration”.

For the plots below, the left-hand column shows the distribution of 15-nearest neighbors for each Gaussian, and the right-hand column 15 random neighbors per point, with the dimensionality increasing from 2 to 50 as you go down the rows. The x-axis is shared for all plots so the overall trend is easier to see:

Code
show_all(g2dnbrs, g3dnbrs, g5dnbrs, g10dnbrs, g50dnbrs, method="ambient", sharex=True)

time: 7.68 s (started: 2023-04-15 11:27:45 -07:00)

The distance concentration is apparent here, with the nearest neighbor distribution getting more and more similar to the random neighbor distribution as dimensionality increases. Also, both distributions of distances:

  • shift away from zero
  • become more symmetric

It’s a little hard to see what is happening with the low-dimensional nearest neighbor distances, so here are the 2D, 3D, and 5D results again, but without sharing the x-axis:

Code
show_all(g2dnbrs, g3dnbrs, g5dnbrs, method="ambient")

time: 4.92 s (started: 2023-04-15 11:27:53 -07:00)

There is a skew of the neighbors at low dimensions which is particularly noticeable for the nearest neighbors.

All of that demonstrates that high-dimensional distances do not bear much resemblance to low-dimensional ones. That does not bode well for trying to preserve high-dimensional distances in a lower dimensions.

Distance Concentration: the Case of Cosine Distance

Does using an angular distance have much effect on the distance concentration?

Code
from drnb.preprocess import renormalize

show_all(
    DataNeighbors(renormalize(gaussnd(10000, 2), "l2")),
    DataNeighbors(renormalize(gaussnd(10000, 3), "l2")),
    DataNeighbors(renormalize(gaussnd(10000, 5), "l2")),
    DataNeighbors(renormalize(gaussnd(10000, 10), "l2")),
    DataNeighbors(renormalize(gaussnd(10000, 50), "l2")),
    method="ambient",
    sharex=True,
)
[22:19:49] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Could not load library with AVX2 support due to:                                   loader.py:58
                    ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'")                                  
           INFO     Loading faiss.                                                                     loader.py:64
           INFO     Successfully loaded faiss.                                                         loader.py:66
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.

time: 9.68 s (started: 2023-05-31 22:19:49 -07:00)
Code
show_all(
    DataNeighbors(renormalize(gaussnd(10000, 2), "l1")),
    DataNeighbors(renormalize(gaussnd(10000, 3), "l1")),
    DataNeighbors(renormalize(gaussnd(10000, 5), "l1")),
    DataNeighbors(renormalize(gaussnd(10000, 10), "l1")),
    DataNeighbors(renormalize(gaussnd(10000, 50), "l1")),
    method="ambient",
    sharex=True,
)

time: 9.06 s (started: 2023-05-31 22:20:08 -07:00)
Code
g2dnbrs_cos = DataNeighbors(gaussnd(10000, 2), metric="cosine")
g3dnbrs_cos = DataNeighbors(gaussnd(10000, 3), metric="cosine")
g5dnbrs_cos = DataNeighbors(gaussnd(10000, 5), metric="cosine")
g10dnbrs_cos = DataNeighbors(gaussnd(10000, 10), metric="cosine")
g50dnbrs_cos = DataNeighbors(gaussnd(10000, 50), metric="cosine")
time: 2.54 s (started: 2023-04-15 11:27:58 -07:00)
Code
show_all(
    g2dnbrs_cos,
    g3dnbrs_cos,
    g5dnbrs_cos,
    g10dnbrs_cos,
    g50dnbrs_cos,
    method="ambient",
    sharex=True,
)

time: 5.47 s (started: 2023-04-15 11:28:00 -07:00)

The 2D and 3D results certainly are different. But the overall trend is the same: distances shift away from zero and random and ambient distribution begin to look more alike.

PCA on Gaussians

Now let’s look at what using PCA to reduce to 2D does to these distance distributions.

Code
g2dnbrs.embed("pca")
g3dnbrs.embed("pca")
g5dnbrs.embed("pca")
g10dnbrs.embed("pca")
g50dnbrs.embed("pca")
[11:28:06] INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
[11:28:07] INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
[11:28:08] INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
time: 2.48 s (started: 2023-04-15 11:28:06 -07:00)
Code
show_all(g2dnbrs, g3dnbrs, g5dnbrs, g10dnbrs, g50dnbrs, method="pca", sharex=True)

time: 7.02 s (started: 2023-04-15 11:28:08 -07:00)

We would expect extracting 2 components from a 2D Gaussian would give the same results as with the raw ambient distances, and that is the case, so the first row is of interest only as a reference to what the ambient 2D distances look like.

There is an obvious difference in the trend as the dimensionality of the Gaussians increases: the distance does not shift rightwards to a great degree and the skewness of the distribution remains. In fact, for the random neighbors, the distribution is basically unchanged. This isn’t too surprising as the embedding space is a 2D distribution, so we get a 2D-like distribution regardless of what the original ambient dimensionality.

For nearest neighbors, we do see a shift of the distribution becoming closer to the random neighbor distribution. So this should makes it pretty clear that PCA on high-dimensional data is not going to preserve much local structure.

One other quirk of PCA is apparent if you plot the distances of PCA against the ambient distances. Here’s the 3D results:

Code
g3dnbrs.dscatter("pca")

time: 624 ms (started: 2023-04-15 11:28:15 -07:00)

The shape of these plots – where there are no points found in the upper left quadrant – means that when PCA transforms points, it will always reduce the distance between points if it has to. It never increases the distance. This is not surprising when you think about how the amount of variance “explained” of the original dataset approaches 100% from below as components are extracted. Here’s the 10D example to confirm the behavior:

Code
g10dnbrs.dscatter("pca")

time: 595 ms (started: 2023-04-15 11:28:16 -07:00)

Stochastic Metric MDS

To determine how much of the above is a quirk specific to PCA, here are some results using a stochastic version of MMDS, initialized from PCA. While not shown here, I have determined that these settings do reduce the stress of the result compared to PCA, i.e. the distances are better reproduced after applying SMMDS. Note also that a sufficiently long optimization with full MMDS starting from a random initialization will give a better-than-PCA stress with qualitatively similar results, i.e. the results are not a quirk of the stochastic nature of the algorithm or due to a bias from starting from the PCA result.

Code
smmds_params = dict(learning_rate=0.001, n_epochs=5000, random_state=42)
g2dnbrs.embed("smmds", params=smmds_params)
g3dnbrs.embed("smmds", params=smmds_params)
g5dnbrs.embed("smmds", params=smmds_params)
g10dnbrs.embed("smmds", params=smmds_params)
# For the 50D result, I needed to use a larger learning rate to get decent convergence in 5000 epochs
g50dnbrs.embed("smmds", params=dict(learning_rate=0.01, n_epochs=5000, random_state=42))
[11:28:17] INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:28:39] INFO     Embedding completed                                                                smmds.py:120
[11:28:40] INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:28:59] INFO     Embedding completed                                                                smmds.py:120
           INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:29:17] INFO     Embedding completed                                                                smmds.py:120
           INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:29:36] INFO     Embedding completed                                                                smmds.py:120
           INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:29:54] INFO     Embedding completed                                                                smmds.py:120
time: 1min 37s (started: 2023-04-15 11:28:17 -07:00)

First, checking in on the distributions:

Code
show_all(g2dnbrs, g3dnbrs, g5dnbrs, g10dnbrs, g50dnbrs, method="smmds", sharex=True)

time: 8.24 s (started: 2023-04-15 11:29:54 -07:00)

The 50D result is very different and is dominating the range of the shared x-axis now, so the sharex=False result is again useful:

Code
show_all(g2dnbrs, g3dnbrs, g5dnbrs, g10dnbrs, g50dnbrs, method="smmds", sharex=False)

time: 7.62 s (started: 2023-04-15 11:30:03 -07:00)

The pattern is still quite similar to the PCA results, but the extra optimization of distances seems to have increased and broadened the distributions. Here’s the 50D distributions for the ambient, PCA and SMMDS distances:

Code
g50dnbrs.dhist("ambient", "pca", "smmds", sharex=True)

time: 3.44 s (started: 2023-04-15 11:30:10 -07:00)

So compared to PCA, SMMDS embedding into 2D is successful at shifting the distribution of distances so the median value gets closer to the high-dimensional values, but it can’t match the spread of the distribution, nor the symmetry, with the nearest neighbor distribution having a noticeably broad right tail. A similar, but less pronounced pattern can be seen with the 5D Gaussian:

Code
g5dnbrs.dhist("ambient", "pca", "smmds", sharex=True)

time: 3.39 s (started: 2023-04-15 11:30:14 -07:00)

We can also look at the scatterplot of how the distances are transformed which also clearly shows the shifting and broadening pattern:

Code
show_scatter(
    g5dnbrs, g10dnbrs, g50dnbrs, name="smmds", alpha=0.1, sharex=True, sharey=True
)

time: 1.86 s (started: 2023-04-15 11:30:17 -07:00)

Unlike PCA, SMDS is able to improve the reproduction of distances as a whole by allowing some distances to be larger in the embedded space than the ambient space. Here are the 50D PCA and SMMDS directly compared with a shared Y-axis that shows this clearly:

Code
g50dnbrs.dscatter("pca", "smmds", sharey=True, alpha=0.5)

time: 1.49 s (started: 2023-04-15 11:30:19 -07:00)

And here’s a histogram of the difference between the smmds-embedded distances and the equivalent ambient distances for the random neighbors which demonstrates that there is still a tendency for the distances to be under-predicted, even though some distances are larger than in the ambient space:

Code
ann, arn = g50dnbrs.distances("ambient")
snn, srn = g50dnbrs.distances("smmds")
sns.histplot(srn - arn)

time: 340 ms (started: 2023-04-15 11:30:21 -07:00)

The bulk of the disparity in distances are below 0.

UMAP on Gaussians

Ok, so we have a pretty good idea of what methods that attempt to preserve distance do. How does UMAP compare? To avoid complete graph overload, let’s just look at the 10D and 50D case for now.

Code
g10dnbrs.embed("umap")
g50dnbrs.embed("umap")
[11:30:21] INFO     Running UMAP                                                                        umap.py:162
[11:30:46] INFO     Embedding completed                                                                 umap.py:167
           INFO     Running UMAP                                                                        umap.py:162
[11:30:54] INFO     Embedding completed                                                                 umap.py:167
time: 32.7 s (started: 2023-04-15 11:30:21 -07:00)
Code
g10dnbrs.dhist("ambient", "pca", "smmds", "umap", sharex=True)

time: 5.05 s (started: 2023-04-15 11:30:54 -07:00)

Obviously there should be little expectation that UMAP preserves distances. The most obvious difference is how the nearest neighbor distribution looks: a sharp peak early, and then a long tail. Meanwhile the random neighbors are less broadly distributed and shifted to a lower distance compared to SMMDS.

Code
g50dnbrs.dhist("ambient", "pca", "smmds", "umap", sharex=True)

time: 4.59 s (started: 2023-04-15 11:30:59 -07:00)

In the 50D case, the nearest neighbors are even more interestingly distributed. The random neighbors have a distribution that seems to have a similar span to the nearest neighbors, but an obviously high peak. Here’s a closer look at just the PCA and UMAP results, as they are the most similar to each other:

Code
g50dnbrs.dhist("pca", "umap", sharex=True)

time: 1.81 s (started: 2023-04-15 11:31:03 -07:00)

The distribution of the random neighbors really doesn’t seem that different.

t-SNE

Let’s also take a look at t-SNE, again for the 10D and 50D case.

Code
g10dnbrs.embed("tsne")
g50dnbrs.embed("tsne")
[11:31:05] INFO     Running t-SNE                                                                       tsne.py:110
[11:31:11] INFO     Precomputed initialization provided. Ignoring initalization-related parameters.    tsne.py:1329
           INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:31:17] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:31:33] INFO     Embedding completed                                                                 tsne.py:113
           INFO     Running t-SNE                                                                       tsne.py:110
[11:31:39] INFO     Precomputed initialization provided. Ignoring initalization-related parameters.    tsne.py:1329
           INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:31:45] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:31:56] INFO     Embedding completed                                                                 tsne.py:113
time: 51.4 s (started: 2023-04-15 11:31:05 -07:00)
Code
g10dnbrs.dhist("umap", "tsne", sharex=True)

time: 1.86 s (started: 2023-04-15 11:31:56 -07:00)

The t-SNE distances are on a completely different scale to UMAP’s (and any of the other methods we have looked at). The nearest neighbor distribution resembles UMAP’s to the extent of a concentration of very short distances and then a long (slightly bimodal?) tail. Meanwhile, the random distances show a much broader more symmetric pattern.

Code
g50dnbrs.dhist("umap", "tsne", sharex=True)

time: 2.07 s (started: 2023-04-15 11:31:58 -07:00)

A similar pattern here, with the bimodal distribution for nearest neighbors more obvious. For the random neighbors, an asymmetry in the distribution is also apparent.

Now let’s look at the scatter plots:

Code
g10dnbrs.dscatter("umap", "tsne", alpha=0.5)

time: 1.16 s (started: 2023-04-15 11:32:00 -07:00)
Code
g50dnbrs.dscatter("umap", "tsne", alpha=0.5)

time: 1.17 s (started: 2023-04-15 11:32:02 -07:00)

These are very different from the PCA and SMMDS results. Really very hard to detect any sort of relationship between the ambient and embedded distances (which again should not be too surprising).

MNIST

Code
from drnb.io.dataset import read_data

mnist = read_data("mnist")
mnistnbrs = DataNeighbors(mnist, data_name="mnist")
time: 8.11 s (started: 2023-04-15 11:32:03 -07:00)
Code
mnistnbrs.embed("pca")
mnistnbrs.embed(
    "smmds", params=dict(learning_rate=1.0, n_epochs=10000, random_state=42)
)
[11:32:11] INFO     Running PCA                                                                           pca.py:20
[11:32:13] INFO     Embedding completed                                                                   pca.py:23
[11:32:14] INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:36:33] INFO     Embedding completed                                                                smmds.py:120
time: 4min 22s (started: 2023-04-15 11:32:11 -07:00)
Code
mnistnbrs.dhist("ambient", "pca", "smmds", sharex=True)

time: 7.75 s (started: 2023-04-15 11:36:33 -07:00)
Code
mnistnbrs.embed("umap")
mnistnbrs.embed("tsne")
[11:36:41] INFO     Running UMAP                                                                        umap.py:162
[11:37:09] INFO     Embedding completed                                                                 umap.py:167
[11:37:10] INFO     Running t-SNE                                                                       tsne.py:110
[11:40:52] INFO     Precomputed initialization provided. Ignoring initalization-related parameters.    tsne.py:1329
[11:40:54] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:41:18] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:42:37] INFO     Embedding completed                                                                 tsne.py:113
time: 5min 55s (started: 2023-04-15 11:36:41 -07:00)
Code
mnistnbrs.dhist("umap")

time: 9.16 s (started: 2023-04-15 11:42:37 -07:00)
Code
mnistnbrs.dhist("tsne")

time: 4.58 s (started: 2023-04-15 11:42:46 -07:00)
Code
mnistnbrs.dscatter("pca", "smmds", "umap", "tsne", alpha=0.1)

time: 6.09 s (started: 2023-04-15 11:42:50 -07:00)

FMNIST (Fashion)

Code
fashion = read_data("fashion")
fashionnbrs = DataNeighbors(fashion, data_name="fashion")
time: 8.23 s (started: 2023-04-15 11:42:57 -07:00)
Code
fashionnbrs.embed("pca")
fashionnbrs.embed(
    "smmds", params=dict(learning_rate=1.0, n_epochs=10000, random_state=42)
)
[11:43:05] INFO     Running PCA                                                                           pca.py:20
[11:43:08] INFO     Embedding completed                                                                   pca.py:23
           INFO     Running SMMDS                                                                      smmds.py:117
           INFO     Initializing via (unscaled) PCA                                                     yinit.py:42
[11:47:37] INFO     Embedding completed                                                                smmds.py:120
time: 4min 31s (started: 2023-04-15 11:43:05 -07:00)
Code
fashionnbrs.dhist("ambient", "pca", "smmds", sharex=True)

time: 8.33 s (started: 2023-04-15 11:47:37 -07:00)
Code
fashionnbrs.embed("umap")
fashionnbrs.embed("tsne")
[11:47:45] INFO     Running UMAP                                                                        umap.py:162
[11:48:17] INFO     Embedding completed                                                                 umap.py:167
           INFO     Running t-SNE                                                                       tsne.py:110
[11:51:18] INFO     Precomputed initialization provided. Ignoring initalization-related parameters.    tsne.py:1329
[11:51:20] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:51:46] INFO     Automatically determined negative gradient method `fft`                              tsne.py:53
[11:53:02] INFO     Embedding completed                                                                 tsne.py:113
time: 5min 16s (started: 2023-04-15 11:47:45 -07:00)
Code
fashionnbrs.dhist("umap")

time: 6.26 s (started: 2023-04-15 11:53:02 -07:00)
Code
fashionnbrs.dhist("tsne")

time: 4.11 s (started: 2023-04-15 11:53:08 -07:00)
Code
fashionnbrs.dscatter("pca", "smmds", "umap", "tsne", alpha=0.1)

time: 5.74 s (started: 2023-04-15 11:53:12 -07:00)

s-curve with a hole

Code
from drnb.io.dataset import read_data

scurvehole = read_data("scurvehole")
scnbrs = DataNeighbors(scurvehole, data_name="scurvehole")
[16:28:56] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Successfully loaded faiss with AVX2 support.                                       loader.py:56
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
time: 2.4 s (started: 2023-06-30 16:28:56 -07:00)
Code
scnbrs.embed("umap")
[16:29:21] INFO     Running UMAP                                                                        umap.py:165
[16:29:46] INFO     Embedding completed                                                                 umap.py:171
time: 25.5 s (started: 2023-06-30 16:29:21 -07:00)
Code
scnbrs.embed_plot("umap")

time: 687 ms (started: 2023-06-30 16:30:00 -07:00)
Code
scnbrs.embed("leopold", params=dict(dof=2.0), name="leo2")
[16:30:46] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:30:56] INFO     Embedding completed                                                              leopold.py:212
time: 10.4 s (started: 2023-06-30 16:30:45 -07:00)
Code
scnbrs.embed("leopold", params=dict(dof=1.0), name="leo1")
[16:31:02] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
[16:31:03] INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:31:07] INFO     Embedding completed                                                              leopold.py:212
time: 4.56 s (started: 2023-06-30 16:31:02 -07:00)
Code
scnbrs.embed("leopold", params=dict(dof=0.5), name="leo0.5")
[16:31:15] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:31:20] INFO     Embedding completed                                                              leopold.py:212
time: 4.88 s (started: 2023-06-30 16:31:15 -07:00)
Code
scnbrs.embed_plot("leo2")

time: 832 ms (started: 2023-06-30 16:31:23 -07:00)
Code
scnbrs.embed_plot("leo1")

time: 654 ms (started: 2023-06-30 16:31:28 -07:00)
Code
scnbrs.embed_plot("leo0.5")

time: 659 ms (started: 2023-06-30 16:31:34 -07:00)
Code
scnbrs.dhist("ambient", "umap", "leo2", "leo1", "leo0.5", sharex=True)

time: 12.5 s (started: 2023-06-30 16:32:49 -07:00)
Code
scnbrs.dhist("ambient", "leo2", "leo1", "leo0.5", sharex=False)

time: 10.9 s (started: 2023-06-30 16:34:07 -07:00)
Code
isonbrs = data_nbrs("isoswiss")
time: 863 ms (started: 2023-06-30 16:38:31 -07:00)
Code
isonbrs.embed("leopold", params=dict(dof=2.0), name="leo2")
[16:38:54] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:38:55] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:39:05] INFO     Embedding completed                                                              leopold.py:212
time: 10.9 s (started: 2023-06-30 16:38:54 -07:00)
Code
isonbrs.embed("leopold", params=dict(dof=1.0), name="leo1")
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:39:16] INFO     Embedding completed                                                              leopold.py:212
time: 10.4 s (started: 2023-06-30 16:39:05 -07:00)
Code
isonbrs.embed("leopold", params=dict(dof=0.5), name="leo0.5")
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:39:26] INFO     Embedding completed                                                              leopold.py:212
time: 10.8 s (started: 2023-06-30 16:39:16 -07:00)
Code
isonbrs.embed("pca")
[16:39:27] INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23
time: 1.41 s (started: 2023-06-30 16:39:27 -07:00)
Code
isonbrs.dhist("ambient", "pca", "leo2", "leo1", "leo0.5", sharex=False)

time: 9.81 s (started: 2023-06-30 16:39:52 -07:00)
Code
isonbrs.embed_plot("leo0.5")

time: 1 s (started: 2023-06-30 16:40:29 -07:00)
Code
isonbrs.embed_plot("leo2")

time: 1.01 s (started: 2023-06-30 16:40:38 -07:00)
Code
isofnbrs = data_nbrs("isofaces")
for dof in [2, 1, 0.5]:
    isofnbrs.embed("leopold", params=dict(dof=dof), name=f"leo{dof}")
isofnbrs.embed("pca")
isofnbrs.dhist("ambient", "pca", "leo2", "leo1", "leo0.5", sharex=False)
[14:48:36] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Successfully loaded faiss with AVX2 support.                                       loader.py:56
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
[14:48:41] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:210
[14:48:55] INFO     Embedding completed                                                              leopold.py:213
[14:48:56] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:210
[14:48:57] INFO     Embedding completed                                                              leopold.py:213
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:210
[14:49:01] INFO     Embedding completed                                                              leopold.py:213
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 35.8 s (started: 2023-07-23 14:48:36 -07:00)
Code
isofnbrs.describe().loc["50%", ["leo2_near", "leo2_random", "pca_near", "pca_random"]]
leo2_near       0.562087
leo2_random     4.648446
pca_near        2.602610
pca_random     12.615314
Name: 50%, dtype: float64
time: 55.7 ms (started: 2023-07-23 14:56:59 -07:00)
Code
isofnbrs.embed_plot("leo2")

time: 543 ms (started: 2023-07-23 14:50:05 -07:00)
Code
isofnbrs.embed_plot("leo0.5")

time: 538 ms (started: 2023-07-23 14:49:50 -07:00)
Code
avonbrs = data_nbrs("avonet")
for dof in [2, 1, 0.5]:
    avonbrs.embed("leopold", params=dict(dof=dof), name=f"leo{dof}")
avonbrs.embed("pca")
avonbrs.dhist("ambient", "pca", "leo2", "leo1", "leo0.5", sharex=False)
[16:44:16] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:44:23] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:44:28] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:44:33] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 43.5 s (started: 2023-06-30 16:44:15 -07:00)
Code
avonbrs.embed_plot("leo0.5")

time: 749 ms (started: 2023-06-30 16:45:25 -07:00)
Code
kuzunbrs = dof_nbrs("kuzushiji")
[16:47:46] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:47:48] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:48:25] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:48:27] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:49:11] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:49:13] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:50:10] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[16:50:12] INFO     Embedding completed                                                                   pca.py:23

time: 3min 8s (started: 2023-06-30 16:47:42 -07:00)
Code
tasicnbrs = dof_nbrs("tasic2018-pca50")
[16:53:18] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:53:19] INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 5 components                                                        yinit.py:228
[16:53:34] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:53:35] INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 5 components                                                        yinit.py:228
[16:53:50] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:53:51] INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 5 components                                                        yinit.py:228
[16:54:07] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 1min 21s (started: 2023-06-30 16:53:17 -07:00)
Code
macoskonbrs = dof_nbrs("macosko2015-pca50")
[16:55:31] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:55:32] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:55:56] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:55:57] INFO     Running LEOPOLD                                                                  leopold.py:209
[16:56:23] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:56:48] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[16:56:49] INFO     Embedding completed                                                                   pca.py:23

time: 1min 36s (started: 2023-06-30 16:55:30 -07:00)
Code
onetnbrs = dof_nbrs("onet271")
[16:57:52] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:57:53] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:57:54] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:57:55] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 8.14 s (started: 2023-06-30 16:57:51 -07:00)
Code
penguinnbrs = dof_nbrs("penguins")
[16:58:58] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 2 components                                                        yinit.py:228
           INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 2 components                                                        yinit.py:228
[16:58:59] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 2 components                                                        yinit.py:228
           INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 7.28 s (started: 2023-06-30 16:58:57 -07:00)
Code
ng20nbrs = dof_nbrs("ng20")
[16:59:44] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[16:59:53] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[16:59:54] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:00:01] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:00:02] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:00:11] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[17:00:12] INFO     Embedding completed                                                                   pca.py:23

time: 1min 17s (started: 2023-06-30 16:59:41 -07:00)
Code
iclrnbrs = dof_nbrs("iclr-l2r")
[17:01:57] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[17:02:06] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[17:02:15] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
[17:02:24] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 39.9 s (started: 2023-06-30 17:01:56 -07:00)
Code
coil20nbrs = dof_nbrs("coil20")
[17:03:06] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 3 components                                                        yinit.py:228
[17:03:07] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 3 components                                                        yinit.py:228
[17:03:09] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
           INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 3 components                                                        yinit.py:228
[17:03:11] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
           INFO     Embedding completed                                                                   pca.py:23

time: 17.3 s (started: 2023-06-30 17:03:05 -07:00)
Code
cifar10nbrs = dof_nbrs("cifar10")
[17:04:08] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:04:14] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:04:56] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:05:02] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:05:46] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:05:51] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:06:33] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[17:06:37] INFO     Embedding completed                                                                   pca.py:23

time: 2min 57s (started: 2023-06-30 17:03:58 -07:00)
Code
norbnbrs = dof_nbrs("norb")
[17:08:56] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:09:11] INFO     Running LEOPOLD                                                                  leopold.py:209
[17:09:12] WARNING  UMAP graph has 2 components                                                        yinit.py:228
[17:09:46] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:10:02] INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 2 components                                                        yinit.py:228
[17:10:30] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[17:10:46] INFO     Running LEOPOLD                                                                  leopold.py:209
           WARNING  UMAP graph has 2 components                                                        yinit.py:228
[17:11:15] INFO     Embedding completed                                                              leopold.py:212
[17:11:16] INFO     Running PCA                                                                           pca.py:20
[17:11:32] INFO     Embedding completed                                                                   pca.py:23

time: 3min 40s (started: 2023-06-30 17:08:29 -07:00)
Code
mnistnbrs = dof_nbrs("mnist")
[21:27:07] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[21:27:08] INFO     Running LEOPOLD                                                                  leopold.py:209
[21:27:54] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[21:27:56] INFO     Running LEOPOLD                                                                  leopold.py:209
[21:28:34] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[21:28:36] INFO     Running LEOPOLD                                                                  leopold.py:209
[21:29:14] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[21:29:15] INFO     Embedding completed                                                                   pca.py:23

time: 2min 50s (started: 2023-06-30 21:27:02 -07:00)
Code
# nbrs=1
mnistnbrs = dof_nbrs("mnist")
[22:08:32] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Successfully loaded faiss with AVX2 support.                                       loader.py:56
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
[22:08:39] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:08:40] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:09:25] INFO     Embedding completed                                                              leopold.py:213
[22:09:26] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:09:27] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:10:04] INFO     Embedding completed                                                              leopold.py:213
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:10:06] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:10:44] INFO     Embedding completed                                                              leopold.py:213
           INFO     Running PCA                                                                           pca.py:20
[22:10:45] INFO     Embedding completed                                                                   pca.py:23

time: 2min 49s (started: 2023-06-30 22:08:32 -07:00)
Code
mnistnbrs.embed_plot("leo2")

time: 2.65 s (started: 2023-06-30 22:18:03 -07:00)
Code
# nnbrs=1
mnistnbrs = dof_nbrs("mnist")
[22:02:59] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
[22:03:00] INFO     Successfully loaded faiss with AVX2 support.                                       loader.py:56
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
[22:03:05] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:03:07] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:03:58] INFO     Embedding completed                                                              leopold.py:213
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:04:00] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:04:40] INFO     Embedding completed                                                              leopold.py:213
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[22:04:42] INFO     Running LEOPOLD                                                                  leopold.py:210
[22:05:24] INFO     Embedding completed                                                              leopold.py:213
           INFO     Running PCA                                                                           pca.py:20
[22:05:26] INFO     Embedding completed                                                                   pca.py:23

time: 3min 1s (started: 2023-06-30 22:02:59 -07:00)
Code
fashionnbrs = dof_nbrs("fashion")
[08:22:02] INFO     Loading faiss with AVX2 support.                                                   loader.py:54
           INFO     Successfully loaded faiss with AVX2 support.                                       loader.py:56
OMP: Info #276: omp_set_nested routine deprecated, please use omp_set_max_active_levels instead.
[08:22:08] INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[08:22:09] INFO     Running LEOPOLD                                                                  leopold.py:209
[08:23:07] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[08:23:09] INFO     Running LEOPOLD                                                                  leopold.py:209
[08:23:56] INFO     Embedding completed                                                              leopold.py:212
           INFO     No suitable pre-calculated neighbors available                                  __init__.py:325
           INFO     Using 'faiss' to find nearest neighbors                                          __init__.py:83
           INFO     Finding 16 neighbors using faiss with euclidean metric and params: {}            __init__.py:96
[08:23:58] INFO     Running LEOPOLD                                                                  leopold.py:209
[08:24:45] INFO     Embedding completed                                                              leopold.py:212
           INFO     Running PCA                                                                           pca.py:20
[08:24:47] INFO     Embedding completed                                                                   pca.py:23

time: 3min 17s (started: 2023-07-01 08:22:01 -07:00)