Let’s Get Certified
Module 02 / 15 · Architect low-code AI solutions

Train a low-code baseline in BigQuery

Translate a business decision into a prediction target, a feature transformation and a held-out evaluation.

Train a low-code baseline in BigQuery

Work through the decision

A grocer keeps weekly store sales in BigQuery. Planners need demand for each of the next four weeks. A colleague proposes clustering stores and copying the cluster average into every week. How should the team benchmark that proposal?

Check your reasoning

Define the forecast horizon and unit, then reserve the latest weeks for evaluation. Fit a forecasting model such as ARIMA_PLUS in BigQuery ML and compare errors against a seasonal baseline. Use ML.FORECAST for the future horizon. A cluster can describe similar stores without providing a time-indexed forecast.

Watch the source lesson at 4:32

Compare the choices

Time-series forecasting
Order observations by time and evaluate future horizons using an earlier training window. Compare against a simple seasonal baseline.
Binary classification
Use labeled examples when the target has two outcomes, then select a decision threshold based on the costs of errors.
BigQuery ML TRANSFORM
Package supported feature transformations with the model so that the same definitions apply at prediction time.
Agent Platform AutoML
Train a managed model for a supported task with labeled data, an appropriate split, an objective and training budget. Evaluate it against a baseline.

Test the decision

For a separate late-delivery classifier, build features with a TRANSFORM clause, fit on historical deliveries and score held-out rows with ML.PREDICT. A model trained in SQL still needs validation. For Gemini tuning in BigQuery, use supported base models and representative input/output pairs, then compare generated outputs with an untuned baseline on unseen examples.

Read a BigQuery ML prediction

Assume ops.delay_classifier is a trained binary classifier whose label is named late. The held-out table supplies its raw features distance_km and item_count. BigQuery ML returns a predicted label per input row. Keep the order ID for a later join to actual outcomes.

SELECT order_id, predicted_late
FROM ML.PREDICT(
  MODEL `ops.delay_classifier`,
  (SELECT order_id, distance_km, item_count
   FROM `ops.held_out_orders`)
)

BigQuery ML prediction reference

Practice the guide skills

  1. Match late delivery, basket value, weekly demand and unlabeled customer segments to classification, regression, forecasting and clustering respectively. Identify which targets require labels. Watch 4:32
  2. Define a BigQuery ML TRANSFORM clause for a feature available at scoring time and test its behavior on a missing value. Watch 6:22
  3. Compare the input and result of ML.PREDICT for a classifier with the future horizon supplied to ML.FORECAST for a forecasting model. Watch 7:47
  4. Choose a supported AutoML task, label column, split strategy, budget and evaluation metric for a product-return dataset. Watch 11:03
  5. Prepare input/output pairs in BigQuery for a supported Gemini tuning workflow. Reserve unseen examples and compare the tuned model with the base model using the same rubric. Watch 8:27

Official objectives for this lesson

Related lesson · Keep order lines and returns at a declared grain

Knowledge check

Train a low-code baseline in BigQuery quiz

Answer 3 questions. Check each answer for an explanation.