BigQuery ML lets you train supported models with GoogleSQL. For linear regression, CREATE MODEL ... OPTIONS(model_type='linear_reg', input_label_cols=['y']) AS SELECT x, y ... treats y as the label and x as a feature. Training sees labels; prediction receives features and returns predicted_y. An identifier should travel with the output without becoming a feature by accident.
The fictional capacity fixture has one numeric predictor and one numeric label. Use sample_id <= 40 for training and sample_id > 40 for evaluation. NO_SPLIT disables automatic splitting because you supply the holdout explicitly. Evaluating the training rows can understate error and doesn't prove future performance.
This local implementation fits a small ordinary least-squares line. It doesn't simulate Google's optimizer, automatic preprocessing, distributed training or every model family. The data is a teaching fixture, so its metrics are computed exercise results rather than claims about a real operation.
CREATE OR REPLACE MODEL practice.capacity_model OPTIONS(model_type='linear_reg', input_label_cols=['y'], data_split_method='NO_SPLIT') AS SELECT x, y FROM practice.capacity_samples WHERE sample_id <= 40;
SELECT mean_squared_error, mean_absolute_error FROM ML.EVALUATE(MODEL practice.capacity_model, (SELECT x, y FROM practice.capacity_samples WHERE sample_id > 40));
The model trains on one set of observations and evaluates a disjoint holdout.