

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 結果の解釈
<a name="model-monitor-interpreting-results"></a>

ベースライン作成ジョブを実行し、データセットの統計と制約を取得した後は、モニタリングジョブを実行して統計を計算し、ベースライン制約に関連して発生した違反を一覧表示できます。Amazon CloudWatch メトリクスは、デフォルトではユーザーのアカウントにも報告されます。Amazon SageMaker Studio でモニタリング結果を表示する方法については、「[Amazon SageMaker Studio でリアルタイムエンドポイントの結果を視覚化する](model-monitor-interpreting-visualize-results.md)」を参照してください。

## 実行を一覧表示する
<a name="model-monitor-interpreting-results-list-executions"></a>

スケジュールは、指定された間隔でジョブのモニタリングを開始します。次のコードは、 最新の 5 つの実行を一覧表示します。時間単位のスケジュールを作成した後にこのコードを実行している場合、実行は空である可能性があり、実行の開始を確認するために時間境界 (UTC) を越えるまで待たなければならないことがあります。次のコードには、待機のためのロジックが含まれています。

```
mon_executions = my_default_monitor.list_executions()
print("We created a hourly schedule above and it will kick off executions ON the hour (plus 0 - 20 min buffer.\nWe will have to wait till we hit the hour...")

while len(mon_executions) == 0:
    print("Waiting for the 1st execution to happen...")
    time.sleep(60)
    mon_executions = my_default_monitor.list_executions()
```

## 特定の実行を確認する
<a name="model-monitor-interpreting-results-inspect-specific-execution"></a>

 

前のステップで、最後に完了したスケジュール実行または失敗したスケジュール実行を選択しました。何がうまくいったか、うまくいかなかったかを調べることができます。ターミナルの状態は次のとおりです。
+ `Completed` - モニタリングの実行が完了し、違反レポートに問題は見つかりませんでした。
+ `CompletedWithViolations` - 実行は完了しましたが、制約違反が検出されました。
+ `Failed` - モニタリングの実行に失敗しました。クライアントエラー (ロールの問題など) やインフラストラクチャの問題が原因である可能性があります。原因を特定するには、`FailureReason` および `ExitMessage` を確認してください。

```
latest_execution = mon_executions[-1] # latest execution's index is -1, previous is -2 and so on..
time.sleep(60)
latest_execution.wait(logs=False)

print("Latest execution status: {}".format(latest_execution.describe()['ProcessingJobStatus']))
print("Latest execution result: {}".format(latest_execution.describe()['ExitMessage']))

latest_job = latest_execution.describe()
if (latest_job['ProcessingJobStatus'] != 'Completed'):
        print("====STOP==== \n No completed executions to inspect further. Please wait till an execution completes or investigate previously reported failures.")
```

```
report_uri=latest_execution.output.destination
print('Report Uri: {}'.format(report_uri))
```

## 生成されたレポートを一覧表示する
<a name="model-monitor-interpreting-results-list-generated-reports"></a>

次のコードを使用して、生成されたレポートを一覧表示します。

```
from urllib.parse import urlparse
s3uri = urlparse(report_uri)
report_bucket = s3uri.netloc
report_key = s3uri.path.lstrip('/')
print('Report bucket: {}'.format(report_bucket))
print('Report key: {}'.format(report_key))

s3_client = boto3.Session().client('s3')
result = s3_client.list_objects(Bucket=report_bucket, Prefix=report_key)
report_files = [report_file.get("Key") for report_file in result.get('Contents')]
print("Found Report Files:")
print("\n ".join(report_files))
```

## 違反レポート
<a name="model-monitor-interpreting-results-violations-report"></a>

ベースラインと比較して、違反がある場合はこれらの違反を含む違反レポートが生成されます。次のコードを使用して、違反を一覧表示します。

```
violations = my_default_monitor.latest_monitoring_constraint_violations()
pd.set_option('display.max_colwidth', -1)
constraints_df = pd.io.json.json_normalize(violations.body_dict["violations"])
constraints_df.head(10)
```

これは、表形式データを含むデータセットにのみ適用されます。次のスキーマファイルは、計算される統計と監視される違反を指定します。

表形式データセットの出力ファイル


| ファイル名 | 説明 | 
| --- | --- | 
| statistics.json |  分析されるデータセット内の各フィーチャの列指向統計を含みます。このファイルのスキーマについては、次のトピックを参照してください。  このファイルは、データ品質モニタリングでのみ作成されます。   | 
| constraint\$1violations.json |  `baseline_constaints` および `baseline_statistics` パスで指定されたベースライン統計および制約ファイルと比較した、この現在のデータセットで検出された違反のリストを含みます。  | 

デフォルトで、[Amazon SageMaker Model Monitor のビルド済みコンテナ](model-monitor-pre-built-container.md) は各特徴の Amazon CloudWatch メトリクスのセットを保存します。

コンテナコードは `/opt/ml/output/metrics/cloudwatch` に CloudWatch メトリクスを出力できます。