{
  "fetched_at": "2026-10-19T21:45:49Z",
  "source_url": "https://www.kaggle.com/competitions/hackathon-1611/data",
  "pages": [
    {
      "name": "data-description",
      "content": "### What is the table schema?\n- **fullVisitorId**: The unique visitor ID.\n- **visitStartTime**: The timestamp (expressed as POSIX time).\n- **date**: The date of the session.\n- **deviceCategory**: The type of device (Mobile, Tablet, Desktop).  \n- **isMobile**: If the user is on a mobile device, this value is true, otherwise false.\t\n- **operatingSystem**: The operating system of the device (e.g., \"Macintosh\" or \"Windows\").\t\n- **browser**: The browser used (e.g., \"Chrome\" or \"Firefox\").\n- **country**: The country from which sessions originated, based on IP address.\n- **city**: Users' city, derived from their IP addresses or Geographical IDs  \n- **trafficSource**: The source of the traffic source. Could be the name of the search engine, the referring hostname, or a value of the utm_source URL parameter.  \n- **trafficMedium**: The medium of the traffic source. Could be \"organic\", \"cpc\", \"referral\", or the value of the utm_medium URL parameter.\t\n- **trafficCampaign**: The campaign value. Usually set by the utm_campaign URL parameter.  \t\n- **isFirstVisit**: 1 if this is the first visit made by the visitor, otherwise 0.\n- **isBounce**: 1 if the visitor went to only one webpage and did not come back, otherwise 0.\n- **totalVisits**: The total number of visits by the visitor across sessions.  \n- **totalHits**: The total number of interactions across sessions. \n- **totalPageviews**: The total number of page views across sessions. \t\n- **totalTimeOnSite**: The total time on site.\n- **totalTransactions**: The total number of interactions across sessions. \t\n- **productPagesViewed**: The number of product pages viewed in the session.\n- **addedToCart**: If the visitor added an item to the cart or made further downstream actions (checkout, transaction), otherwise 0 (if the visitor only browsed but never added an item to the cart).  \n\n### What does the training data look like?\n```\n SELECT   \n   *   \n FROM  \n   kaggleworkshops.google_analytics_sample_eu.train  \n LIMIT 20\n```\n\n### What does the testing data look like?\n```\n SELECT   \n   *   \n FROM  \n   kaggleworkshops.google_analytics_sample_eu.test  \n LIMIT 20\n```\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Description",
      "content": "## Can we predict if a visitor, in a session, will add item(s) to the cart?\nThe [Google Merchandise Store](https://www.googlemerchandisestore.com/shop.axd/Home) sells Google branded merchandise, a real ecommerce store. Using obfuscated Google Analytics data on each visitor session, you will use BigQuery ML to try and build a model that predicts whether each session will result in the visitor performing an action to add an item to the cart.\n\n## Where's the data?\nThe data is split into two public tables on BigQuery: You will use the **training data** to build your model, and **testing data** to make your predictions using your model. \nGo to the [data](../data) page for more information on the tables.\n\n## How to create your first model and make your submission:\n\n### Step 1. \nLaunch one of the notebooks below on AI Platform Notebooks:\n\n- <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Online%20Retail%20Store%3A%20Predicting%20Visitor%20Behaviour%20-%20Starter%20Notebook%20%5BPython%5D&download_url=https%3A%2F%2Fstorage.googleapis.com%2Fstarter_notebooks%2Fgoogle_analytics_sample_bqml_python.ipynb&url=https%3A%2F%2Fgist.github.com%2Fpolong-lin%2F51bb01bac82513294e10fb9856c4fdb0\" target=\"_blank\"><img src=\"https://cloud.google.com/images/products/ai/ai-solutions-icon.svg\" alt=\"AI Platform Notebooks\">Starter Notebook [Python]</a>  \n- <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Online%20Retail%20Store%3A%20Predicting%20Visitor%20Behaviour%20-%20Starter%20Notebook%20%5BR%5D&download_url=https%3A%2F%2Fstorage.googleapis.com%2Fstarter_notebooks%2Fgoogle_analytics_sample_bqml_r.ipynb&url=https%3A%2F%2Fgist.github.com%2Fpolong-lin%2F568c0984abdf169c91d475da1ddb3489\" target=\"_blank\"><img src=\"https://cloud.google.com/images/products/ai/ai-solutions-icon.svg\" alt=\"AI Platform Notebooks\">Starter Notebook [R]</a> Note: Select \"R\" under \"Advanced Options\" > \"Environment\".\n\nIf you'd like to only use SQL instead, you can follow the [instructions on using the BigQuery Console UI](https://www.kaggle.com/c/online-retail-store-20201008/overview/can-i-just-use-the-bigquery-console-ui)\n\n### Step 2. \nUpload your CSV submission file to Kaggle via \"Submit Predictions\"\n\nThis is the home page of the competition. You don't need a subtitle here. The competition sub-title will appear above. This is where you introduce the problem. You can upload images using the \"Insert Photo\" icon on the bar that displays above this textbox when in edit mode.\n\nIf you are copy-pasting from another application, like Word or your browser, you may need to clean up the markdown or html for things to display properly.\n\nHere is a handy link to Kaggle's [competition documentation](https://www.kaggle.com/docs/competitions), which includes, among other things, instructions on [submitting predictions](https://www.kaggle.com/docs/competitions#making-a-submission).\n\n\n## Can we predict if a visitor, in a session, will add item(s) to the cart?\nThe [Google Merchandise Store](https://www.googlemerchandisestore.com/shop.axd/Home) sells Google branded merchandise, a real ecommerce store. Using obfuscated Google Analytics data on each visitor session, you will use BigQuery ML to try and build a model that predicts whether each session will result in the visitor performing an action to add an item to the cart.\n\n## Where's the data?\nThe data is split into two public tables on BigQuery: You will use the **training data** to build your model, and **testing data** to make your predictions using your model. \nGo to the [data](../data) page for more information on the tables.\n\n## How to create your first model and make your submission:\n\n### Step 1. \nLaunch one of the notebooks below on AI Platform Notebooks:\n\n- <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Online%20Retail%20Store%3A%20Predicting%20Visitor%20Behaviour%20-%20Starter%20Notebook%20%5BPython%5D&download_url=https%3A%2F%2Fstorage.googleapis.com%2Fstarter_notebooks%2Fgoogle_analytics_sample_bqml_python.ipynb&url=https%3A%2F%2Fgist.github.com%2Fpolong-lin%2F51bb01bac82513294e10fb9856c4fdb0\" target=\"_blank\"><img src=\"https://cloud.google.com/images/products/ai/ai-solutions-icon.svg\" alt=\"AI Platform Notebooks\">Starter Notebook [Python]</a>  \n- <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Online%20Retail%20Store%3A%20Predicting%20Visitor%20Behaviour%20-%20Starter%20Notebook%20%5BR%5D&download_url=https%3A%2F%2Fstorage.googleapis.com%2Fstarter_notebooks%2Fgoogle_analytics_sample_bqml_r.ipynb&url=https%3A%2F%2Fgist.github.com%2Fpolong-lin%2F568c0984abdf169c91d475da1ddb3489\" target=\"_blank\"><img src=\"https://cloud.google.com/images/products/ai/ai-solutions-icon.svg\" alt=\"AI Platform Notebooks\">Starter Notebook [R]</a> Note: Select \"R\" under \"Advanced Options\" > \"Environment\".\n\nIf you'd like to only use SQL instead, you can follow the [instructions on using the BigQuery Console UI](https://www.kaggle.com/c/online-retail-store-20201008/overview/can-i-just-use-the-bigquery-console-ui)\n\n### Step 2. \nUpload your CSV submission file to Kaggle via \"Submit Predictions\"\n\nThis is the home page of the competition. You don't need a subtitle here. The competition sub-title will appear above. This is where you introduce the problem. You can upload images using the \"Insert Photo\" icon on the bar that displays above this textbox when in edit mode.\n\nIf you are copy-pasting from another application, like Word or your browser, you may need to clean up the markdown or html for things to display properly.\n\nHere is a handy link to Kaggle's [competition documentation](https://www.kaggle.com/docs/competitions), which includes, among other things, instructions on [submitting predictions](https://www.kaggle.com/docs/competitions#making-a-submission)",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Evaluation",
      "content": "## Goal\nIt is your job to predict for each visitor session, **whether it will result in addedToCart (1) or not (0). Your predictions should be a probability between 0 and 1.0**.\n\n## Metric\nSubmissions are evaluated on [AUC](https://developers.google.com/machine-learning/crash-course/classification/roc-and-auc), which is a number between 0 and 1, where 0 means 100% of the predictions are wrong and 1 means 100% of the predictions are correct. Randomly guessing should give a score of 0.5.\n\n## Submission File Format\nThe file should contain a header and have the following format:\n```\nsessionId,addedToCart\n121212121212,0.30\n3434343434,1.0\n...\n```\nYou can download an example submission file (csv) on the [Data page](../data).\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "rules",
      "content": "# Rules\n\n## 1. Have fun!\n\n## 2. You can make up to 20 submissions.\n\n## 3. You can use AI Platform Notebooks on Google Cloud\nUse `%%bigquery` to run BigQuery SQL commands from Jupyter notebooks on AI Platform, as in:  \n\n```\n%%bigquery  \n{SQL STATEMENT}\n```\n\n## 4. Instructions on how to make submissions are on the [Evaluation](overview/evaluation) page\n\n## 5. Please be aware that this competition is viewable by the general public, but only those with the invite URL can enter the competition.\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "How Do I Evaluate My BigQuery ML Model?",
      "content": "# How do I evaluate my BigQuery ML model, before making predictions?\n\nTo evaluate your model after training completes, run:\n```\nSELECT\n  *\nFROM\n  ML.EVALUATE(MODEL bqmlretail.MY_MODEL_NAME)\n```\nHint: Look at the **AUC** metric to compare performance between your models.\n\n## How does ML.EVALUATE work if I never split the data?\nWhen you use CREATE MODEL, BigQuery ML automatically splits your training data into its own training/test data so that you can evaluate the performance of the model immediately when the model has finished training. \n\n_For more information on how BigQuery ML automatically splits your training data, read the [docs here on the `DATA_SPLIT_METHOD` parameter](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create#data_split_method) when using CREATE MODEL._\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "How Can I Improve My Model?",
      "content": "# How can I improve my predictions? My rank is not going up.\n### Feature selection\n- try selecting the features that you think are most important to the model\n\n### Model selection and hyperparameter tuning\n- have you tried choosing different classification models? have you tried tuning some of its hyperparameters? Check out the docs on each of the models below:\n - [`logistic_reg`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create)\n - [`boosted_tree_classifier`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-boosted-tree)\n - [`dnn_classifier`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-dnn-models)\n - [`automl_classifier`](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create-automl)\n\n### Feature engineering\n- could the day of week have an impact on purchasing patterns? use the [EXTRACT](https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#extract) function to retrieve the year/month/day/hour/minute/etc. from a TIMESTAMP column\n- can you multiple, divide, add, or subtract numerical features to create new features?\n- can you augment the weight of outliers by squaring numerical features, or on the other hand, taking the square root?\n- could combinations of features impact purchasing patterns more than individual columns? You can use [ML.FEATURE_CROSS](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-preprocessing-functions#mlfeature_cross) to create interactions on category variables \n- would it help to scale quantitative variables using [ML.STANDARD_SCALER](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-preprocessing-functions#mlstandard_scaler)?\n- are numerical features too granular? Could you bucketize them using [ML.QUANTILE_BUCKETIZE](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-preprocessing-functions#quantile_bucketize)?\n- check out all of the [pre-processing features built into BigQuery ML](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-preprocessing-functions)\n\n\n### Ensembling models\n- the combination of multiple model outputs may be better than any single model alone. As a simple example, you can try to take the mean/median of the probability outputs of ML.PREDICT across multiple models. For example, for a specific fullVisitorId, if model_1 and model_2 predict 0.5 and 1.0 respectively, then the averaged prediction would be 0.75.\n\n```\n## Ensemble two models (model_a, model_b) by averaging their predictions\nWITH pred1 AS (\n  SELECT\n    sessionId, \n    prob as addedToCart\n  FROM\n    ML.PREDICT(MODEL bqmlretail.model_a, ## replace model name\n      (\n      SELECT \n        CONCAT(fullVisitorId, CAST(visitStartTime as string)) as sessionId, \n        *\n      FROM\n      `kaggleworkshops.google_analytics_sample_eu.test`\n    )),\n  UNNEST(predicted_addedToCart_probs)\n  WHERE label = 1),\n  \n  pred2 AS (\n  \n  SELECT\n    sessionId, \n    prob as addedToCart\n  FROM\n    ML.PREDICT(MODEL bqmlretail.model_b, ## replace model name\n      (\n      SELECT \n        CONCAT(fullVisitorId, CAST(visitStartTime as string)) as sessionId, \n        *\n      FROM\n      `kaggleworkshops.google_analytics_sample_eu.test`\n    )),\n  UNNEST(predicted_addedToCart_probs)\n  WHERE label = 1)\n\nSELECT\n  sessionId,\n  AVG(addedToCart) addedToCart\nFROM (\n  SELECT\n    *\n  FROM pred1\n  UNION ALL\n  SELECT\n    *\n  FROM pred2\n  )\nGROUP BY sessionId\n```\n\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Error: Unsupported Column Date?",
      "content": "# I got an error: _Unsupported column date: model {} doesn't support TIMESTAMP data type._\nThe `date` column is a TIMESTAMP column, which some BigQuery ML models (e.g. `boosted_tree_classifier`, `dnn_classifier`) do not accept. You will need to manually extract out the values you'd like as separate features. \n\nHere's how to extract various date-time features from a TIMESTAMP column:\n```\nCREATE OR REPLACE MODEL bqmlretail.xgb_extract_time\nTRANSFORM(\n  EXTRACT (dayofweek FROM date) AS dayofweek,\n  EXTRACT (day FROM date) as day,\n  EXTRACT (month FROM date) as month,\n  EXTRACT( hour FROM TIMESTAMP_SECONDS(visitStartTime) ) as hour,\n  addedToCart\nOPTIONS(\n  model_type='boosted_tree_classifier', \n  INPUT_LABEL_COLS=[\"addedToCart\"]) AS\nSELECT \n  *\nFROM\n  `kaggleworkshops.google_analytics_sample_eu.train`\n```\n\nCheck the [EXTRACT](https://cloud.google.com/bigquery/docs/reference/standard-sql/timestamp_functions#extract) documentation for more info.\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    },
    {
      "name": "Can I Just Use The BigQuery Console UI?",
      "content": "Yes! You will only need to know SQL to use the BigQuery Console UI. Follow the instructions below:\n\n## Create your first BigQuery ML model\n\n### Step 0:\nOpen the [BigQuery Console](https://console.cloud.google.com/bigquery).\n\n### Step 1:\nFirst, create a dataset in BigQuery called `bqmlretail` in the `EU` region. If you create it in a different region, Step 2 will not work.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2F23bd8fee4e4828a49bf36bab54f74141%2Finstructions_createbqdataset.png?generation=1594202939078531&amp;alt=media)\n\n\n\n### Step 2:\nRun the CREATE MODEL query below. It should take ~1 min to train.\n\n```\nCREATE OR REPLACE MODEL bqmlretail.logreg_sample\nTRANSFORM(\n  LOWER(country) country_lower,\n  totalPageviews,\n  addedToCart\n)\nOPTIONS(\n  model_type='logistic_reg', \n  INPUT_LABEL_COLS=[\"addedToCart\"]) AS\nSELECT \n  *\nFROM\n  `kaggleworkshops.google_analytics_sample_eu.train`\nWHERE date BETWEEN TIMESTAMP(\"2016-08-01\")\n  AND TIMESTAMP(\"2016-08-31\")\n```\n\n## How to create your submission file\n### Step 3. Run this code\nUsing your model (e.g., `your_project_id.addtocart_model_name`), run the following code to make predictions on all the test data. This returns the probability that addedToCart = 1. Make sure to use at least the same features you used to create your model.\n\n```\nSELECT\n  sessionId, \n  prob as addedToCart\nFROM\n  ML.PREDICT(MODEL bqmlretail.YOUR_MODEL_NAME, ## replace model name\n    (\n    SELECT \n      CONCAT(fullVisitorId, CAST(visitStartTime as string)) as sessionId, \n      *\n    FROM\n    `kaggleworkshops.google_analytics_sample_eu.test`\n  )),\nUNNEST(predicted_addedToCart_probs)\nWHERE label = 1\n```\n\n### Step 4. Save your results as a CSV\nOnce your ML.PREDICT has finished running, click on **Save Results**, then choose **CSV (Google Drive)**:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2F6b98c796f91435ccab4687dd5df98c2f%2Fsave_results.png?generation=1581284671726951&alt=media)\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2Fe86add0ff58b73240d5f736a914d6bf1%2Fsave_results_popup.png?generation=1581284672753246&alt=media)\n\n_If you missed the link, you can re-export, or in the \"Jobs history\" section in the BigQuery Console, navigate to your export job, find the filename, and search in your Google Drive for the file._\n\n### Step 5. Open the file in Google Drive\nWait for the \"Open in Drive\" link to appear in the bottom-left corner of your screen and click on it.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2F4ea482fcbdd6763aef45215eec2973f8%2Fopen_in_drive.png?generation=1581285106012139&alt=media)\n(**Can't find it?** Easiest way is to re-do Step 2. Otherwise, you can find the output filename under _Job History_ on the left-hand menu on the BigQuery Console, then check under _Personal History_.)\n\n### Step 6. Download the CSV\nDownload the results from your Google Drive (~8MB):\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2F107b5d000d77eba26d0a85d451c3c3a3%2Fdownload_drive.png?generation=1581285350804991&alt=media)\n\n### Step 7. Make your submission!\nOn the Submit Predictions page, follow the following instructions. Pasting the SQL query in the description will allow you to keep track of what models you used, and help the competition admins audit your queries.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-user-content/o/inbox%2F3399668%2Faa300b2d2b341ee3e7d386e4e2885c77%2Finstructions_makesubmission.png?generation=1594202366445976&alt=media)\n",
      "isPublished": false,
      "hasIsPublished": false,
      "postTitle": "",
      "hasPostTitle": false,
      "mimeType": "",
      "hasMimeType": false
    }
  ]
}