

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

# 데이터 캡처
<a name="model-monitor-data-capture"></a>

엔드포인트로 들어오는 입력과 Amazon S3에 배포된 모델의 추론 출력을 기록하기 위해 데이터 캡처라는 특징을 활성화할 수 있습니다.** 데이터 캡처는 일반적으로 훈련, 디버깅 및 모니터링에 사용할 수 있는 정보를 기록하는 데 사용됩니다.** Amazon SageMaker 모델 모니터는 캡처된 이 데이터를 자동으로 구문 분석하고 이 데이터의 지표을 사용자가 모델에 대해 생성한 기준과 비교합니다. 모델 모니터링에 대한 자세한 내용은 [Amazon SageMaker Model Monitor를 사용한 데이터 및 모델 품질 모니터링](model-monitor.md)섹션을 참조하세요.

 AWS SDK for Python (Boto) 또는 SageMaker Python SDK를 사용하여 실시간 및 배치 모델 모니터링 모드 모두에 대해 *데이터 캡처*를 구현할 수 있습니다. 실시간 엔드포인트의 경우, 엔드포인트를 생성할 때 데이터 캡처 구성을 지정해야 합니다.** 실시간 엔드포인트의 지속적 특성 때문에 특정 시간에 데이터 캡처를 켜거나 끄거나 샘플링 빈도를 변경하는 추가 옵션을 구성할 수 있습니다. 추론 데이터를 암호화하도록 선택할 수도 있습니다.

배치 변환 작업의 경우 정기적이고 주기적인 배치 변환 작업에 대해 일정에 따른 모델 모니터링 또는 지속적인 모델 모니터링을 실행하기 위해 데이터 캡처를 활성화할 수 있습니다.** 배치 변환 작업을 생성할 때 데이터 캡처 구성을 지정해야 합니다.** 이 구성에서는 출력과 함께 암호화를 켜거나 추론 ID를 생성할 수 있으며, 이렇게 하면 캡처한 데이터를 Ground Truth 데이터와 일치시키는 데 도움이 됩니다.

# 실시간 엔드포인트에서 데이터 캡처
<a name="model-monitor-data-capture-endpoint"></a>

**참고**  
데이터 캡처는 추론 요청에 영향이 없도록 하기 위해 디스크 사용량이 많은 경우 요청 캡처를 중단합니다. 데이터 캡처가 요청을 계속 캡처하도록 하려면, 디스크 사용률을 75% 미만으로 유지하는 것이 좋습니다.

실시간 엔드포인트의 데이터를 캡처하려면 SageMaker AI 호스팅 서비스를 사용하여 모델을 배포해야 합니다. 이를 위해서는 SageMaker AI 모델을 생성하고, 엔드포인트 구성을 정의하고, HTTPS 엔드포인트를 생성해야 합니다.

