ML.FEATURE_IMPORTANCE function allows you to see feature importance score,
which indicates how useful or valuable each feature was in the construction of
the Boosted Tree model during training. See information about feature importance in the XGBoost library.
ML.FEATURE_IMPORTANCE returns the following columns:
feature: The name of the feature column in the input training data.
importance_weight: The number of times a feature is used to split the data across all trees.
importance_gain: The average gain across all splits the feature is used in.
importance_cover: The average coverage across all splits the feature is used in.
clause is present in the
CREATE MODEL statement that creates
ML.FEATURE_IMPORTANCE outputs the information of the pre-transform columns from
You need both
bigquery.models.getData to run
project_idis your project ID.
datasetis the BigQuery dataset that contains the model.
modelis the name of the model.
The following example retrieves feature importance from
mydataset. The dataset is in your default project.
SELECT * FROM ML.FEATURE_IMPORTANCE(MODEL `mydataset.mymodel`)
ML.FEATURE_IMPORTANCE function is subject to the following limitations:
ML.FEATURE_IMPORTANCEis only supported with Boosted Tree models.