Hikaru's notes

A collection of notes and resources

View the Project on GitHub HikaruMizoe/notes

2.1 モデリングアプローチを選択する

タスクステートメント

モデリングアプローチを選択する

対象知識

ビジネス上の問題を解決するための ML アルゴリズムの機能と適切な使用

教師あり学習

教師なし学習

深層学習

AWS の AI サービスを使用してビジネス上の特定の問題を解決する方法

Amazon Translate

Amazon Transcribe

Amazon Rekognition

Amazon Bedrock

その他のAIサービス

モデル選択またはアルゴリズム選択時の解釈可能性を考慮する方法

SageMaker の組み込みアルゴリズムと適用のタイミング

教師あり学習アルゴリズム

教師なし学習アルゴリズム

テキスト・NLP アルゴリズム

時系列アルゴリズム

対象スキル

1. 使用可能なデータと問題の複雑さを評価して ML ソリューションの実現可能性を判断する

2. 特定の問題を解決するための適切な ML モデルやアルゴリズムを比較して選択する

| 問題タイプ | 推奨アルゴリズム | 考慮事項 | |———–|—————-|———-| | 表形式データの分類・回帰 | XGBoost, Linear Learner | データサイズ、解釈可能性 | | 画像分類 | CNN, Image Classification | データ量、転移学習 | | テキスト分類 | BlazingText, Transformer | 文書長、言語 | | 時系列予測 | DeepAR, Prophet | 季節性、トレンド | | 異常検出 | Random Cut Forest | データ分布 |

3. 組み込みアルゴリズム、基盤モデル、ソリューションテンプレートを選択する

4. コストに基づいてモデルやアルゴリズムを選択する

5. 一般的なビジネスニーズを解決する AI サービスを選択する

実践例

SageMaker 組み込みアルゴリズムの使用

from sagemaker import image_uris
from sagemaker.estimator import Estimator

# XGBoost アルゴリズムのイメージ URI を取得
container = image_uris.retrieve('xgboost', region, '1.7-1')

# Estimator の作成
xgb_estimator = Estimator(
    container,
    role=role,
    instance_count=1,
    instance_type='ml.m5.xlarge',
    output_path=f's3://{bucket}/output',
    sagemaker_session=session
)

# ハイパーパラメータの設定
xgb_estimator.set_hyperparameters(
    objective='binary:logistic',
    num_round=100,
    max_depth=5,
    eta=0.2
)

# トレーニング
xgb_estimator.fit({'train': s3_train_data})

SageMaker JumpStart の使用

from sagemaker.jumpstart.model import JumpStartModel

# 事前トレーニング済みモデルの選択
model_id = 'huggingface-text-classification-bert-base-uncased'

model = JumpStartModel(model_id=model_id)

# デプロイ
predictor = model.deploy()

# 推論
response = predictor.predict("This is a great product!")

Amazon Bedrock の使用

import boto3
import json

bedrock = boto3.client('bedrock-runtime')

# Claude モデルを使用
response = bedrock.invoke_model(
    modelId='anthropic.claude-v2',
    body=json.dumps({
        "prompt": "\\n\\nHuman: Explain machine learning\\n\\nAssistant:",
        "max_tokens_to_sample": 300,
        "temperature": 0.7
    })
)

result = json.loads(response['body'].read())
print(result['completion'])

アルゴリズム選択のフローチャート

問題タイプの特定
├─ 画像データ?
│  ├─ Yes → CNN, Image Classification, Rekognition
│  └─ No → 次へ
├─ テキストデータ?
│  ├─ Yes → BlazingText, Transformers, Comprehend
│  └─ No → 次へ
├─ 時系列データ?
│  ├─ Yes → DeepAR, Forecast
│  └─ No → 次へ
└─ 表形式データ?
   ├─ 分類 → XGBoost, Linear Learner
   └─ 回帰 → XGBoost, Linear Learner

重要なポイント

アルゴリズム選択の考慮事項

  1. データの特性: サイズ、型、品質
  2. 問題の種類: 分類、回帰、クラスタリング
  3. 解釈可能性: ビジネス要件
  4. パフォーマンス: 精度、速度
  5. コスト: トレーニング、推論
  6. 保守性: 再トレーニングの容易さ

関連リンク