Normalisation (ML)

up:: Machine Learning

It is best practice to normalise the data before giving it to a model.

Many machine learning models are optimised to work with small numbers. Common ranges are 0 to 1 or -1 to 1.

Example in TensorflowJS

//Step 3. Normalize the data to the range 0 - 1 using min-max scaling
const inputMax = inputTensor.max();
const inputMin = inputTensor.min();
const labelMax = labelTensor.max();
const labelMin = labelTensor.min();
 
const normalizedInputs = inputTensor.sub(inputMin).div(inputMax.sub(inputMin));
const normalizedLabels = labelTensor.sub(labelMin).div(labelMax.sub(labelMin));