text: #https://cloud.google.com/docs
  #creating the initial logistic regression model, this creates classification_model_1
  CREATE OR REPLACE MODEL `ecommerce.classification_model`
  OPTIONS
  (
  model_type='logistic_reg',
  labels = ['will_buy_on_return_visit']
  )
  AS
  
  #standardSQL
  SELECT
    * EXCEPT(fullVisitorId)
  FROM
  
    # features
    (SELECT
      fullVisitorId,
      IFNULL(totals.bounces, 0) AS bounces,
      IFNULL(totals.timeOnSite, 0) AS time_on_site
    FROM
      `data-to-insights.ecommerce.web_analytics`
    WHERE
      totals.newVisits = 1
      AND date BETWEEN '20160801' AND '20170430') # train on first 9 months
    JOIN
    (SELECT
      fullvisitorid,
      IF(COUNTIF(totals.transactions > 0 AND totals.newVisits IS NULL) > 0, 1, 0) AS will_buy_on_return_visit
    FROM
        `data-to-insights.ecommerce.web_analytics`
    GROUP BY fullvisitorid)
    USING (fullVisitorId)
  ;
  