Normalization

Normalization to the range 0..1

Normalization rescales a value so that it falls into a chosen range. One of the simplest and most common variants is scaling to the interval from 0 to 1.
This is useful when features live on very different scales. After such processing, age, number of purchases, and average check start to “weigh” approximately the same in feature space.

Example of code:

 
<?php

function normalize(float $valuefloat $minfloat $max): float {
    
$range $max $min;

    if (
$range === 0.0) {
        return 
0.0;
    }

    return (
$value $min) / $range;
}