The ML.MAX_ABS_SCALER function
This document describes theML.MAX_ABS_SCALER function, which lets youscale a numerical expression to the range[-1, 1] by dividing with the maximum absolute value. It doesn'tshift or center the data, and so doesn't destroy any sparsity.
When used in theTRANSFORM clause,the maximum absolute value calculated during training is automaticallyused in prediction.
You can use this function with models that supportmanual feature preprocessing. For moreinformation, see the following documents:
Syntax
ML.MAX_ABS_SCALER(numerical_expression) OVER()
Arguments
ML.MAX_ABS_SCALER takes the following argument:
numerical_expression: thenumericalexpression to scale.
Output
ML.MAX_ABS_SCALER returns aFLOAT64 value that represents the scalednumerical expression.
Example
The following example scales a set of numerical expressions to have valuesbetween-1 and1:
SELECTf,ML.MAX_ABS_SCALER(f)OVER()ASoutputFROMUNNEST([NULL,-3,1,2,3,4,5])ASfORDERBYf;
The output looks similar to the following:
+------+--------+| f | output |+------+--------+| NULL | NULL || -3 | -0.6 || 1 | 0.2 || 2 | 0.4 || 3 | 0.6 || 4 | 0.8 || 5 | 1.0 |+------+--------+
What's next
- For information about feature preprocessing, seeFeature preprocessing overview.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.