The ML.POLYNOMIAL_EXPAND function

This document describes the ML.POLYNOMIAL_EXPAND function, which lets you calculate all polynomial combinations of the input features.

You can use this function with models that support manual feature preprocessing. For more information, see the following documents:

Syntax

ML.POLYNOMIAL_EXPAND(struct_numerical_features [, degree])

Arguments

ML.POLYNOMIAL_EXPAND takes the following arguments:

  • struct_numerical_features: a STRUCT value that contains the numerical input features to expand. You can specify less than or equal to 10 input features. Don't specify unnamed features or duplicate features.
  • degree: an INT64 value that specifies the highest degree of all combinations in the range of [1, 4]. The default value is 2.

Output

ML.POLYNOMIAL_EXPAND returns a STRUCT<STRING> value that contain all polynomial combinations of the numerical input features with a degree no larger than the passed-in degree, including the original features. The field names of the output struct are concatenations of the original feature names.

Example

The following example calculates the polynomial expansion of two numerical features:

SELECT
ML.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 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月24日 UTC.