あなたは食品会社に勤務しています。会社の過去の売上データはBigQueryに保存されています。BigQueryからデータを読み込み、将来の売上を予測する複数のTensorFlowモデルをトレーニングするために、Vertex AIのカスタムトレーニングサービスを使用する必要があります。モデルの実験を開始する前に、多数の特徴量に対して最小最大スケーリングとバケット化を実行するデータ前処理アルゴリズムを実装する予定です。前処理の時間、コスト、開発作業を最小限に抑えたいと考えています。このワークフローをどのように構成すればよいでしょうか?
正解: C
ワークフローを構成するための最良のオプションは、変換を TensorFlow モデルの前処理レイヤーとして追加することです。このオプションを使用すると、TensorFlow のパワーとシンプルさを活用して、シンプルな Python コードでデータを前処理および変換できます。TensorFlow は、機械学習モデルを構築およびトレーニングするためのフレームワークです。TensorFlow は、データ分析と機械学習のためのさまざまなツールとライブラリを提供します。前処理レイヤーは、入力データに対してデータの前処理と特徴エンジニアリング操作を実行できる TensorFlow のレイヤーの一種です。前処理レイヤーを使用すると、データの変換と前処理ロジックをカスタマイズしたり、複雑なデータ形式や標準以外のデータ形式を処理したりできます。また、前処理レイヤーを実装するために数行のコードを記述するだけで済み、中間データソースやパイプラインを作成する必要がないため、前処理の時間、コスト、開発作業を最小限に抑えることができます。TensorFlow モデルの前処理レイヤーとして変換を追加することで、Vertex AI のカスタムトレーニング サービスを使用して、BigQuery からデータを読み取り、将来の売上を予測する複数の TensorFlow モデルをトレーニングできます。
他の選択肢は、以下の理由から選択肢Cほど優れていません。
* オプション A: spark-bigquery-connector を使用する Spark に変換を記述し、Dataproc を使用してデータを前処理するには、TensorFlow で前処理レイヤーを使用するよりも多くのスキルと手順が必要になります。 Spark は、分散データ処理と機械学習のためのフレームワークです。 Spark は、Spark が BigQuery と通信できるようにするライブラリである spark-bigquery-connector を使用して、BigQuery からデータを読み書きできます。 Dataproc は、Google Cloud 上で Spark クラスターを作成および管理できるサービスです。 Dataproc を使用すると、Google Cloud 上で Spark ジョブを実行し、ワークロードに応じてクラスターをスケーリングできます。ただし、spark-bigquery-connector を使用する Spark に変換を記述し、Dataproc を使用してデータを前処理するには、TensorFlow で前処理レイヤーを使用するよりも多くのスキルと手順が必要になります。コードを記述し、Spark クラスターを作成して構成し、spark-bigquery-connector をインストールしてインポートし、データをロードして前処理し、データを BigQuery に書き戻す必要があります。さらに、このオプションではBigQuery内に中間データソースが作成されるため、ストレージと計算コストが増加する可能性があります2。
* Option B: Writing SQL queries to transform the data in-place in BigQuery would not allow you to use Vertex AI's custom training service to train multiple TensorFlow models that read the data from BigQuery and predict future sales. BigQuery is a service that can perform data analysis and machine learning by using SQL queries. BigQuery can perform data transformation and preprocessing by using SQL functions and clauses, such as MIN, MAX, CASE, and TRANSFORM. BigQuery can also perform machine learning by using BigQuery ML, which is a feature that can create and train machine learning models by using SQL queries. However, writing SQL queries to transform the data in-place in BigQuery would not allow you to use Vertex AI's custom training service to train multiple TensorFlow models that read the data from BigQuery and predict future sales. Vertex AI's custom training service is a service that can run your custom machine learning code on Vertex AI. Vertex AI's custom training service can support various machine learning frameworks, such as TensorFlow, PyTorch, and scikit- learn. Vertex AI's custom training service cannot support SQL queries, as SQL is not a machine learning framework. Therefore, if you want to use Vertex AI's custom training service, you cannot use SQL queries to transform the data in-place in BigQuery3.
* Option D: Creating a Dataflow pipeline that uses the BigQueryIO connector to ingest the data, process it, and write it back to BigQuery would require more skills and steps than using a preprocessing layer in TensorFlow. Dataflow is a service that can create and run data processing and machine learning pipelines on Google Cloud. Dataflow can read and write data from BigQuery by using the BigQueryIO connector, which is a library that allows Dataflow to communicate with BigQuery. Dataflow can perform data transformation and preprocessing by using Apache Beam, which is a framework for distributed data processing and machine learning. However, creating a Dataflow pipeline that uses the BigQueryIO connector to ingest the data, process it, and write it back to BigQuery would require more skills and steps than using a preprocessing layer in TensorFlow. You would need to write code, create and configure the Dataflow pipeline, install and import the BigQueryIO connector, load and preprocess the data, and write the data back to BigQuery. Moreover, this option would create an intermediate data source in BigQuery, which can increase the storage and computation costs4.
References:
* Preparing for Google Cloud Certification: Machine Learning Engineer, Course 3: Production ML Systems, Week 2: Serving ML Predictions
* Google Cloud Professional Machine Learning Engineer Exam Guide, Section 2: Developing ML models, 2.1 Developing ML models by using TensorFlow
* Official Google Cloud Certified Professional Machine Learning Engineer Study Guide, Chapter 4:
機械学習モデルの開発、第4.1節:TensorFlowを使用した機械学習モデルの開発
* TensorFlowの前処理レイヤー
* SparkとBigQuery
* データ処理
* BigQuery ML
* DataflowとBigQuery
* アパッチビーム