01_基礎

セクション5 基礎 — ML パイプラインの自動化とオーケストレーション

📘 対象:新人エンジニア。E2E ML パイプラインの全体像、主要なオーケストレータ、MLOps 成熟度の3レベルを押さえる。


1. なぜパイプラインが必要か

手動の ML 開発の問題

パイプライン化のメリット


2. ML パイプラインの典型構成

[1. データ取り込み]
       ↓
[2. データ検証](スキーマ/統計/異常)
       ↓
[3. 前処理・特徴量化](TFT / Feature Store)
       ↓
[4. 訓練]
       ↓
[5. 評価]
       ↓
[6. モデル検証](性能 / バイアス / SLO 合格判定)
       ↓
[7. Model Registry に登録]
       ↓
[8. 推論基盤にデプロイ](カナリア → 本番)
       ↓
[9. モニタリング](ドリフト / 精度劣化)
       ↓ (劣化検知)
   [再訓練トリガー]

各ステップが コンポーネント(再利用可能なユニット)として独立しているのが理想。


3. Agent Platform Pipelines(旧 Vertex AI Pipelines)

3.1 概要

3.2 KFP v2 基本構造(Python SDK)

from kfp import dsl, compiler

@dsl.component(packages_to_install=["pandas", "scikit-learn"])
def train(data_path: str, model_path: dsl.OutputPath("Model")):
    import pandas as pd, joblib
    from sklearn.linear_model import LogisticRegression
    df = pd.read_csv(data_path)
    model = LogisticRegression().fit(df.drop("y", axis=1), df["y"])
    joblib.dump(model, model_path)

@dsl.pipeline(name="churn-pipeline")
def pipeline(data_path: str):
    train(data_path=data_path)

compiler.Compiler().compile(pipeline, "pipeline.json")

3.3 強み

3.4 いつ使う


4. Managed Service for Apache Airflow(旧 Cloud Composer)

4.1 概要

4.2 強み

4.3 いつ使う

4.4 Cloud Composer 1 vs Composer 2 vs Composer 3


5. Ray on Agent Platform(新ガイドで追加)🆕

5.1 Ray とは

5.2 Ray on Agent Platform

5.3 いつ使う


6. Cloud Workflows

6.1 概要

6.2 いつ使う

6.3 Pipelines / Airflow との違い


7. オーケストレータ早見表

Agent Platform Pipelines Managed Airflow Ray on Agent Platform Cloud Workflows
主用途 ML パイプライン ETL+ML/汎用ワークフロー 分散 ML / RL 軽量 API 連携
言語 Python (KFP v2) Python (Airflow DSL) Python (Ray API) YAML
強み サーバーレス・系統管理 Operator 豊富・柔軟 分散制御 軽量・低コスト
第一候補 ML 専用パイプライン ETL+ML、既存資産 RL/HPT/分散ML API オーケストレーション

8. データ・モデル検証ステップ

8.1 データ検証

ツール

8.2 モデル検証

ツール


9. CI/CD/CT の概念

9.1 用語

9.2 MLOps 成熟度モデル(Google 公式)

レベル 名称 特徴
Level 0 手動 手動でノートブック実行、人手でデプロイ
Level 1 ML パイプライン自動化 パイプラインで自動訓練・自動デプロイ
Level 2 CI/CD パイプライン自動化 コードの変更で パイプライン自体 も自動更新 + CT

試験頻出: 「レベル X はどう違うか」

9.3 Cloud Build の役割

9.4 典型的な CI/CD/CT 構成

[Developer commits code]
       ↓ (Cloud Build trigger)
[Unit tests + Lint]
       ↓
[Container build & push (Artifact Registry)]
       ↓
[Pipeline definition compile (KFP)]
       ↓
[Pipeline submit (Agent Platform Pipelines)]
       ↓
[Training → Evaluation → Model Registry → Canary deploy]
       ↓
[Monitoring (drift detection)]
       ↓ (drift detected)
[Auto-trigger pipeline → CT]

10. このセクションで覚えるキーワード

次は 02_応用.md で再訓練ポリシーと検証ステップの応用、Ray の詳細を扱います。