Path: blob/master/site/en-snapshot/io/tutorials/bigquery.ipynb
25118 views
Copyright 2019 The TensorFlow IO Authors.
End to end example for BigQuery TensorFlow reader
Overview
This tutorial shows how to use BigQuery TensorFlow reader for training neural network using the Keras sequential API.
Dataset
This tutorial uses the United States Census Income Dataset provided by the UC Irvine Machine Learning Repository. This dataset contains information about people from a 1994 Census database, including age, education, marital status, occupation, and whether they make more than $50,000 a year.
Setup
Set up your GCP project
The following steps are required, regardless of your notebook environment.
Enter your project ID in the cell below. Then run the cell to make sure the Cloud SDK uses the right project for all the commands in this notebook.
Note: Jupyter runs lines prefixed with !
as shell commands, and it interpolates Python variables prefixed with $
into these commands.
Install required Packages, and restart runtime
Authenticate
Set your PROJECT ID
Import Python libraries, define constants
Import census data into BigQuery
Define helper methods to load data into BigQuery
Load Census data in BigQuery.
Confirm that data was imported
TODO: replace <YOUR PROJECT> with your PROJECT_ID
Note: --use_bqstorage_api will get data using BigQueryStorage API and will make sure that you are authorized to use it. Make sure that it is enabled for your project: https://cloud.google.com/bigquery/docs/reference/storage/#enabling_the_api
##Load census data in TensorFlow DataSet using BigQuery reader
Read and transform cesnus data from BigQuery into TensorFlow DataSet
##Define feature columns
##Build and train model
Build model
Train model
##Evaluate model
Evaluate model
Evaluate a couple of random samples