Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save velotiotech/fbfaf3e37744e5598c64e41f1bf39f2a to your computer and use it in GitHub Desktop.
Save velotiotech/fbfaf3e37744e5598c64e41f1bf39f2a to your computer and use it in GitHub Desktop.
BigQuery 101: All the Basics You Need to Know - Code for Velotio Blog Part - 2
CREATE MODEL `velotio_tutorial.sample_model`
OPTIONS(model_type='logistic_reg') 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 '20190401' AND '20180630'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment