

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

# 照会のための推論エンドポイントの作成
<a name="machine-learning-on-graphs-inference-endpoint"></a>

推論エンドポイントを使用すると、モデルトレーニングプロセスによって構築された 1 つの特定のモデルを照会できます。エンドポイントは、トレーニングプロセスで生成できた特定のタイプの最もパフォーマンスの高いモデルにアタッチします。エンドポイントは Neptune からの Gremlin クエリを受け入れ、クエリ内の入力に対するモデルの予測を返すことができます。推論エンドポイントを作成した後も、削除するまでアクティブなままになります。

## Neptune ML の推論エンドポイントの管理
<a name="machine-learning-on-graphs-endpoint-managing"></a>

Neptune からエクスポートしたデータのモデルトレーニングが完了したら、次のようなコマンドを使用して推論エンドポイントを作成できます。

------
#### [ AWS CLI ]

```
aws neptunedata create-ml-endpoint \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique ID for the new endpoint)}}" \
  --ml-model-training-job-id "{{(the model-training job-id of a completed job)}}"
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[create-ml-endpoint](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/create-ml-endpoint.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.create_ml_endpoint(
    id='{{(a unique ID for the new endpoint)}}',
    mlModelTrainingJobId='{{(the model-training job-id of a completed job)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/endpoints \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique ID for the new endpoint)}}",
        "mlModelTrainingJobId": "{{(the model-training job-id of a completed job)}}"
      }'
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/endpoints \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique ID for the new endpoint)}}",
        "mlModelTrainingJobId": "{{(the model-training job-id of a completed job)}}"
      }'
```

------

また、ほぼ同じ方法で、完成したモデル変換ジョブによって作成されたモデルから推論エンドポイントを作成することもできます。

------
#### [ AWS CLI ]

```
aws neptunedata create-ml-endpoint \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique ID for the new endpoint)}}" \
  --ml-model-transform-job-id "{{(the model-transform job-id of a completed job)}}"
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[create-ml-endpoint](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/create-ml-endpoint.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.create_ml_endpoint(
    id='{{(a unique ID for the new endpoint)}}',
    mlModelTransformJobId='{{(the model-transform job-id of a completed job)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/endpoints \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique ID for the new endpoint)}}",
        "mlModelTransformJobId": "{{(the model-transform job-id of a completed job)}}"
      }'
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/endpoints \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique ID for the new endpoint)}}",
        "mlModelTransformJobId": "{{(the model-transform job-id of a completed job)}}"
      }'
```

------

これらのコマンドの使用方法の詳細については、[エンドポイントコマンド](machine-learning-api-endpoints.md) を参照してください。また、エンドポイントのステータスの取得方法、エンドポイントの削除方法、およびすべての推論エンドポイントの一覧表示方法に関する情報も記載されています。