## 标准化 > 归一化是将单个样本缩放为具有单位范数的过程。 ## L2 norm [http://mathworld.wolfram.com/L2-Norm.html](http://mathworld.wolfram.com/L2-Norm.html) ### 例: ``` use Phpml\Preprocessing\Normalizer; $samples = [ [1, -1, 2], [2, 0, 0], [0, 1, -1], ]; $normalizer = new Normalizer(); $normalizer->preprocess($samples); /* $samples = [ [0.4, -0.4, 0.81], [1.0, 0.0, 0.0], [0.0, 0.7, -0.7], ]; */ ``` ***** ## L1 norm [http://mathworld.wolfram.com/L1-Norm.html](http://mathworld.wolfram.com/L1-Norm.html) ### 例: ``` use Phpml\Preprocessing\Normalizer; $samples = [ [1, -1, 2], [2, 0, 0], [0, 1, -1], ]; $normalizer = new Normalizer(Normalizer::NORM_L1); $normalizer->preprocess($samples); /* $samples = [ [0.25, -0.25, 0.5], [1.0, 0.0, 0.0], [0.0, 0.5, -0.5], ]; */ ```