NelworksNelworks

ML & AI / Season 1 / EP03

UMAP: Still Have To Be Smart With Compressing

Shez

It's full of stars!

Kurumi

(Typing on a physical keyboard nearby) You're drooling on the headset.

Shez

I ditched PCA. I ditched the Linear Algebra dinosaurs.

Shez

I found the God Algorithm. **UMAP**.

Shez

It handles non-linearity! It unfolds the Swiss Roll! It respects the local geometry!

Shez

And best of all, it's topology! I didn't have to worry about the "Unit Problem."

Kurumi

"Topology doesn't care about units?"

Kurumi

You are absolutely wrong.

Kurumi

Shez, how does UMAP build this beautiful graph?

Shez

It... finds the nearest neighbors for each point... and then connects them with fuzzy edges... and...

Kurumi

Stop. You said *finds the nearest neighbors.*

Kurumi

How does it measure *Nearest*?

Shez

Uh... distance?

Kurumi

Which distance?

Shez

The... default distance?

Kurumi

Euclidean Distance. The Pythagorean Theorem. $a^2 + b^2 = c^2$.

Kurumi

To UMAP, Point A is **1000 times closer** to Point B than Point C.

Kurumi

The algorithm thinks the Voltage Spike is "The Same State," but the tiny movement is "Far Away."

Shez

So... the neighbors...

Kurumi

The neighbors are determined entirely by the variable with the biggest numbers.

Kurumi

You haven't escaped the Unit Problem. You just hid it inside the Neighbor Search.

Shez

But UMAP has local scaling! The $\sigma$ value! It adapts to the density!

Kurumi

It adapts to the *density* of the neighbors it found.

Kurumi

But if it found the *wrong* neighbors because your units were messed up, it's just adapting to garbage.

Kurumi

UMAP is like a camera that focuses automatically.

Kurumi

But if you leave the lens cap on (Wrong Units), it just focuses perfectly on the back of the lens cap.

Kurumi

Look at your "Islands."

Kurumi

Island 1 is "High Meters." Island 2 is "Low Meters."

Kurumi

Where is the Voltage info?

Shez

The voltage... is lost. It was treated as noise because it was too small.

Shez

Okay. So I *still* have to normalize? `StandardScaler`?

Kurumi

Yes. You always have to normalize if your units are different. There is no "God Algorithm" that fixes bad physics.

Shez

Fine. `StandardScaler`. Then UMAP.

Shez

*Click.*

Shez

Okay, this looks better.

Shez

Let me run it again just to be sure.

Shez

*Click.*

Shez

What?!

Shez

It changed shape! Why did it change shape?! Now I can't find ID_420!

Kurumi

Welcome to **Stochasticity**.

Kurumi

PCA is Linear Algebra. It solves for Eigenvectors. It is the same every time.

Kurumi

UMAP is an Optimization Process. It uses random initialization and stochastic gradient descent.

Shez

But... which shape is the truth? The Wishbone or the Donut?

Kurumi

Neither. Or both.

Kurumi

They are just 2D shadows of a high-dimensional object. The "Global Structure" in UMAP is not guaranteed to be preserved.

Kurumi

**Global Structure vs. Local Structure.**

Kurumi

UMAP cares about *Neighbors*. It will tear the global map apart to keep neighbors together.

Kurumi

Imagine the Earth.

Kurumi

PCA tries to flatten it like a Mercator projection. It preserves the general "North is Up."

Kurumi

UMAP ensures that New York is next to New Jersey.

Kurumi

But it might put the USA next to China just because they fit together nicely on the table.

Shez

So I can trust that the points *in this cluster* are similar...

Kurumi

Yes.

Shez

But I can't trust that Cluster A is close to Cluster B?

Kurumi

Exactly. The distance *between* clusters is often meaningless in UMAP.

Shez

This "God Algorithm" has a lot of fine print.

Kurumi

It's a tool for **Visualization**, not for rigorous engineering.

Shez

So what do I do? I need to use this data for the robot's navigation! I can't feed it a stochastic donut!

Kurumi

If you need features for a model: Use **Autoencoders** (or PCA). They are parametric functions. They are stable.

Kurumi

If you need to make a pretty chart for the CEO: Use UMAP.

Kurumi

And if you *must* use UMAP for analysis... change the metric.

Shez

Change it from Euclidean?

Kurumi

Mahalanobis distance. It accounts for the variance and covariance of the data.

Kurumi

It essentially "learns" the units for you.

Shez

It looks like a robot leg now.

Kurumi

Because you used a metric that understands how the variables relate to each other.

Kurumi

Don't be seduced by the "Manifold Learning". At the bottom of every fancy algorithm is a simple function calculating `Distance(A, B)`.

Kurumi

If you feed that function garbage units, it will build you a garbage castle.