Stay organized with collectionsSave and categorize content based on your preferences.
The ML.MIN_MAX_SCALER function
This document describes theML.MIN_MAX_SCALERfunction, which lets you scale
a numerical_expression to the range[0, 1]. Negative values are set to0,
and values above1are set to1.
When used in theTRANSFORMclause,
the range of[0,1]is automatically used in prediction, and predicted
values outside that range are similarly capped.
You can use this function with models that supportmanual feature preprocessing. For more
information, see the following documents:
[[["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-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eML.MIN_MAX_SCALER\u003c/code\u003e function scales a numerical expression to a range between \u003ccode\u003e0\u003c/code\u003e and \u003ccode\u003e1\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eValues outside the \u003ccode\u003e[0, 1]\u003c/code\u003e range are capped, with negative values becoming \u003ccode\u003e0\u003c/code\u003e and values above \u003ccode\u003e1\u003c/code\u003e becoming \u003ccode\u003e1\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eWhen used within a \u003ccode\u003eTRANSFORM\u003c/code\u003e clause, the scaling and capping of the range \u003ccode\u003e[0,1]\u003c/code\u003e is applied during prediction.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eML.MIN_MAX_SCALER\u003c/code\u003e function takes one argument, a numerical expression to scale, and returns a \u003ccode\u003eFLOAT64\u003c/code\u003e value.\u003c/p\u003e\n"]]],[],null,["# The ML.MIN_MAX_SCALER function\n==============================\n\nThis document describes the `ML.MIN_MAX_SCALER` function, which lets you scale\na numerical_expression to the range `[0, 1]`. Negative values are set to `0`,\nand values above `1` are set to `1`.\n\nWhen used in the\n[`TRANSFORM` clause](/bigquery/docs/reference/standard-sql/bigqueryml-syntax-create#transform),\nthe range of `[0,1]` is automatically used in prediction, and predicted\nvalues outside that range are similarly capped.\n\nSyntax\n------\n\n```sql\nML.MIN_MAX_SCALER(numerical_expression) OVER()\n```\n\n### Arguments\n\n`ML.MIN_MAX_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.MIN_MAX_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 values between\n`0` and `1`: \n\n```sql\nSELECT\n f, ML.MIN_MAX_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| 4 | 0.75 |\n| 2 | 0.25 |\n| 1 | 0.0 |\n| 3 | 0.5 |\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)."]]