Stay organized with collections Save and categorize content based on your preferences.
The ML.MAX_ABS_SCALER function
This document describes the ML.MAX_ABS_SCALER function, which lets you scale a numerical expression to the range [-1, 1] by dividing with the maximum absolute value. It doesn't shift or center the data, and so doesn't destroy any sparsity.
When used in the TRANSFORM clause, the maximum absolute value calculated during training is automatically used in prediction.
Syntax
ML.MAX_ABS_SCALER(numerical_expression) OVER()
Arguments
ML.MAX_ABS_SCALER takes the following argument:
numerical_expression: the numerical expression to scale.
Output
ML.MAX_ABS_SCALER returns a FLOAT64 value that represents the scaled numerical expression.
Example
The following example scales a set of numerical expressions to have values between -1 and 1:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eML.MAX_ABS_SCALER\u003c/code\u003e function scales a numerical expression to the range \u003ccode\u003e[-1, 1]\u003c/code\u003e by dividing it by its maximum absolute value.\u003c/p\u003e\n"],["\u003cp\u003eThis function does not shift or center the data, preserving any sparsity present in the dataset.\u003c/p\u003e\n"],["\u003cp\u003eWhen used within the \u003ccode\u003eTRANSFORM\u003c/code\u003e clause, the maximum absolute value determined during the training phase is applied automatically during the prediction phase.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes a single numerical expression as an argument and returns a scaled \u003ccode\u003eFLOAT64\u003c/code\u003e value.\u003c/p\u003e\n"],["\u003cp\u003eIn practice, the function will adjust numbers to be between -1 and 1, with the maximum and minimum values of the input data mapped to those values, respectively.\u003c/p\u003e\n"]]],[],null,["# The ML.MAX_ABS_SCALER function\n==============================\n\nThis document describes the `ML.MAX_ABS_SCALER` function, which lets you\nscale a numerical expression to the range\n`[-1, 1]` by dividing with the maximum absolute value. It doesn't\nshift or center the data, and so doesn't destroy any sparsity.\n\nWhen used in the\n[`TRANSFORM` clause](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#transform),\nthe maximum absolute value calculated during training is automatically\nused in prediction.\n\nSyntax\n------\n\n```sql\nML.MAX_ABS_SCALER(numerical_expression) OVER()\n```\n\n### Arguments\n\n`ML.MAX_ABS_SCALER` takes the following argument:\n\n- `numerical_expression`: the [numerical](/bigquery/docs/reference/standard-sql/data-types#numeric_types) expression to scale.\n\nOutput\n------\n\n`ML.MAX_ABS_SCALER` returns a `FLOAT64` value that represents the scaled\nnumerical expression.\n\nExample\n-------\n\nThe following example scales a set of numerical expressions to have values\nbetween `-1` and `1`: \n\n```sql\nSELECT f, ML.MAX_ABS_SCALER(f) OVER () AS output\nFROM\n UNNEST([NULL, -3, 1, 2, 3, 4, 5]) AS f\nORDER BY f;\n```\n\nThe output looks similar to the following: \n\n```\n+------+--------+\n| f | output |\n+------+--------+\n| NULL | NULL |\n| -3 | -0.6 |\n| 1 | 0.2 |\n| 2 | 0.4 |\n| 3 | 0.6 |\n| 4 | 0.8 |\n| 5 | 1.0 |\n+------+--------+\n```\n\nWhat's next\n-----------\n\n- For information about feature preprocessing, see [Feature preprocessing overview](/bigquery/docs/preprocess-overview).\n- For information about the supported SQL statements and functions for each model type, see [End-to-end user journey for each model](/bigquery/docs/e2e-journey)."]]