Skip to content

Instantly share code, notes, and snippets.

@juri96
Created November 15, 2019 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juri96/c709e167b03ca86aa56da549d6a68d5e to your computer and use it in GitHub Desktop.
Save juri96/c709e167b03ca86aa56da549d6a68d5e to your computer and use it in GitHub Desktop.
WITH dataset AS (SELECT pm25,
pm10,
so2,
co,
o3,
temp,
press,
dewp,
rain,
timestamp,
station
FROM `GCP_PROJECT_NAME.DATASET_NAME.measurements`
WHERE pm25 IS NOT NULL
AND pm10 IS NOT NULL
AND so2 IS NOT NULL
AND co IS NOT NULL
AND o3 IS NOT NULL
AND temp IS NOT NULL
AND press IS NOT NULL
AND dewp IS NOT NULL
AND rain IS NOT NULL
AND timestamp IS NOT NULL
AND station IS NOT NULL
)
SELECT * EXCEPT (nearest_centroids_distance) FROM
ML.PREDICT(MODEL `GCP_PROJECT_NAME.DATASET_NAME.pollution_kmeans`,
(
SELECT timestamp, station, pm25, pm10, so2, co, o3, temp, press, rain, dewp
FROM dataset
)
)
ORDER BY station, timestamp DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment