The ML.MIN_MAX_SCALER function

This document describes the ML.MIN_MAX_SCALER function, which lets you scale a numerical_expression to the range [0, 1]. Negative values are set to 0, and values above 1 are set to 1.

When used in the TRANSFORM clause, 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 support manual feature preprocessing. For more information, see the following documents:

Syntax

ML.MIN_MAX_SCALER(numerical_expression) OVER()

Arguments

ML.MIN_MAX_SCALER takes the following argument:

  • numerical_expression: the numerical expression to scale.

Output

ML.MIN_MAX_SCALER returns a FLOAT64 value that represents the scaled numerical expression.

Example

The following example scales a set of numerical expressions to values between 0 and 1:

SELECT
f,ML.MIN_MAX_SCALER(f)OVER()ASoutput
FROM
UNNEST([1,2,3,4,5])ASf;

The output looks similar to the following:

+---+--------+
| f | output |
+---+--------+
| 4 | 0.75 |
| 2 | 0.25 |
| 1 | 0.0 |
| 3 | 0.5 |
| 5 | 1.0 |
+---+--------+

What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月16日 UTC.