The ML.FEATURE_IMPORTANCE function
This document describes theML.FEATURE_IMPORTANCE function, which lets yousee the feature importance score. This score indicates how useful or valuableeach feature was in the construction of a boosted tree or a random forest modelduring training. For more information, see thefeature_importances propertyin the XGBoost library.
Syntax
ML.FEATURE_IMPORTANCE( MODEL `PROJECT_ID.DATASET.MODEL`)
Arguments
ML.FEATURE_IMPORTANCE takes the following arguments:
PROJECT_ID: your project ID.DATASET: the BigQuery dataset that containsthe model.MODEL: the name of the model.
Output
ML.FEATURE_IMPORTANCE returns the following columns:
feature: aSTRINGvalue that contains the name of the feature columnin the input training data.importance_weight: aFLOAT64value that contains the number of times afeature is used to split the data across all trees.importance_gain: aFLOAT64value that contains the average gain across allsplits the feature is used in.importance_cover: aFLOAT64value that contains the average coverageacross all splits the feature is used in.
If theTRANSFORM clausewas used in theCREATE MODEL statement that created the model,ML.FEATURE_IMPORTANCE returns the information of the pre-transform columnsfrom thequery_statement clause of theCREATE MODEL statement.
Permissions
You must have thebigquery.models.create andbigquery.models.getDataIdentity and Access Management (IAM) permissionsin order to runML.FEATURE_IMPORTANCE.
Limitations
ML.FEATURE_IMPORTANCE is only supported withboosted tree modelsandrandom forest models.
Example
This example retrieves feature importance frommymodel inmydataset. The dataset is in your default project.
SELECT*FROMML.FEATURE_IMPORTANCE(MODEL`mydataset.mymodel`)
What's next
- For more 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-12-15 UTC.