struct_categorical_features: a STRUCT<STRING> value that specifies
the categorical features to cross. The maximum number of input features is 10.
Don't specify unnamed features or duplicate features in
struct_numerical_features.
degree: an INT64 value that specifies the highest degree of all
combinations of features in the range of [2, 4]. The default value is 2.
Output
ML.FEATURE_CROSS returns a STRUCT<STRING> value that identifies all
combinations of the crossed categorical features with a degree no larger than
the degree value, except for 1-degree items (the original features) and
self-crossing items. The field names in the output struct are concatenations
of the original feature names.
[[["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\u003e\u003ccode\u003eML.FEATURE_CROSS\u003c/code\u003e is a function that creates feature crosses from input features for machine learning models.\u003c/p\u003e\n"],["\u003cp\u003eThe function accepts a \u003ccode\u003eSTRUCT<STRING>\u003c/code\u003e of categorical features as input, with a maximum of 10 features allowed.\u003c/p\u003e\n"],["\u003cp\u003eAn optional \u003ccode\u003edegree\u003c/code\u003e argument can be specified to control the highest degree of feature combinations, within the range of 2 to 4.\u003c/p\u003e\n"],["\u003cp\u003eThe output is a \u003ccode\u003eSTRUCT<STRING>\u003c/code\u003e that lists all crossed feature combinations, excluding single features and self-crosses, up to the specified degree.\u003c/p\u003e\n"],["\u003cp\u003eFeature preprocessing and supported SQL statements are referenced in related documents for more information.\u003c/p\u003e\n"]]],[],null,["# The ML.FEATURE_CROSS function\n=============================\n\nThis document describes the `ML.FEATURE_CROSS` function, which lets you\ncreate [feature crosses](https://developers.google.com/machine-learning/crash-course/feature-crosses/video-lecture) of the input features.\n\nSyntax\n------\n\n```sql\nML.FEATURE_CROSS(struct_categorical_features [, degree])\n```\n\n### Arguments\n\n`ML.FEATURE_CROSS` takes the following arguments:\n\n- `struct_categorical_features`: a `STRUCT\u003cSTRING\u003e` value that specifies the categorical features to cross. The maximum number of input features is 10. Don't specify unnamed features or duplicate features in `struct_numerical_features`.\n- `degree`: an `INT64` value that specifies the highest degree of all combinations of features in the range of `[2, 4]`. The default value is `2`.\n\nOutput\n------\n\n`ML.FEATURE_CROSS` returns a `STRUCT\u003cSTRING\u003e` value that identifies all\ncombinations of the crossed categorical features with a degree no larger than\nthe `degree` value, except for 1-degree items (the original features) and\nself-crossing items. The field names in the output struct are concatenations\nof the original feature names.\n\nExample\n-------\n\nThe following example crosses three features: \n\n```sql\nSELECT\n ML.FEATURE_CROSS(STRUCT('a' AS f1, 'b' AS f2, 'c' AS f3)) AS output;\n```\n\nThe output looks similar to the following: \n\n```\n+---------------------------------------------+\n| output |\n+---------------------------------------------+\n| {\"f1_f2\":\"a_b\",\"f1_f3\":\"a_c\",\"f2_f3\":\"b_c\"} |\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)."]]