Stay organized with collections
Save and categorize content based on your preferences.
The ML.STANDARD_SCALER function
This document describes the ML.STANDARD_SCALER function, which lets you scale
a numerical expression by using
z-score.
When used in the
TRANSFORM clause,
the standard deviation and
mean values calculated to standardize the
expression are automatically used in prediction.
Syntax
ML.STANDARD_SCALER(numerical_expression) OVER()
Arguments
ML.STANDARD_SCALER takes the following argument:
numerical_expression: the
numerical
expression to scale.
Output
ML.STANDARD_SCALER returns a FLOAT64 value that represents the scaled
numerical expression.
Example
The following example scales a set of numerical expressions to have a
mean of 0 and standard deviation of 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\u003e\u003ccode\u003eML.STANDARD_SCALER\u003c/code\u003e scales a numerical expression using the z-score method.\u003c/p\u003e\n"],["\u003cp\u003eWhen used in the \u003ccode\u003eTRANSFORM\u003c/code\u003e clause, the calculated standard deviation and mean are automatically used in prediction.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes a single argument, \u003ccode\u003enumerical_expression\u003c/code\u003e, which is the numerical data to be scaled.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eML.STANDARD_SCALER\u003c/code\u003e outputs a \u003ccode\u003eFLOAT64\u003c/code\u003e value that represents the scaled numerical expression, resulting in a mean of 0 and a standard deviation of 1.\u003c/p\u003e\n"],["\u003cp\u003eThere is a provided example of how to use the function and the output it produces.\u003c/p\u003e\n"]]],[],null,["# The ML.STANDARD_SCALER function\n===============================\n\nThis document describes the `ML.STANDARD_SCALER` function, which lets you scale\na numerical expression by using\n[z-score](https://developers.google.com/machine-learning/data-prep/transform/normalization#z-score).\n\nWhen used in the\n[`TRANSFORM` clause](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#transform),\nthe [standard deviation](https://en.wikipedia.org/wiki/Standard_deviation) and\n[mean](https://en.wikipedia.org/wiki/Mean) values calculated to standardize the\nexpression are automatically used in prediction.\n\nSyntax\n------\n\n```sql\nML.STANDARD_SCALER(numerical_expression) OVER()\n```\n\n### Arguments\n\n`ML.STANDARD_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.STANDARD_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 a\nmean of `0` and standard deviation of `1`: \n\n```sql\nSELECT\n f, ML.STANDARD_SCALER(f) OVER() AS output\nFROM\n UNNEST([1,2,3,4,5]) AS f;\n```\n\nThe output looks similar to the following: \n\n```\n+---+---------------------+\n| f | output |\n+---+---------------------+\n| 1 | -1.2649110640673518 |\n| 5 | 1.2649110640673518 |\n| 2 | -0.6324555320336759 |\n| 4 | 0.6324555320336759 |\n| 3 | 0.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)."]]