Created
May 15, 2023 19:47
-
-
Save joshreini1/2681fc19148a5d1ce8f8008890866626 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#standardSQL | |
SELECT | |
visitorID, #passthrough | |
Country, | |
Top_feature_attributions, # from ml.explain_predict | |
SUM(predicted_label) as total_predicted_purchases, | |
label #passthrough | |
FROM | |
ML.EXPLAIN_PREDICT(MODEL `bqml_tutorial.sample_model`, ( | |
SELECT | |
IFNULL(device.operatingSystem, "") AS os, | |
device.isMobile AS is_mobile, | |
IFNULL(totals.pageviews, 0) AS pageviews, | |
IFNULL(geoNetwork.country, "") AS country | |
FROM | |
`bigquery-public-data.google_analytics_sample.ga_sessions_*` | |
WHERE | |
_TABLE_SUFFIX BETWEEN '20170701' AND '20170801')) | |
GROUP BY country | |
ORDER BY total_predicted_purchases DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment