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:
[[["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-08-25 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eML.POLYNOMIAL_EXPAND\u003c/code\u003e function calculates all polynomial combinations of numerical input features.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts a \u003ccode\u003eSTRUCT\u003c/code\u003e of numerical features (up to 10) and an optional \u003ccode\u003edegree\u003c/code\u003e parameter between 1 and 4, defaulting to 2.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a \u003ccode\u003eSTRUCT<STRING>\u003c/code\u003e containing all polynomial combinations up to the specified degree, including the original features.\u003c/p\u003e\n"],["\u003cp\u003eThe function requires numerical values and will return a string representing the calculations done.\u003c/p\u003e\n"],["\u003cp\u003eThe output struct's field names are formed by concatenating the original feature names.\u003c/p\u003e\n"]]],[],null,["# The ML.POLYNOMIAL_EXPAND function\n=================================\n\nThis document describes the `ML.POLYNOMIAL_EXPAND` function, which lets you\ncalculate all polynomial combinations of the input features.\n\nSyntax\n------\n\n```sql\nML.POLYNOMIAL_EXPAND(struct_numerical_features [, degree])\n```\n\n### Arguments\n\n`ML.POLYNOMIAL_EXPAND` takes the following arguments:\n\n- `struct_numerical_features`: a `STRUCT` value that contains the [numerical](/bigquery/docs/reference/standard-sql/data-types#numeric_types) input features to expand. You can specify less than or equal to `10` input features. Don't specify unnamed features or duplicate features.\n- `degree`: an `INT64` value that specifies the highest degree of all combinations in the range of `[1, 4]`. The default value is `2`.\n\nOutput\n------\n\n`ML.POLYNOMIAL_EXPAND` returns a `STRUCT\u003cSTRING\u003e` value that contain all\npolynomial combinations of the numerical input features with a degree no larger\nthan the passed-in degree, including the original features. The field names of\nthe output struct are concatenations of the original feature names.\n\nExample\n-------\n\nThe following example calculates the polynomial expansion of two\nnumerical features: \n\n```sql\nSELECT\n ML.POLYNOMIAL_EXPAND(STRUCT(2 AS f1, 3 AS f2)) AS output;\n```\n\nThe output looks similar to the following: \n\n```\n+-------------------------------------------------------------------+\n| output |\n+-------------------------------------------------------------------+\n| {\"f1\":\"2.0\",\"f1_f1\":\"4.0\",\"f1_f2\":\"6.0\",\"f2\":\"3.0\",\"f2_f2\":\"9.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)."]]