翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
アセットのセンサーで異常検出を有効にする
計算モデルを作成する (AWS CLI)
計算モデルを作成するには、 コマンドラインインターフェイス () AWS を使用しますAWS CLI。計算モデルを定義したら、モデルをトレーニングし、アセットの異常検出を実行するように推論をスケジュールします AWS IoT SiteWise。
-
次の内容
anomaly-detection-computation-model-payload.json
のファイルを作成します。{ "computationModelName": "anomaly-detection-computation-model-name", "computationModelConfiguration": { "anomalyDetection": { "inputProperties": "${input_properties}", "resultProperty": "${result_property}" } }, "computationModelDataBinding": { "input_properties": { "list": [{ "assetModelProperty": { "assetModelId": "
asset-model-id
", "propertyId": "input-property-id-1
" } }, { "assetModelProperty": { "assetModelId": "asset-model-id
", "propertyId": "input-property-id-2
" } } ] }, "result_property": { "assetModelProperty": { "assetModelId": "asset-model-id
", "propertyId": "results-property-id
" } } } } -
次のコマンドを実行して、計算モデルを作成します。
aws iotsitewise create-computation-model \ --cli-input-json
file://anomaly-detection-computation-model-payload.json
ExecuteAction API ペイロードの準備
トレーニングと推論を実行する次のステップは、ExecuteAction API を使用して実行されます。トレーニングと推論の両方が JSON アクションペイロード設定で設定されます。ExecuteAction API を呼び出すときは、アクションペイロードをstringValue
ペイロードの値として指定する必要があります。
ペイロードは API 要件に厳密に従う必要があります。具体的には、値は制御文字 (改行、タブ、キャリッジリターンなど) を含まないフラット文字列である必要があります。
以下のオプションは、有効なアクションペイロードを提供する 2 つの信頼できる方法を提供します。
オプション 1: クリーンペイロードファイルを使用する
次の手順では、クリーンペイロードファイルのステップについて説明します。
-
ファイルをクリーンアップしてコントロール文字を削除します。
tr -d '\n\r\t' < original-action-payload.json > training-or-inference-action-payload.json
-
ファイル を使用して アクションを実行します
@=file://...
。aws iotsitewise execute-action \ --target-resource computationModelId=<
MODEL_ID
> \ --action-definition-id <ACTION_DEFINITION_ID
> \ --resolve-to assetId=<ASSET_ID
> \ --action-payload stringValue@=file://training-or-inference-action-payload.json
オプション 2: エスケープされた引用符を含むインライン文字列
次の手順では、ペイロードをインラインで提供し、中間ファイルを回避する手順について説明します。
-
JSON 文字列内でエスケープされた二重引用符 (
\"
) を使用します。 -
StringValue=..
式全体を二重引用符で囲みます。
例 エスケープされたアクションペイロードの :
aws iotsitewise execute-action \ --target-resource computationModelId=<
MODEL_ID
> \ --action-definition-id <ACTION_DEFINITION_ID
> \ --resolve-to assetId=<ASSET_ID
> \ --action-payload "stringValue={\"exportDataStartTime\":1717225200,\"exportDataEndTime\":1722789360,\"targetSamplingRate\":\"PT1M\"}"
をトレーニングする AWS CLI
計算モデルを作成すると、アセットに対してモデルをトレーニングできます。アセットのモデルをトレーニングするには、次の手順に従います。
-
次のコマンドを実行して、
AWS/ANOMALY_DETECTION_TRAINING
アクションのactionDefinitionId
を検索します。を前のステップで返された IDcomputation-model-id
に置き換えます。aws iotsitewise describe-computation-model \ --computation-model-id
computation-model-id
-
という名前のファイルを作成し
anomaly-detection-training-payload.json
、次の値を追加します。注記
ペイロードは に準拠している必要がありますオプション 1: クリーンペイロードファイルを使用する。
-
StartTime
エポック秒で提供されるトレーニングデータの開始。 -
EndTime
エポック秒で提供されるトレーニングデータの終了。 -
オプションで を設定して高度なトレーニング設定、モデルのパフォーマンスを向上させることができます。
-
(オプション)
TargetSamplingRate
データのサンプリングレート。 -
(オプション) モデルトレーニングを改善
LabelInputConfiguration
するための異常な動作が発生した期間を指定します。 -
(オプション)
ModelEvaluationConfiguration
トレーニングの完了後に指定された時間範囲で推論を実行してモデルのパフォーマンスを評価します。
-
{ "exportDataStartTime": StartTime, "exportDataEndTime": EndTime }
例 トレーニングペイロードの例:
{ "exportDataStartTime": 1717225200, "exportDataEndTime": 1722789360 }
-
-
次のコマンドを実行してトレーニングを開始します。コマンド内の以下のパラメータを置き換えてください。
-
computation-model-id
ターゲット計算モデルの ID を指定します。 -
asset-id
モデルをトレーニングするアセットの ID を指定します。 -
training-action-definition-id
ステップ 1 のAWS/ANOMALY_DETECTION_TRAINING
アクションの ID を持つ 。
aws iotsitewise execute-action \ --target-resource computationModelId=
computation-model-id
\ --resolve-to assetId=asset-id
\ --action-definition-idtraining-action-definition-id
\ --action-payload stringValue@=file://anomaly-detection-training-payload.json
例 実行アクションの :
aws iotsitewise execute-action --target-resource computationModelId=27cb824c-fd84-45b0-946b-0a5b0466d890 --resolve-to assetId=cefd4b68-481b-4735-b466-6a4220cd19ee --action-definition-id e54cea94-5d1c-4230-a59e-4f54dcbc972d --action-payload stringValue@=file://anomaly-detection-training-payload.json
-
-
次のコマンドを実行して、モデルトレーニングプロセスのステータスを確認します。最新の実行概要には、実行ステータス (
RUNNING
/COMPLETED
/) が表示されますFAILED
。aws iotsitewise list-executions \ --target-resource-type COMPUTATION_MODEL \ --target-resource-id
computation-model-id
\ --resolve-to-resource-type ASSET \ --resolve-to-resource-idasset-id
-
次のコマンドを実行して、最新のトレーニング済みモデルの設定を確認します。このコマンドは、少なくとも 1 つのモデルが正常にトレーニングされた場合にのみ出力を生成します。
aws iotsitewise describe-computation-model-execution-summary \ --computation-model-id
computation-model-id
\ --resolve-to-resource-type ASSET \ --resolve-to-resource-idasset-id
-
ComputationModel
が AssetModelProperty を使用している場合は、ListComputationModelResolveToResources API を使用して、実行されたアクションを持つアセットを識別します。aws iotsitewise list-computation-model-resolve-to-resources \ --computation-model-id
computation-model-id
推論の開始と停止 (AWS CLI)
モデルをトレーニングしたら、推論を開始します。これにより、 に異常がないか産業用アセットをアクティブにモニタリング AWS IoT SiteWise するように指示します。
推論を開始する
-
次のコマンドを実行して、
AWS/ANOMALY_DETECTION_INFERENCE
アクションのactionDefinitionId
を検索します。を、前に作成した計算モデルの実際の IDcomputation-model-id
に置き換えます。aws iotsitewise describe-computation-model \ --computation-model-id
computation-model-id
-
ファイルを作成し
anomaly-detection-start-inference-payload.json
、次の値を追加します。注記
ペイロードは に準拠している必要がありますオプション 1: クリーンペイロードファイルを使用する。
"inferenceMode": "START", "dataUploadFrequency": "
DataUploadFrequency
"-
DataUploadFrequency
: 異常検出を実行するために推論スケジュールを実行する頻度を設定します。許可される値はPT5M, PT10M, PT15M, PT30M, PT1H, PT2H..PT12H, PT1D
です。 -
(オプション)
DataDelayOffsetInMinutes
遅延オフセットを分単位で指定します。この値を 0~60 分に設定します。 -
(オプション) アクティブ化
TargetModelVersion
するモデルバージョン。 -
(オプション) シフト設定
weeklyOperatingWindow
で を設定します。 -
オプションで を設定できます高度な推論設定。
-
-
推論を開始するには、次のコマンドを実行します。ペイロードファイルの次のパラメータを置き換えます。
-
computation-model-id
ターゲット計算モデルの ID を指定します。 -
asset-id
モデルがトレーニングされたアセットの ID。 -
inference-action-definition-id
ステップ 1 のAWS/ANOMALY_DETECTION_INFERENCE
アクションの ID を持つ 。
aws iotsitewise execute-action \ --target-resource computationModelId=
computation-model-id
\ --resolve-to assetId=asset-id
\ --action-definition-idinference-action-definition-id
\ --action-payload stringValue@=file://anomaly-detection-inference-payload.json
-
-
次のコマンドを実行して、推論がまだ実行されているかどうかを確認します。推論がアクティブな
TRUE
場合、inferenceTimerActive
フィールドは に設定されます。aws iotsitewise describe-computation-model-execution-summary \ --computation-model-id
computation-model-id
\ --resolve-to-resource-type ASSET \ --resolve-to-resource-idasset-id
-
次のコマンドは、すべての推論実行を一覧表示します。
aws iotsitewise list-executions \ --target-resource-type COMPUTATION_MODEL \ --target-resource-id
computation-model-id
\ --resolve-to-resource-type ASSET \ --resolve-to-resource-idasset-id
-
次のコマンドを実行して、個々の実行を記述します。を前のステップ 5 の ID
execution-id
に置き換えます。aws iotsitewise describe-execution \ --execution-id
execution-id
推論を停止する
-
次のコマンドを実行して、
AWS/ANOMALY_DETECTION_INFERENCE
アクションのactionDefinitionId
を検索します。を、前に作成した計算モデルの実際の IDcomputation-model-id
に置き換えます。aws iotsitewise describe-computation-model \ --computation-model-id
computation-model-id
-
ファイルを作成し
anomaly-detection-stop-inference-payload.json
、次のコードを追加します。{ "inferenceMode": "STOP" }
注記
ペイロードは に準拠している必要がありますオプション 1: クリーンペイロードファイルを使用する。
-
推論を停止するには、次のコマンドを実行します。ペイロードファイルの次のパラメータを置き換えます。
-
computation-model-id
ターゲット計算モデルの ID を指定します。 -
asset-id
モデルがトレーニングされたアセットの ID。 -
inference-action-definition-id
ステップ 1 のAWS/ANOMALY_DETECTION_INFERENCE
アクションの ID を持つ 。
例 stop inference コマンドの :
aws iotsitewise execute-action \ --target-resource computationModelId=
computation-model-id
\ --resolve-to assetId=asset-id
\ --action-definition-idinference-action-definition-id
\ --action-payload stringValue@=file://anomaly-detection-stop-inference-payload.json
-
データバインディングで特定のリソースを使用する計算モデルを検索する
特定のリソースにバインドされている計算モデルを一覧表示するには:
-
アセットモデル (このアセットモデルのプロパティのいずれかがバインドされているすべての計算モデルを取得します)。
-
asset (このアセットのプロパティのいずれかがバインドされているすべての計算モデルを取得します)
-
アセットモデルプロパティ (このプロパティがバインドされているすべての計算モデルを取得します)
-
アセットプロパティ (このプロパティがバインドされているすべての計算モデルを取得します。 これは情報提供を目的としている場合もあれば、ユーザーがこのプロパティを別の計算モデルにバインドしようとしても、既に別の場所にバインドされている場合に必要になる場合もあります)。
ListComputationModelDataBindingUsages API を使用して、アセット (プロパティ) またはアセットモデル (プロパティ) ComputationModelId
をデータバインディングとして使用する のリストを取得します。
次の情報request.json
を使用して を準備します。
{ "dataBindingValueFilter": { "asset": { "assetId": "<string>" } // OR "assetModel": { "assetModelId": "<string>" } // OR "assetProperty": { "assetId": "<string>", "propertyId": "<string>" } // OR "assetModelProperty": { "assetModelId": "<string>", "propertyId": "<string>" } }, "nextToken": "<string>", "maxResults": "<number>" }
list-computation-model-data-binding-usages
コマンドを使用して、アセットまたはアセットモデルをデータバインディングとしてモデルを取得します。
aws iotsitewise list-computation-model-data-binding-usages \ --cli-input-json file:
//request.json