Utilizing the linear regression model
To use our BigQuery ML model, we'll use the ML.PREDICT
function and the table that we've expressly created to host the records that we haven't used yet.
The following query will predict the label using the data in prediction_table
:
SELECT Â Â Â tripduration as actual_duration, Â Â Â predicted_label as predicted_duration, Â Â Â ABS(tripduration - predicted_label) difference_in_min FROM Â Â ML.PREDICT(MODEL `04_nyc_bike_sharing.trip_duration_by_stations_and_day`, Â Â Â Â ( Â Â Â Â SELECT Â Â Â Â Â Â Â Â Â Â start_station_name, Â Â Â Â Â Â Â Â Â Â end_station_name, Â Â Â Â Â Â Â Â Â Â IF (EXTRACT(DAYOFWEEK FROM starttime)=1 OR Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â EXTRACT(DAYOFWEEK...