The ML.FEATURE_CROSS function
This document describes theML.FEATURE_CROSS function, which lets you createfeature crosses.
You can use this function with models that supportmanual feature preprocessing. For moreinformation, see the following documents:
Syntax
ML.FEATURE_CROSS(struct_categorical_features [, degree])
Arguments
ML.FEATURE_CROSS takes the following arguments:
struct_categorical_features: aSTRUCT<STRING>value that specifiesthe categorical features to cross. The maximum number of input features is 10.Don't specify unnamed features or duplicate features instruct_numerical_features.degree: anINT64value that specifies the highest degree of allcombinations of features in the range of[2, 4]. The default value is2.
Output
ML.FEATURE_CROSS returns aSTRUCT<STRING> value that identifies allcombinations of the crossed categorical features with a degree no larger thanthedegree value, except for 1-degree items (the original features) andself-crossing items. The field names in the output struct are concatenationsof the original feature names.
Example
The following example crosses three features:
SELECTML.FEATURE_CROSS(STRUCT('a'ASf1,'b'ASf2,'c'ASf3))ASoutput;
The output looks similar to the following:
+---------------------------------------------+| output |+---------------------------------------------+| {"f1_f2":"a_b","f1_f3":"a_c","f2_f3":"b_c"} |+---------------------------------------------+What's next
- For information about feature preprocessing, seeFeature preprocessing overview.
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.