데이터 캡처를 켜는 데 필요한 단계는 AWS SDK for Python (Boto) 을 사용하든 SageMaker Python SDK를 사용하든 비슷합니다. AWS SDK를 사용하는 경우 [CreateEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpointConfig.html) 메서드 내에서 필수 필드와 함께 [DataCaptureConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DataCaptureConfig.html) 사전을 정의하여 데이터 캡처를 켭니다. SageMaker Python SDK를 사용하는 경우 [DataCaptureConfig](https://sagemaker.readthedocs.io/en/stable/api/inference/model_monitor.html#sagemaker.model_monitor.data_capture_config.DataCaptureConfig) 클래스를 가져와서 이 클래스에서 인스턴스를 초기화하세요. 그런 다음 이 객체를 `sagemaker.model.Model.deploy()`메서드의 `DataCaptureConfig`파라미터에 전달합니다.

이전 코드 스니펫을 사용하려면 예시 코드의 *기울임꼴 자리표시자 텍스트*를 자신의 정보로 대체합니다.

## 데이터 캡처 활성화 방법
<a name="model-monitor-data-capture-defing.title"></a>

데이터 캡처 구성을 지정합니다. 이 구성을 사용하여 요청 페이로드, 응답 페이로드 또는 둘 다를 캡처할 수 있습니다. 진행 코드 조각은 AWS SDK for Python (Boto) 및 SageMaker AI Python SDK를 사용하여 데이터 캡처를 활성화하는 방법을 보여줍니다.

**참고**  
요청 또는 응답 페이로드를 캡처하기 위해 모델 모니터를 사용할 필요는 없습니다.

------
#### [ AWS SDK for Python (Boto) ]

`CreateEndpointConfig` 메서드를 사용하여 엔드포인트를 생성할 때 [DataCaptureConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DataCaptureConfig.html) 사전으로 캡처하려는 데이터를 구성하세요. `EnableCapture`를 부울 값 True로 설정합니다. 또한 다음과 같은 필수 파라미터를 제공합니다.
+ `EndpointConfigName`: 엔드포인트 구성의 이름입니다. `CreateEndpoint` 요청 시 이 이름을 사용하게 됩니다.
+ `ProductionVariants`: 이 엔드포인트에서 호스팅하려는 모델 모니터입니다. 각 모델의 사전 데이터 유형을 정의합니다.
+ `DataCaptureConfig`: 샘플링할 데이터의 초기 백분율에 해당하는 정수 값(`InitialSamplingPercentage`), 캡처된 데이터를 저장할 Amazon S3 URI, 캡처 옵션(`CaptureOptions`) 목록을 지정하는 사전 데이터 유형입니다. `CaptureOptions` 목록 내에서 `CaptureMode`에 대해 `Input`또는 `Output`중 하나를 지정합니다.

키-값 페어의 인수를 `CaptureContentTypeHeader` 사전에 전달하여 SageMaker AI가 캡처된 데이터를 인코딩하는 방법을 선택적으로 지정할 수 있습니다.

```
# Create an endpoint config name.
endpoint_config_name = '<endpoint-config-name>'

# The name of the production variant.
variant_name = '<name-of-production-variant>'                   
  
# The name of the model that you want to host. 
# This is the name that you specified when creating the model.
model_name = '<The_name_of_your_model>'

instance_type = '<instance-type>'
#instance_type='ml.m5.xlarge' # Example    

# Number of instances to launch initially.
initial_instance_count = <integer>

# Sampling percentage. Choose an integer value between 0 and 100
initial_sampling_percentage = <integer>                                                                                                                                                                                                                        

# The S3 URI containing the captured data
s3_capture_upload_path = 's3://<bucket-name>/<data_capture_s3_key>'

# Specify either Input, Output, or both
capture_modes = [ "Input",  "Output" ] 
#capture_mode = [ "Input"] # Example - If you want to capture input only
                            
endpoint_config_response = sagemaker_client.create_endpoint_config(
    EndpointConfigName=endpoint_config_name, 
    # List of ProductionVariant objects, one for each model that you want to host at this endpoint.
    ProductionVariants=[
        {
            "VariantName": variant_name, 
            "ModelName": model_name, 
            "InstanceType": instance_type, # Specify the compute instance type.
            "InitialInstanceCount": initial_instance_count # Number of instances to launch initially.
        }
    ],
    DataCaptureConfig= {
        'EnableCapture': True, # Whether data should be captured or not.
        'InitialSamplingPercentage' : initial_sampling_percentage,
        'DestinationS3Uri': s3_capture_upload_path,
        'CaptureOptions': [{"CaptureMode" : capture_mode} for capture_mode in capture_modes] # Example - Use list comprehension to capture both Input and Output
    }
)
```

다른 엔드포인트 구성 옵션에 대한 자세한 내용은 [Amazon SageMaker AI 서비스 API 참조 가이드](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_Operations_Amazon_SageMaker_Service.html)의 [CreateEndpointConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpointConfig.html) API를 참조하세요.

------
#### [ SageMaker Python SDK ]

[sagemaker.model\$1monitor](https://sagemaker.readthedocs.io/en/stable/api/inference/model_monitor.html) 모듈에서 `DataCaptureConfig`클래스를 가져옵니다. `EnableCapture`를 부울 값 `True`로 설정하여 데이터 캡처를 활성화합니다.

선택적으로 다음 파라미터에 대한 인수를 제공합니다.
+ `SamplingPercentage`: 샘플링할 데이터의 백분율에 해당하는 정수 값입니다. 샘플링 백분율을 제공하지 않는 경우 SageMaker AI는 데이터의 기본값인 20(20%)을 샘플링합니다.
+ `DestinationS3Uri`: SageMaker AI가 캡처된 데이터를 저장하는 데 사용할 Amazon S3 URI입니다. 제공하지 않는 경우 SageMaker AI는 캡처된 데이터를 `"s3://<default-session-bucket>/ model-monitor/data-capture"`에 저장합니다.

```
from sagemaker.model_monitor import DataCaptureConfig

# Set to True to enable data capture
enable_capture = True

# Optional - Sampling percentage. Choose an integer value between 0 and 100
sampling_percentage = <int> 
# sampling_percentage = 30 # Example 30%

# Optional - The S3 URI of stored captured-data location
s3_capture_upload_path = 's3://<bucket-name>/<data_capture_s3_key>'

# Specify either Input, Output or both. 
capture_modes = ['REQUEST','RESPONSE'] # In this example, we specify both
# capture_mode = ['REQUEST'] # Example - If you want to only capture input.

# Configuration object passed in when deploying Models to SM endpoints
data_capture_config = DataCaptureConfig(
    enable_capture = enable_capture, 
    sampling_percentage = sampling_percentage, # Optional
    destination_s3_uri = s3_capture_upload_path, # Optional
    capture_options = ["REQUEST", "RESPONSE"],
)
```

------

## 모델 배포
<a name="model-monitor-data-capture-deploy"></a>

모델을 배포하고 `DataCapture`가 활성화된 HTTPS 엔드포인트를 생성합니다.

------
#### [ AWS SDK for Python (Boto3) ]

SageMaker AI에 엔드포인트 구성을 제공합니다. 서비스는 ML 컴퓨팅 인스턴스를 시작하고 구성에서 지정된 대로 모델을 배포합니다.

모델 및 엔드포인트 구성이 완료되면 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html)API를 사용하여 엔드포인트를 생성합니다. 엔드포인트 이름은 AWS 계정의 AWS 리전 내에서 고유해야 합니다.

다음은 요청에 지정된 엔드포인트 구성을 사용하여 엔드포인트를 생성합니다. Amazon SageMaker AI는 엔드포인트를 사용하여 리소스를 프로비저닝하고 모델을 배포합니다.

```
# The name of the endpoint. The name must be unique within an AWS Region in your AWS account.
endpoint_name = '<endpoint-name>' 

# The name of the endpoint configuration associated with this endpoint.
endpoint_config_name='<endpoint-config-name>'

create_endpoint_response = sagemaker_client.create_endpoint(
                                            EndpointName=endpoint_name, 
                                            EndpointConfigName=endpoint_config_name)
```

자세한 정보는 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateEndpoint.html)API를 참조하세요.

------
#### [ SageMaker Python SDK ]

엔드포인트의 이름을 정의합니다. 이 단계는 선택 사항입니다. 이름을 제공하지 않는 경우 SageMaker AI는 고유한 이름을 생성합니다.

```
from datetime import datetime

endpoint_name = f"DEMO-{datetime.utcnow():%Y-%m-%d-%H%M}"
print("EndpointName =", endpoint_name)
```

모델 객체의 내장 `deploy()`메서드를 사용하여 실시간 HTTPS 엔드포인트에 모델을 배포합니다. `initial_instance_count` 필드에 엔드포인트를 실행할 초기 인스턴스 수와 함께 `instance_type`필드에 이 모델을 배포할 Amazon EC2 인스턴스 유형의 이름을 입력합니다.

```
initial_instance_count=<integer>
# initial_instance_count=1 # Example

instance_type='<instance-type>'
# instance_type='ml.m4.xlarge' # Example

# Uncomment if you did not define this variable in the previous step
#data_capture_config = <name-of-data-capture-configuration>

model.deploy(
    initial_instance_count=initial_instance_count,
    instance_type=instance_type,
    endpoint_name=endpoint_name,
    data_capture_config=data_capture_config
)
```

------

## 캡처된 데이터 보기
<a name="model-monitor-data-capture-view"></a>

SageMaker Python SDK [예측기](https://sagemaker.readthedocs.io/en/stable/api/inference/predictors.html) 클래스에서 예측기 객체를 생성합니다. `Predictor` 클래스에서 반환된 객체를 사용하여 향후 단계에서 엔드포인트를 호출합니다. 엔드포인트 이름(이전에 `endpoint_name`으로 정의됨)을 serializer 및 deserializer용 serializer 및 deserializer 객체와 함께 제공합니다. Serializer 유형에 대한 자세한 내용은 [SageMaker AI Python SDK](https://sagemaker.readthedocs.io/en/stable/index.html)의 [Serializers](https://sagemaker.readthedocs.io/en/stable/api/inference/serializers.html) 클래스를 참조하세요.

```
from sagemaker.predictor import Predictor
from sagemaker.serializers import <Serializer>
from sagemaker.deserializers import <Deserializers>

predictor = Predictor(endpoint_name=endpoint_name,
                      serializer = <Serializer_Class>,
                      deserializer = <Deserializer_Class>)

# Example
#from sagemaker.predictor import Predictor
#from sagemaker.serializers import CSVSerializer
#from sagemaker.deserializers import JSONDeserializer

#predictor = Predictor(endpoint_name=endpoint_name,
#                      serializer=CSVSerializer(),
#                      deserializer=JSONDeserializer())
```

진행 코드 예시 시나리오에서는 `validation_with_predictions`이라는 CSV 파일에 로컬로 저장한 샘플 유효성 검사 데이터를 사용하여 엔드포인트를 호출합니다. 샘플 검증 세트에는 각 입력에 대한 레이블이 포함되어 있습니다.

with 문의 처음 몇 줄은 먼저 검증 세트 CSV 파일을 연 다음 파일 내의 각 행을 쉼표 문자 `","`로 분할한 다음 반환된 두 객체를 레이블 및 input\$1cols 변수에 저장합니다. 각 행에 대해 입력(`input_cols`)은 예측 변수(`predictor`)의 객체 내장 메서드 `Predictor.predict()`로 전달됩니다.

모델이 확률을 반환한다고 가정해 보겠습니다. 확률의 범위는 0\$11.0입니다. 모델에서 반환되는 확률이 80%(0.8)보다 큰 경우 예측에 정수 값 레이블 1을 할당합니다. 그렇지 않으면 예측에 정수 값 레이블 0을 할당합니다.

```
from time import sleep

validate_dataset = "validation_with_predictions.csv"

# Cut off threshold of 80%
cutoff = 0.8

limit = 200  # Need at least 200 samples to compute standard deviations
i = 0
with open(f"test_data/{validate_dataset}", "w") as validation_file:
    validation_file.write("probability,prediction,label\n")  # CSV header
    with open("test_data/validation.csv", "r") as f:
        for row in f:
            (label, input_cols) = row.split(",", 1)
            probability = float(predictor.predict(input_cols))
            prediction = "1" if probability > cutoff else "0"
            baseline_file.write(f"{probability},{prediction},{label}\n")
            i += 1
            if i > limit:
                break
            print(".", end="", flush=True)
            sleep(0.5)
print()
print("Done!")
```

이전 단계에서 데이터 캡처를 활성화했으므로 요청 및 응답 페이로드는 일부 추가 메타데이터와 함께 `DataCaptureConfig`에서 지정한 Amazon S3 위치에 저장됩니다. 캡처 데이터를 Amazon S3로 전송하는 데 몇 분이 걸릴 수 있습니다.

캡처된 데이터는 Amazon S3에 저장된 데이터 캡처 파일을 나열하는 방식으로 확인하세요. 해당 Amazon S3 경로의 형식은 `s3:///{endpoint-name}/{variant-name}/yyyy/mm/dd/hh/filename.jsonl`입니다.

호출이 발생한 시간을 기준으로 구성된 서로 다른 기간의 서로 다른 파일을 볼 수 있습니다. 다음을 실행하여 단일 캡처 파일의 내용을 인쇄합니다.

```
print("\n".join(capture_file[-3:-1]))
```

그러면 SageMaker AI에 특정한 JSON 줄 형식의 파일이 반환됩니다. 다음은 `csv/text`데이터를 사용하여 호출한 실시간 엔드포인트에서 가져온 응답 샘플입니다.

```
{"captureData":{"endpointInput":{"observedContentType":"text/csv","mode":"INPUT",
"data":"69,0,153.7,109,194.0,105,256.1,114,14.1,6,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0\n",
"encoding":"CSV"},"endpointOutput":{"observedContentType":"text/csv; charset=utf-8","mode":"OUTPUT","data":"0.0254181120544672","encoding":"CSV"}},
"eventMetadata":{"eventId":"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee","inferenceTime":"2022-02-14T17:25:49Z"},"eventVersion":"0"}
{"captureData":{"endpointInput":{"observedContentType":"text/csv","mode":"INPUT",
"data":"94,23,197.1,125,214.5,136,282.2,103,9.5,5,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,1\n",
"encoding":"CSV"},"endpointOutput":{"observedContentType":"text/csv; charset=utf-8","mode":"OUTPUT","data":"0.07675473392009735","encoding":"CSV"}},
"eventMetadata":{"eventId":"aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee","inferenceTime":"2022-02-14T17:25:49Z"},"eventVersion":"0"}
```

진행 예시에서 `capture_file`객체는 목록 유형입니다. 목록의 첫 번째 요소를 인덱싱하여 단일 추론 요청을 확인합니다.

```
# The capture_file object is a list. Index the first element to view a single inference request  
print(json.dumps(json.loads(capture_file[0]), indent=2))
```

이는 다음과 비슷한 응답을 반환합니다. 반환되는 값은 엔드포인트 구성, SageMaker AI 모델 및 캡처된 데이터에 따라 달라집니다.

```
{
  "captureData": {
    "endpointInput": {
      "observedContentType": "text/csv", # data MIME type
      "mode": "INPUT",
      "data": "50,0,188.9,94,203.9,104,151.8,124,11.6,8,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,0,1,0\n",
      "encoding": "CSV"
    },
    "endpointOutput": {
      "observedContentType": "text/csv; charset=character-encoding",
      "mode": "OUTPUT",
      "data": "0.023190177977085114",
      "encoding": "CSV"
    }
  },
  "eventMetadata": {
    "eventId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
    "inferenceTime": "2022-02-14T17:25:06Z"
  },
  "eventVersion": "0"
}
```

# 배치 변환 작업에서 데이터 캡처
<a name="model-monitor-data-capture-batch"></a>

 배치 변환 작업에 대한 데이터 캡처를 활성화하는 데 필요한 단계는 AWS SDK for Python (Boto) 를 사용하든 SageMaker Python SDK를 사용하든 비슷합니다. AWS SDK를 사용하는 경우 `CreateTransformJob` 메서드 내에서 필수 필드와 함께 [DataCaptureConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DataCaptureConfig.html) 사전을 정의하여 데이터 캡처를 켭니다. SageMaker AI Python SDK를 사용하는 경우 `BatchDataCaptureConfig` 클래스를 가져와서 이 클래스에서 인스턴스를 초기화하세요. 그런 다음 이 객체를 변환 작업 인스턴스의 `batch_data_capture_config`파라미터에 전달합니다.

 다음 코드 스니펫을 사용하려면 예시 코드의 *기울임꼴 자리표시자 텍스트*를 자신의 정보로 대체합니다.

## 데이터 캡처 활성화 방법
<a name="data-capture-batch-enable"></a>

 변환 작업을 시작할 때 데이터 캡처 구성을 지정하세요. AWS SDK for Python (Boto3) 를 사용하든 SageMaker Python SDK를 사용하든, 변환 작업이 캡처된 데이터를 로깅할 디렉터리인 `DestinationS3Uri` 인수를 제공해야 합니다. 선택적으로 다음 파라미터를 지정할 수도 있습니다.
+  `KmsKeyId`: 캡처된 데이터를 암호화하는 데 사용되는 AWS KMS 키입니다.
+  `GenerateInferenceId`: 데이터를 캡처할 때 변환 작업에서 출력에 추론 ID와 시간을 추가할지 여부를 나타내는 부울 플래그입니다. 이는 Ground Truth 데이터를 수집해야 하는 모델 품질 모니터링에 유용합니다. 추론 ID 및 시간은 캡처된 데이터를 Ground Truth 데이터와 일치시키는 데 도움이 됩니다.

------
#### [ AWS SDK for Python (Boto3) ]

 `CreateTransformJob` 메서드를 사용하여 변환 작업을 생성할 때 [DataCaptureConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_DataCaptureConfig.html) 사전으로 캡처하려는 데이터를 구성하세요.

```
input_data_s3_uri = "s3://input_S3_uri"
output_data_s3_uri = "s3://output_S3_uri"
data_capture_destination = "s3://captured_data_S3_uri"

model_name = "model_name"

sm_client.create_transform_job(
    TransformJobName="transform_job_name",
    MaxConcurrentTransforms=2,
    ModelName=model_name,
    TransformInput={
        "DataSource": {
            "S3DataSource": {
                "S3DataType": "S3Prefix",
                "S3Uri": input_data_s3_uri,
            }
        },
        "ContentType": "text/csv",
        "CompressionType": "None",
        "SplitType": "Line",
    },
    TransformOutput={
        "S3OutputPath": output_data_s3_uri,
        "Accept": "text/csv",
        "AssembleWith": "Line",
    },
    TransformResources={
        "InstanceType": "ml.m4.xlarge",
        "InstanceCount": 1,
    },
    DataCaptureConfig={
       "DestinationS3Uri": data_capture_destination,
       "KmsKeyId": "kms_key",
       "GenerateInferenceId": True,
    }
    )
```

------
#### [ SageMaker Python SDK ]

 [sagemaker.model\$1monitor](https://sagemaker.readthedocs.io/en/stable/api/inference/model_monitor.html)에서 `BatchDataCaptureConfig`클래스를 가져옵니다.

```
from sagemaker.transformer import Transformer
from sagemaker.inputs import BatchDataCaptureConfig

# Optional - The S3 URI of where to store captured data in S3
data_capture_destination = "s3://captured_data_S3_uri"

model_name = "model_name"

transformer = Transformer(model_name=model_name, ...)
transform_arg = transformer.transform(
    batch_data_capture_config=BatchDataCaptureConfig(
        destination_s3_uri=data_capture_destination,
        kms_key_id="kms_key",
        generate_inference_id=True,
    ),
    ...
)
```

------

## 캡처된 데이터를 보는 방법
<a name="data-capture-batch-view"></a>

 변환 작업이 완료되면 캡처된 데이터는 데이터 캡처 구성과 함께 제공된 `DestinationS3Uri`아래 기록됩니다. `DestinationS3Uri`, `/input`, 및 `/output`아래에는 두 개의 하위 디렉토리가 있습니다. `DestinationS3Uri`가 `s3://my-data-capture`인 경우 변환 작업은 다음 디렉터리를 만듭니다.
+  `s3://my-data-capture/input`: 변환 작업의 캡처된 입력 데이터입니다.
+  `s3://my-data-capture/output`: 변환 작업의 캡처된 출력 데이터입니다.

 데이터 중복을 방지하기 위해 이전 두 디렉터리에 있는 캡처된 데이터는 매니페스트입니다. 각 매니페스트는 원본 객체의 Amazon S3 위치가 포함된 JSONL 파일입니다. 매니페스트 파일은 다음 예시와 같습니다.

```
# under "/input" directory
[
    {"prefix":"s3://input_S3_uri/"},
    "dummy_0.csv",
    "dummy_1.csv",
    "dummy_2.csv",
    ...
]

# under "/output" directory
[
    {"prefix":"s3://output_S3_uri/"},
    "dummy_0.csv.out",
    "dummy_1.csv.out",
    "dummy_2.csv.out",
    ...
]
```

 변환 작업은 캡처 시기를 나타내는 *yyyy/mm/dd/hh* S3 접두사를 사용하여 이러한 매니페스트를 구성하고 레이블을 지정합니다. 이렇게 하면 모델 모니터가 분석할 데이터의 적절한 부분을 결정하는 데 도움이 됩니다. 예를 들어, 2022-8-26 13PM UTC에 변환 작업을 시작하면 캡처된 데이터에 `2022/08/26/13/`접두사 문자열이 레이블로 지정됩니다.

## 추론 ID 생성
<a name="data-capture-batch-inferenceid"></a>

 변환 작업에 대해 `DataCaptureConfig`을 구성할 때 부울 플래그 `GenerateInferenceId`를 켤 수 있습니다. 이는 사용자가 수집한 Ground Truth 데이터가 필요한 모델 품질 및 모델 바이어스 모니터링 작업을 실행해야 할 때 특히 유용합니다. 모델 모니터는 추론 ID를 사용하여 캡처된 데이터와 Ground Truth 데이터를 일치시킵니다. Ground Truth 수집에 대한 자세한 내용은 [Ground Truth 레이블을 수집하여 예측과 병합](model-monitor-model-quality-merge.md)섹션을 참조하세요. `GenerateInferenceId`가 켜져 있으면 변환 출력에 추론 ID(임의 UUID)와 각 레코드의 변환 작업 시작 시간(UTC)이 추가됩니다. 모델 품질 및 모델 바이어스 모니터링을 실행하려면 이 두 값이 필요합니다. Ground Truth 데이터를 생성할 때는 출력 데이터와 일치하도록 동일한 추론 ID를 제공해야 합니다. 현재 이 기능은 CSV, JSON 및 JSONL 형식의 변환 출력을 지원합니다.

 변환 출력이 CSV 형식인 경우 출력 파일은 다음 예시와 같습니다.

```
0, 1f1d57b1-2e6f-488c-8c30-db4e6d757861,2022-08-30T00:49:15Z
1, 22445434-0c67-45e9-bb4d-bd1bf26561e6,2022-08-30T00:49:15Z
...
```

 마지막 두 열은 추론 ID와 변환 작업 시작 시간입니다. 수정할 수 없습니다. 나머지 열은 변환 작업 출력입니다.

 변환 출력이 JSON 또는 JSONL 형식인 경우 출력 파일은 다음 예시와 같습니다.

```
{"output": 0, "SageMakerInferenceId": "1f1d57b1-2e6f-488c-8c30-db4e6d757861", "SageMakerInferenceTime": "2022-08-30T00:49:15Z"}
{"output": 1, "SageMakerInferenceId": "22445434-0c67-45e9-bb4d-bd1bf26561e6", "SageMakerInferenceTime": "2022-08-30T00:49:15Z"}
...
```

 예약되어 있는 두 개의 추가된 필드 `SageMakerInferenceId`와 `SageMakerInferenceTime`이 있습니다. 모델 품질 또는 모델 바이어스 모니터링을 실행해야 하는 경우에는 이 필드를 수정하지 마세요.이는 병합 작업에 필요합니다.