Prepare and test your skills
Prepare and test your skills
Evaluate Fairness Metrics and Sliced Performance is the practice of measuring whether a model behaves consistently across protected groups instead of judging it by a single overall score. A model can show strong aggregate accuracy while performing poorly for a specific race, gender, class, or other sensitive slice. In Google Cloud, this work connects data validation, Vertex AI Model Evaluation (opens in a new tab) as a pipeline component, explainability, and continuous production monitoring with governance in Model Registry (opens in a new tab).
Data bias and model bias indicators are evaluation signals that separate skew in the dataset from disparate behavior in the trained model. Gemini Enterprise Agent Platform exposes metrics called data bias and model bias that help evaluate fairness across categories such as race, gender, and class. Data bias reflects skew present in the dataset before training, while model bias reflects disparate behavior in predictions or scores after training. Statistical deviations across categories do not automatically prove harm, because differences might reflect sample size, valid base rates, or domain context, so deviations require domain review rather than automatic rejection.
Sliced evaluation is the comparison of overall model performance against performance computed on predefined data slices defined by demographic groups or sensitive attributes. Sliced evaluation starts by defining fairness measures that match the use case, such as demographic parity, equalized odds, or disparate impact, then evaluating the model for potential biases across different slices. This disaggregated view identifies disparate performance that affects specific subgroups even when aggregate metrics look acceptable.
Proactive bias work spans the machine learning operations (MLOps) lifecycle:
The evaluation result for a slice depends on the slice definition, the chosen metric, and the dataset used, so the same model version must be compared on consistent slices and datasets over time.
Vertex AI Model Evaluation is the Agent Platform capability for scoring model versions against defined metrics and datasets and tracking the results for lineage. The evaluation can run as a pipeline component with Agent Platform Pipelines, either by itself or with other components for data processing, training, evaluation, and deployment. The evaluation component consumes a model version and an evaluation dataset, computes overall and sliced metrics, and the workflow then compares model versions against those metrics. Evaluation results flow from the evaluation component to Agent Platform ML Metadata for lineage and tracking, which links the metrics back to training parameters, dataset version, and code version and feeds re-evaluation or retraining cycles.
Exam tip: High overall accuracy does not prove fairness; a disparity hidden in one slice is only visible when overall metrics and disaggregated slice metrics are evaluated on the same dataset.
Explainability is the set of techniques that show which inputs and logic drove a prediction so teams can check whether the drivers align with domain knowledge and ethical guidelines. Vertex Explainable AI provides feature-based explanations and is integrated with both BigQuery ML and Agent Platform; teams can perform explainability in BigQuery ML or register the model in Agent Platform and perform explainability in Agent Platform. For tabular models deployed on Agent Platform endpoints, feature attributions indicate the input features that contributed most to each prediction, which helps reveal when a sensitive or proxy feature carries unexpected weight.
Additional diagnostic practices connect explanations to decisions:
Explanations do not by themselves prove bias, but they show where to investigate when a slice underperforms.
Continuous fairness monitoring is the production practice of detecting shifts in model behavior or outputs that might indicate emerging bias or unfairness after deployment. Model Monitoring on Agent Platform tracks prediction drift, data drift relative to training, unexpected shifts in prediction distributions, and spikes in low-confidence predictions, then feeds those insights back into re-evaluation or retraining. Cloud Logging provides an audit trail of key events and decisions, while Error Reporting groups errors to reveal patterns that point to underlying bias or areas needing refinement. Governance preserves the evidence needed to act on those signals, because data lineage from Knowledge Catalog tracks where data comes from, where it is passed, and what transformations are applied to it, which helps identify potential sources of bias or error. Model Registry stores each model version with its training parameters, evaluation metrics, dataset version, and documented limitations, so a fairness regression can be traced from a production prediction back to the data, pipeline, and model version that produced it.
Implement Explainable AI for Bias and Attribution Analysis is the capability to quantify how much each input feature contributed to a prediction and to aggregate those contributions to reveal systematic reliance on sensitive features. Vertex Explainable AI (opens in a new tab), now part of Gemini Enterprise Agent Platform (formerly Vertex AI Platform services), attaches an explanationSpec to a model and returns per-feature attribution values alongside each prediction. Local attributions explain a single instance, while global attributions summarize feature importance across many instances to reveal systematic reliance on sensitive or proxy features.
Sampled Shapley attribution is the Vertex Explainable AI method for structured data models that approximates exact Shapley values from cooperative game theory. Shapley values treat each model feature as a player in a game and assign credit to each player in proportion to the outcome of a particular inference. Exact Shapley computation considers different permutations of features, which is intractable for large feature sets, so the service uses a sampling approximation called Sampled Shapley. Increasing the number of sampled paths increases the precision of the approximation, but attributions can change dramatically as precision changes, so low path counts produce unstable explanations.
The explanationSpec is the model configuration that controls how Vertex Explainable AI computes feature attributions for online and batch predictions. The explanationSpec.parameters block sets the method and its precision, for example sampledShapleyAttribution.pathCount: 6 controls how many permutation paths are sampled and topK: -1 controls how many highest-attribution features are returned. The explanationSpec.metadata block defines the model contract for explanations, with metadata.inputs mapping each input name such as prediction_values, static_value, and historical_values to its inputBaselines, metadata.outputs naming the predicted output such as value, and featureAttributionsSchemaUri describing the output schema. Data flows from the baseline input through the model to the inference output, and the service computes attribution as the change in inference value relative to the baseline value, so the baseline choice determines the question the explanation answers. A meaningful baseline must represent the reference point relevant to the bias question, such as neutral values for advertisement, holiday, date, product, store, and historical sales.
BigQuery ML (BQML) (opens in a new tab) explainability separates local per-row explanations from global dataset-level explanations using extended SQL functions. Local functions return attributions for each row, while global functions aggregate attributions across the evaluation dataset to support bias review. ML.GLOBAL_EXPLAIN returns global explainability by taking the mean absolute attribution that each feature receives for all rows in the evaluation dataset, which surfaces features the model systematically relies on.
| Model type | Attribution method | Local explanation function | Global explanation function |
|---|---|---|---|
| Boosted tree and random forest | Tree SHAP and Gini Index-based feature importance | ML.EXPLAIN_PREDICT, an extended version of ML.PREDICT | ML.FEATURE_IMPORTANCE for Gini importance showing how useful each feature was in construction during training, and ML.GLOBAL_EXPLAIN for Tree SHAP |
| AutoML Tables | Sampled Shapley that assigns credit considering different feature permutations | Not applicable as a separate local function in this mapping | ML.GLOBAL_EXPLAIN for sampled Shapley approximation of exact Shapley values |
| ARIMA_PLUS time series | Time series decomposition into trend, seasonal, holiday, step changes, and spike and dips | ML.EXPLAIN_FORECAST, an extended version of ML.FORECAST | Not applicable |
| ARIMA_PLUS_XREG multivariate time series | Time series decomposition plus Shapley values for external regressors where attribution equals model weight * feature value | ML.EXPLAIN_FORECAST, an extended version of ML.FORECAST | Not applicable |
The table shows that tree-based models support both local and global views, AutoML Tables explanations are aggregated through ML.GLOBAL_EXPLAIN, and forecasting models explain through decomposition plus regressor attribution. ML.ADVANCED_WEIGHTS is an extended version of ML.WEIGHTS for weight inspection where supported. Choosing a global function is required when the question is whether a proxy feature consistently drives outcomes, while choosing a local function is required when the question is why a single prediction changed.
Attribution interpretation for bias review starts from the rule that attributions only express how much a feature affected the change in inference value relative to the baseline value. A large positive or negative attribution means that feature moved the prediction away from the baseline prediction, not that the feature is inherently important in isolation. When a sensitive attribute or its proxy, such as store, product, date, or correlated behavioral flags, repeatedly receives high absolute attribution in global results, the model depends on that encoding of historical bias. Counterfactual sensitivity is tested by changing the baseline or the feature value and observing whether the attribution and prediction shift, which reveals whether the model outcome is fragile to that feature.
Exam tip: Attributions are relative to the chosen inputBaselines, not absolute importance scores, so switching baselines can significantly change values and interpretation.
Configure Continuous Bias Monitoring and Remediation Pipelines is the automated routine that compares production serving data to training data and to earlier serving windows to catch shifts that degrade accuracy and fairness. In BigQuery ML (opens in a new tab), the pipeline centers on descriptive statistics and validation functions that detect data skew and data drift, trigger investigation when thresholds are violated, and feed corrections back into retraining. Because serving data that deviates from training data can degrade performance even when the model itself has not changed, continuous comparison is what keeps deployed models accurate over time.
Data skew and data drift are two distribution shifts that signal performance and fairness risk in production machine learning (ML) systems. Data skew occurs when the distribution of feature values for training data is significantly different from serving data in production. Data drift occurs when feature data distribution in production changes significantly over time. A model performs best on serving data that is similar to the training data, so understanding variance between training and serving data is critical for ensuring that models remain accurate and equitable across cohorts.
| Shift | Comparison source to destination | When it appears |
|---|---|---|
| Data skew | Training data statistics flow to serving data statistics for comparison | At deployment or when production inputs differ from training inputs |
| Data drift | Earlier serving data statistics flow to later serving data statistics for comparison | Over time in production, for example between different days of serving data |
Exam tip: Data skew compares training data to serving data, while data drift compares one span of serving data to another span of serving data.
Monitoring functions in BigQuery ML are SQL functions that compute descriptive statistics and validate differences between datasets without requiring separate monitoring infrastructure. Training statistics for the model are saved during model training, so the original training data is not required to use skew detection. Statistics for skew checks are only computed for feature columns in the serving data that match feature columns in the training data, which improves performance and lowers cost.
The monitoring functions divide by depth and purpose:
tfdv.generate_statistics_from_csv API for integration with existing validation solutions.validate_statistics API.The basic functions support quick development and monitoring, while the TensorFlow Data Validation (TFDV) functions provide fine-grained statistics for teams that need to integrate with an existing monitoring solution.
The skew monitoring workflow is the ordered routine for detecting when production inputs have diverged from training inputs. The workflow depends on the training statistics saved by BigQuery ML at model creation, which become the baseline that serving statistics flow into for comparison. This routine is appropriate when teams want to quickly develop and monitor a model for skew without needing fine-grained statistics.
The workflow runs first through validation, then through remediation:
ML.DESCRIBE_DATA on training and serving data to confirm both datasets compare appropriately and sit within expected parameters.ML.VALIDATE_DATA_SKEW to compare serving statistics against the saved training statistics and flag anomalous differences in matching feature columns.Only after the root cause is addressed does retraining restore alignment between the model and its serving environment.
The drift monitoring loop is the continuous routine that watches for production data changing over time before the datasets diverge too much to retrain. Drift detection in BigQuery ML compares consecutive spans of serving data, for example between different days of serving data, and the comparison lets teams receive notification while correction is still practical. The loop starts with ML.DESCRIBE_DATA on training and serving data to confirm both datasets compare appropriately and remain within expected parameters. When ML.VALIDATE_DATA_DRIFT or ML.TFDV_VALIDATE flags an anomalous difference between serving windows, data flows from the alert into investigation of the shifted features, then into adjustment of training data and retraining. The control boundary sits between serving and training: serving statistics are observed continuously, while the saved training statistics remain the fixed reference until a new model version replaces them. This closed loop turns fairness degradation and accuracy loss from silent failures into measurable events with a defined remediation path of detect, investigate, adjust data, and retrain.
Data skew occurs when the distribution of feature values for training data is significantly different from serving data in production, while data drift occurs when feature data distribution in production changes significantly over time. In BigQuery ML, skew is checked by comparing training statistics to serving statistics and drift is checked by comparing earlier serving statistics to later serving statistics. Because serving data that deviates from training data can degrade performance even when the model itself has not changed, continuous comparison keeps deployed models accurate and equitable.
ML.GLOBAL_EXPLAIN returns global explainability as the mean absolute attribution each feature receives across all rows in the evaluation dataset, which surfaces features the model systematically relies on. Local functions return attributions for each row to explain a single prediction or forecast. Choosing a global function is therefore required when the question is whether a proxy feature consistently drives outcomes, while choosing a local function is required when the question is why a single prediction changed.
In Gemini Enterprise Agent Platform, data bias reflects skew present in the dataset before training, while model bias reflects disparate behavior in predictions or scores after training. The metrics help evaluate fairness across categories such as race, gender, and class. Statistical deviations across categories do not automatically prove harm because differences might reflect sample size, valid base rates, or domain context, so deviations require domain review rather than automatic rejection.
Sliced evaluation compares overall model performance against performance computed on predefined slices defined by demographic groups or sensitive attributes. A model can show strong aggregate accuracy while performing poorly for a specific race, gender, class, or other sensitive slice, so the disparity is only visible when overall metrics and disaggregated slice metrics are evaluated on the same dataset. The evaluation result for a slice depends on the slice definition, the chosen metric, and the dataset used, so the same model version must be compared on consistent slices and datasets over time.
Last updated