NelworksNelworks

ML & AI / Season 1 / EP02

PCA (Principal Component Analysis) on Mixed-Unit Data

Shez

HAHAHA! Telemetry is fused! I've compressed the sensor data from 500 inputs down to 3 Principal Components!

Kurumi

(Tightening a bolt on the mech's knee) Yeah? Tell me more.

Shez

The mech has lasers, hydraulics, temperature sensors, and radiation detectors. That's too much data for the CPU. So I ran **PCA** to find the "Essence of Motion."

Shez

Look at this beautiful cluster! PC1 explains 95% of the variance. The robot knows exactly what it's doing.

Kurumi

PC1 explains 95% of the variance? Now that's sus...

Kurumi

Shez, what are the units of your sensors?

Shez

Uh... Velocity is in $m/s$... Pressure is in Pascals... Temperature in Kelvin...

Kurumi

Pressure in Pascals. Velocity in meters per second.

Kurumi

Atmospheric pressure is around 100,000 Pascals.

Kurumi

Walking speed is around 1.5 $m/s$.

Kurumi

PCA looks for **Variance**.

Kurumi

The variance of the Pressure sensor is in the billions. The variance of the Velocity sensor is like... 0.5.

Kurumi

To PCA, your Velocity sensor looks like a flat line. It looks like "Noise."

Kurumi

Your "Principal Component 1" isn't the "Essence of Motion." It's probably just **Atmospheric Pressure**.

Shez

Oh. It... it basically ignored the movement.

Shez

So my robot is just standing there thinking about how heavy the air is?

Shez

Easy fix! I'll change the units!

Shez

I'll measure Pressure in "MegaPascals" (0.1 MPa) and Velocity in "Millimeters per second" (1500 mm/s).

Kurumi

Stop! Stop! You are playing **God with Geometry**.

Kurumi

When you change units, you stretch and squash the data cloud.

Kurumi

If you use Millimeters, the cloud stretches 1000x in the X-axis. PCA points the arrow that way.

Kurumi

If you use Kilometers, the cloud squashes. PCA points the arrow somewhere else.

Kurumi

A physical law ($F=ma$) doesn't change if you measure in feet or meters.

Kurumi

But your PCA model changes completely. That means your model has no **Physical Integrity**.

Kurumi

It gets worse. What *is* a Principal Component?

Shez

Umm, it's a linear combination of features...

Kurumi

Let's say $w_1 = 0.5$ and $w_2 = 0.5$.

Kurumi

What is $0.5 \text{Kelvin} + 0.5 \text{Volts}$?

Shez

It's... Volvin? Kelvolts?

Kurumi

It's **Nonsense**. Physics forbids adding different units. You can multiply them ($Volts \times Amps = Watts$), but you cannot add them.

Kurumi

Your robot is making decisions based on a variable that physically does not exist. You are feeding it **Unit Salad**.

Shez

So I can't use PCA? I have to feed 500 raw inputs into the neural net? The latency will kill us!

Kurumi

You can use PCA. But you have to strip the units first.

Shez

Strip them?

Kurumi

You normalize every feature.

Kurumi

Subtract the mean. Divide by the standard deviation.

Kurumi

Now, Pressure has variance = 1. Velocity has variance = 1.

Kurumi

They are **Dimensionless**.

Shez

`scaler.fit_transform(X)`.

Shez

Okay, now they are equal. PCA will look at *correlation*, not magnitude. Now PC1 is valid!

Kurumi

Careful.

Kurumi

You solved the **Math** problem. You haven't solved the **Noise** problem.

Kurumi

This sensor is broken. It just outputs random static between 0.0001 and 0.0002.

Shez

It's tiny. Who cares?

Kurumi

You just ran `StandardScaler`.

Kurumi

You took that tiny 0.0001 static... and stretched it to have Variance = 1.

Kurumi

You just made the broken sensor as loud as the main engine.

Shez

PC1 is... now mostly the vibration sensor...

Shez

I amplified the noise. I turned a static into a rock concert...

Kurumi

This is the trade-off.

Kurumi

**Raw PCA:** Biased by Unit Scale.

Kurumi

**Scaled PCA:** Biased by Noise Amplification.

Shez

Ahhh, there is no winning!

Kurumi

There is winning. It's called **Engineering Judgment**.

Kurumi

Don't just blindly scale everything.

Kurumi

Remove the broken sensors first. Use Log-transforms on the Pressure.

Kurumi

Or... don't use PCA. Use something that respects local geometry, like UMAP, or a Variational Autoencoder (VAE).

Kurumi

But if you must use Linear Algebra...

Shez

1. Filter noise.

Shez

2. Log-transform large magnitudes.

Shez

3. StandardScaler.

Shez

4. PCA.

Shez

It actually makes sense. The clusters map to actions!

Kurumi

Now the latent space represents **Behavior**, not just **Unit Bias**.

Shez

It works! It's walking!

Kurumi

And it's not trying to add Volts to Meters anymore.

Shez

You know, "Kelvolts" kind of sounded cool. Like a superhero name.

Kurumi

"Kelvolt" sounds like a battery that overheats and explodes.