The ML.POLYNOMIAL_EXPAND function

This document describes theML.POLYNOMIAL_EXPAND function, which lets youcalculate all polynomial combinations of the input features.

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

Syntax

ML.POLYNOMIAL_EXPAND(struct_numerical_features [, degree])

Arguments

ML.POLYNOMIAL_EXPAND takes the following arguments:

  • struct_numerical_features: aSTRUCT value that contains thenumericalinput features to expand. You can specify less than or equal to10input features. Don't specify unnamed features or duplicate features.
  • degree: anINT64 value that specifies the highest degree ofall combinations in the range of[1, 4]. The default value is2.

Output

ML.POLYNOMIAL_EXPAND returns aSTRUCT<STRING> value that contain allpolynomial combinations of the numerical input features with a degree no largerthan the passed-in degree, including the original features. The field names ofthe output struct are concatenations of the original feature names.

Example

The following example calculates the polynomial expansion of twonumerical features:

SELECTML.POLYNOMIAL_EXPAND(STRUCT(2ASf1,3ASf2))ASoutput;

The output looks similar to the following:

+-------------------------------------------------------------------+|                              output                               |+-------------------------------------------------------------------+| {"f1":"2.0","f1_f1":"4.0","f1_f2":"6.0","f2":"3.0","f2_f2":"9.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-12-15 UTC.