Mathematical Intuition

Unfortunately, there's a big flaw in the linear projection trick.

Video


Code

Although this video is mainly a visual exploration, we've added the python code to generate the pretty 3d-charts.

import numpy as np
import matplotlib.pyplot as plt
from sklearn.datasets import make_blobs
X, y = make_blobs(600, 3, cluster_std=2, random_state=41)
plt.figure(figsize=(7, 7))
ax = plt.axes(projection='3d')
ax.scatter3D(X[:, 0], X[:, 1], X[:, 2], c=X[:, 2], cmap='Greens');

We can now use whatlies to make a projection.

from whatlies import EmbeddingSet, Embedding
embset = EmbeddingSet(*[Embedding(str(i), x) for i, x in enumerate(X)])
emb_away = Embedding("away", [0, 0, 1])
X_new = embset | emb_away
X_away = X_new.to_X()
plt.figure(figsize=(7, 7))
ax = plt.axes(projection='3d')
ax.scatter3D(X_away[:, 0], X_away[:, 1], X_away[:, 2], c=X[:, 2], cmap='Purples')
ax.scatter3D(X[:, 0], X[:, 1], X[:, 2], c=X[:, 2], cmap='Greens');

2016-2022 © Rasa.