Google BigQuery (50 Qs)•Part 3: Enterprise FinOps, Disaster Recovery & Scale (25 - 35)
BigQuery ML (BQML): Training ML models directly with SQL.
senior LevelCode ExampleDatabases & SQL
In Simple Words: Train and deploy machine learning models directly inside BigQuery without exporting data to Python or Pandas:
sql
-- Train a customer churn model using XGBoost
CREATE OR REPLACE MODEL `analytics.churn_model`
OPTIONS(model_type='BOOSTED_TREE_CLASSIFIER', input_label_cols=['churned']) AS
SELECT tenure, monthly_spend, support_calls, churned
FROM `analytics.customer_features`;
-- Run predictions in real-time SQL
SELECT customer_id, predicted_churned
FROM ML.PREDICT(MODEL `analytics.churn_model`, TABLE `analytics.active_customers`);
- Supports Linear Regression, Logistic Regression, K-Means clustering, Matrix Factorization, and remote Vertex AI Gemini models.