Skip to content

Instantly share code, notes, and snippets.

@hackintoshrao
Created August 3, 2018 08:14
Show Gist options
  • Select an option

  • Save hackintoshrao/cbdd20136730cba9c6c4df262cbd0b8c to your computer and use it in GitHub Desktop.

Select an option

Save hackintoshrao/cbdd20136730cba9c6c4df262cbd0b8c to your computer and use it in GitHub Desktop.
compute_rmse = """
#standardSQL
SELECT
IF(MOD(ABS(FARM_FINGERPRINT(date)), 10) < 8, 'train', 'eval') AS dataset,
SQRT(AVG((arrival_delay - ALPHA * departure_delay)*(arrival_delay - ALPHA * departure_delay))) AS rmse,
COUNT(arrival_delay) AS num_flights
FROM
`bigquery-samples.airline_ontime_data.flights`
WHERE
departure_airport = 'DEN'
AND arrival_airport = 'LAX'
GROUP BY
dataset
"""
print bq.Query(compute_rmse.replace('ALPHA', str(alpha))).execute().result().to_dataframe().head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment