Skip to content

Instantly share code, notes, and snippets.

@securetorobert
Created May 19, 2019 16:53
Show Gist options
  • Save securetorobert/1584353cc3d551c42cf806c6d1d6312d to your computer and use it in GitHub Desktop.
Save securetorobert/1584353cc3d551c42cf806c6d1d6312d to your computer and use it in GitHub Desktop.
Create a Logistic Regression model with BQML
#standardSQL
CREATE MODEL `bqml_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 '20160801' AND '20170630'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment