

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# Neptune ML을 사용한 모델 훈련
<a name="machine-learning-on-graphs-model-training"></a>

모델 훈련을 위해 Neptune에서 내보낸 데이터를 처리한 후 다음과 같은 명령을 사용하여 모델 훈련 작업을 시작할 수 있습니다.

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

```
aws neptunedata start-ml-model-training-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-training job ID)}}" \
  --data-processing-job-id "{{(the data-processing job-id of a completed job)}}" \
  --train-model-s3-location "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer"
```

자세한 내용은 AWS CLI 명령 참조의 [start-ml-model-training-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-training-job.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.start_ml_model_training_job(
    id='{{(a unique model-training job ID)}}',
    dataProcessingJobId='{{(the data-processing job-id of a completed job)}}',
    trainModelS3Location='s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer'
)

print(response)
```

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

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer"
      }'
```

**참고**  
이 예제에서는 자격 AWS 증명이 환경에 구성되어 있다고 가정합니다. {{us-east-1}}을 Neptune 클러스터의 리전으로 바꿉니다.

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

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer"
      }'
```

------

이 명령을 사용하는 방법에 대한 자세한 내용은 실행 중인 작업의 상태를 가져오는 방법, 실행 중인 작업을 중지하는 방법, 실행 중인 모든 작업을 나열하는 방법과 함께 [modeltraining 명령](machine-learning-api-modeltraining.md)에 설명되어 있습니다.

또한 `previousModelTrainingJobId` 제공을 통해 완료된 Neptune ML 모델 훈련 작업의 정보를 사용하여 새 훈련 작업에서 하이퍼파라미터 검색을 가속화할 수 있습니다. 이는 [새 그래프 데이터에 대한 모델 재훈련](machine-learning-overview-evolving-data-incremental.md#machine-learning-overview-model-retraining)뿐만 아니라 [동일한 그래프 데이터에 대한 증분 훈련](machine-learning-overview-evolving-data-incremental.md#machine-learning-overview-incremental)에도 유용합니다. 다음과 같은 명령을 사용하세요.

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

```
aws neptunedata start-ml-model-training-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-training job ID)}}" \
  --data-processing-job-id "{{(the data-processing job-id of a completed job)}}" \
  --train-model-s3-location "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer" \
  --previous-model-training-job-id "{{(the model-training job-id of a completed job)}}"
```

자세한 내용은 AWS CLI 명령 참조의 [start-ml-model-training-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-training-job.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.start_ml_model_training_job(
    id='{{(a unique model-training job ID)}}',
    dataProcessingJobId='{{(the data-processing job-id of a completed job)}}',
    trainModelS3Location='s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer',
    previousModelTrainingJobId='{{(the model-training job-id of a completed job)}}'
)

print(response)
```

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

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer",
        "previousModelTrainingJobId" : "{{(the model-training job-id of a completed job)}}"
      }'
```

**참고**  
이 예제에서는 자격 AWS 증명이 환경에 구성되어 있다고 가정합니다. {{us-east-1}}을 Neptune 클러스터의 리전으로 바꿉니다.

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

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-graph-autotrainer",
        "previousModelTrainingJobId" : "{{(the model-training job-id of a completed job)}}"
      }'
```

------

다음과 같이 `customModelTrainingParameters` 객체를 제공하여 Neptune ML 훈련 인프라에서 자체 모델 구현을 훈련시킬 수 있습니다.

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

```
aws neptunedata start-ml-model-training-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-training job ID)}}" \
  --data-processing-job-id "{{(the data-processing job-id of a completed job)}}" \
  --train-model-s3-location "s3://{{(your Amazon S3 bucket)}}/neptune-model-graph-autotrainer" \
  --model-name "custom" \
  --custom-model-training-parameters '{
    "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
    "trainingEntryPointScript": "{{(your training script entry-point name in the Python module)}}",
    "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
  }'
```

자세한 내용은 AWS CLI 명령 참조의 [start-ml-model-training-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-training-job.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.start_ml_model_training_job(
    id='{{(a unique model-training job ID)}}',
    dataProcessingJobId='{{(the data-processing job-id of a completed job)}}',
    trainModelS3Location='s3://{{(your Amazon S3 bucket)}}/neptune-model-graph-autotrainer',
    modelName='custom',
    customModelTrainingParameters={
        'sourceS3DirectoryPath': 's3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}',
        'trainingEntryPointScript': '{{(your training script entry-point name in the Python module)}}',
        'transformEntryPointScript': '{{(your transform script entry-point name in the Python module)}}'
    }
)

print(response)
```

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

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your Amazon S3 bucket)}}/neptune-model-graph-autotrainer",
        "modelName": "custom",
        "customModelTrainingParameters" : {
          "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
          "trainingEntryPointScript": "{{(your training script entry-point name in the Python module)}}",
          "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
        }
      }'
```

**참고**  
이 예제에서는 자격 AWS 증명이 환경에 구성되어 있다고 가정합니다. {{us-east-1}}을 Neptune 클러스터의 리전으로 바꿉니다.

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

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltraining \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-training job ID)}}",
        "dataProcessingJobId" : "{{(the data-processing job-id of a completed job)}}",
        "trainModelS3Location" : "s3://{{(your Amazon S3 bucket)}}/neptune-model-graph-autotrainer",
        "modelName": "custom",
        "customModelTrainingParameters" : {
          "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
          "trainingEntryPointScript": "{{(your training script entry-point name in the Python module)}}",
          "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
        }
      }'
```

------



실행 중인 작업의 상태를 가져오는 방법, 실행 중인 작업을 중지하는 방법, 실행 중인 모든 작업을 나열하는 방법 등과 같은 자세한 내용은 [modeltraining 명령](machine-learning-api-modeltraining.md)을 참조하세요. 사용자 지정 모델을 구현하고 사용하는 방법에 대한 자세한 내용은 [Neptune ML의 사용자 지정 모델](machine-learning-custom-models.md)을 참조하세요.

**Topics**
+ [Amazon Neptune ML에서의 모델 및 모델 훈련](machine-learning-models-and-training.md)
+ [Neptune ML의 모델 하이퍼파라미터 구성 사용자 지정](machine-learning-customizing-hyperparams.md)
+ [모델 훈련 모범 사례](machine-learning-improve-model-performance.md)