Commander MirzaBefore we run the deep scan, I want all sensor data normalized. We can't have one sensor's scale drowning out another — each data source must contribute equally.
Dr. FarahJust like CSS resets create a consistent baseline for styling, normalization creates a consistent baseline for data. Without it, the analysis system will be biased toward sensors with larger numerical ranges.
* { margin: 0; padding: 0; box-sizing: border-box; }const normalized = data.sub(mean).div(std)Every frontend developer knows CSS resets. Without them, browsers apply inconsistent default styles. Normalization is the data equivalent — without it, features with large values (like pixel counts in the thousands) dominate features with small values (like percentages from 0-1).
import * as tf from '@tensorflow/tfjs';
// Sensor data: temperature (°C) and signal strength (dB)
const temperature = tf.tensor([20, 22, 19, 35, 28]); // range: 19-35
const signal = tf.tensor([0.1, 0.8, 0.3, 0.9, 0.5]); // range: 0.1-0.9
// Without normalization, temperature dominates (values 20-35 vs 0.1-0.9)
// Z-score normalization: center at 0, spread to ~1
function zNormalize(tensor: tf.Tensor) {
const mean = tensor.mean();
const std = tensor.std(); // standard deviation
return tensor.sub(mean).div(std);
}
const tempNorm = zNormalize(temperature);
// [-0.65, -0.26, -0.85, 1.27, 0.49] — centered around 0
const signalNorm = zNormalize(signal);
// [-1.06, 0.88, -0.50, 1.16, -0.22] — same scale!
// Min-max normalization: squeeze to [0, 1] range
function minMaxNormalize(tensor: tf.Tensor) {
const min = tensor.min();
const max = tensor.max();
return tensor.sub(min).div(max.sub(min));
}
const tempMinMax = minMaxNormalize(temperature);
// [0.06, 0.19, 0.0, 1.0, 0.56] — all between 0 and 1Z-score (mean=0, std=1): Use when you need to preserve the spread of your data. Most common for neural network inputs.
Min-max (range 0-1): Use when you need bounded values, like pixel data or probabilities.
Think of it like choosing between normalize.css and a full reset — each has its place depending on what consistency you need.
Normalize the Archimedes sensor data using z-score normalization.
Apply z-score normalization to a tensor of sensor readings.
const data = tf.tensor([10, 20, 30, 40, 50]); const normalized = null; // apply z-score normalization
Module complete. The foundations are in place for the deep space signal classifier.