The ML.MIN_MAX_SCALER function

This document describes theML.MIN_MAX_SCALER function, which lets you scalea numerical_expression to the range[0, 1]. Negative values are set to0,and values above1 are set to1.

When used in theTRANSFORM clause,the range of[0,1] is automatically used in prediction, and predictedvalues outside that range are similarly capped.

You can use this function with models that supportmanual feature preprocessing. For moreinformation, see the following documents:

Syntax

ML.MIN_MAX_SCALER(numerical_expression) OVER()

Arguments

ML.MIN_MAX_SCALER takes the following argument:

  • numerical_expression: thenumericalexpression to scale.

Output

ML.MIN_MAX_SCALER returns aFLOAT64 value that represents the scalednumerical expression.

Example

The following example scales a set of numerical expressions to values between0 and1:

SELECTf,ML.MIN_MAX_SCALER(f)OVER()ASoutputFROMUNNEST([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 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-11-24 UTC.