Skip to content

Instantly share code, notes, and snippets.

@joshreini1
Last active June 15, 2023 13:57
Show Gist options
  • Save joshreini1/45797bdebbb3da2f016e141e2741bac0 to your computer and use it in GitHub Desktop.
Save joshreini1/45797bdebbb3da2f016e141e2741bac0 to your computer and use it in GitHub Desktop.
#standardSQL
CREATE MODEL 'bqml_tutorial.sample_model'
OPTIONS(model_type='boosted_tree_classifier') AS
SELECT
IF(totals.transactions IS NULL, 0, 1) AS label,
IFNULL(device.operatingSystem, "") as os,
device.isMobile AS is_mobile,
IFNULL(geoNetwork.country, "") AS country,
IFNULL(totals.pageviews, 0) AS pageviews
FROM
'bigquery-public-data.google_analytics_sample.ga_sessions_*'
WHERE
_TABLE_SUFFIX BETWEEN '20160801' AND '20170630'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment