How to preprocess BigQuery data for TensorFlow efficiently?
You are using Keras and TensorFlow to develop a fraud detection model. Records of customer transactions are stored in a large table in BigQuery. You need to preprocess these records in a cost-effective and efficient way before you use them to train the model. The trained model will be used to perform batch inference in BigQuery. How should you implement the preprocessing workflow?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
This question tests the principle of using the right tool for the job—specifically, leveraging BigQuery's native processing power rather than moving data to external frameworks—and the trap is over-engineering the solution with Spark or Dataflow.
To preprocess large BigQuery datasets cost-effectively for TensorFlow, performing transformations directly in BigQuery using SQL and reading data via the BigQueryClient is the recommended approach. The community agrees this method avoids the overhead and management costs of external clusters like Dataproc or Dataflow.
Choosing Option D (Apache Beam on Dataflow) is a frequent error because, although it is a powerful ETL tool, it introduces unnecessary complexity and expense for a preprocessing task that can be handled natively and more cheaply within BigQuery.
Community Discussion (3 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
Expert Analysis
Why the Answer Is Correct
Option C is the correct choice because it utilizes BigQuery's serverless architecture to handle large-scale data transformations efficiently and cost-effectively. By preprocessing with SQL, data movement is minimized, and usingtf.data.BigQueryClient allows TensorFlow to stream data directly for training without exporting to intermediate files like CSV.Why the Other Options Are Wrong
Option A (Spark/Dataproc) and Option D (Beam/Dataflow) are incorrect because they require provisioning and managing external clusters, which adds cost and operational overhead that is unnecessary for this scenario. Option B (Pandas) is incorrect because loading a large table into a local or single-machine DataFrame often leads to Out of Memory errors and is not scalable.Community Comment Notes
Community feedback strongly supports Option C, with users noting it is the "easiest" solution. Comments highlight that Dataproc involves additional cluster setup costs and that pandas is unsuitable for large datasets due to performance and resource constraints.Official Reference
Exam Strategy
Always look for opportunities to perform data transformations where the data resides. If the data is in BigQuery, use SQL for preprocessing to avoid data egress fees and the complexity of managing external processing clusters.
Related Analysis
Practice All PMLE Questions
Access 65 questions with complete answers and detailed explanations.
View Full PMLE Practice Test →