The ML.GLOBAL_EXPLAIN function
This document describes theML.GLOBAL_EXPLAIN function, which lets you provideexplanations for the entire model by aggregating the local explanations of the evaluation data. You can only useML.GLOBAL_EXPLAIN with models that are trained with theENABLE_GLOBAL_EXPLAIN optionset toTRUE.
Syntax
ML.GLOBAL_EXPLAIN( MODEL `PROJECT_ID.DATASET.MODEL`, STRUCT( [CLASS_LEVEL_EXPLAIN AS class_level_explain]))
Arguments
ML.GLOBAL_EXPLAIN takes the following arguments:
PROJECT_ID: your project ID.DATASET: the BigQuery dataset that containsthe model.MODEL: the name of the model.CLASS_LEVEL_EXPLAIN: aBOOLvalue that specifieswhether global feature importances are returned for each class. Applies onlyto non-AutoML Tables classification models. When set toFALSE, the globalfeature importance of the entire model is returned rather than that of eachclass. The default value isFALSE.Regression models and AutoML Tables classification models only havemodel-level global feature importance.
Output
The output ofML.GLOBAL_EXPLAIN has two formats:
For classification models with
class_level_explainsettoFALSE, and for regression models, the following columns are returned:feature: aSTRINGvalue that contains the feature name.attribution: aFLOAT64value that contains the feature importance tothe model overall.
For classification models with
class_level_explainset toTRUE,the following columns are returned:<class_name>: aSTRINGvalue that contains the name of the class in thelabel column.feature: aSTRINGvalue that contains the feature name.attribution: aFLOAT64value that contains the feature importance tothis class.
For each class, only the top 10 most important features are returned.
Examples
The following examples assume your model is in your default project.
Regression model
This example gets global feature importance for the boosted tree regressionmodelmymodel inmydataset. The dataset is in your default project.
SELECT*FROMML.GLOBAL_EXPLAIN(MODEL`mydataset.mymodel`)
Classifier model
This example gets global feature importance for the boosted tree classifiermodelmymodel inmydataset. The dataset is in your default project.
SELECT*FROMML.GLOBAL_EXPLAIN(MODEL`mydataset.mymodel`,STRUCT(TRUEASclass_level_explain))
What's next
- For information about Explainable AI, seeBigQuery Explainable AI overview.
- For more information about supported SQL statements and functions for MLmodels, seeEnd-to-end user journeys for ML models.
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-11-24 UTC.