모니터링 기능

Vertex AI Feature Store를 사용하면 특성 모니터링 작업을 예약하고 실행하여 특성 데이터를 모니터링하고, 특성 통계를 가져오고, 특성 드리프트를 감지할 수 있습니다. 특성 레지스트리에 특성 데이터 소스를 등록한 경우에만 특성 데이터를 모니터링할 수 있습니다.

지형지물 데이터를 모니터링하려면 FeatureGroup 리소스 아래에 FeatureMonitor 리소스를 만들면 됩니다. FeatureMonitor 리소스를 만드는 동안 지형지물 데이터에서 주기적으로 모니터링 작업을 실행하도록 모니터링 일정을 구성할 수 있습니다. 또는 지형지물 모니터링 작업을 수동으로 실행하여 모니터링 일정 외부에서 지형지물 데이터를 모니터링할 수 있습니다.

실행되는 각 모니터링 작업에 대해 Vertex AI Feature Store는 FeatureMonitorJob 리소스를 생성합니다. 이 리소스를 검색하여 특성 통계와 특성 데이터에서 감지된 드리프트에 관한 정보를 확인할 수 있습니다.

시작하기 전에

Vertex AI Feature Store를 사용하여 기능을 모니터링하기 전에 이 섹션에 나열된 기본 요건을 완료하세요.

지형지물 데이터 소스 등록

특성 그룹특성을 만들어 BigQuery의 특성 데이터 소스를 특성 레지스트리에 등록합니다. 지형지물 통계를 검색하고 모니터링하는 데 사용되는 FeatureMonitor 리소스는 지형지물 그룹과 연결됩니다.

Vertex AI에 인증

아직 Vertex AI에 인증하지 않았다면 인증을 진행합니다.

Select the tab for how you plan to use the samples on this page:

Python

로컬 개발 환경에서 이 페이지의 Python 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.

  1. Install the Google Cloud CLI.
  2. To initialize the gcloud CLI, run the following command:

    gcloud init
  3. If you're using a local shell, then create local authentication credentials for your user account:

    gcloud auth application-default login

    You don't need to do this if you're using Cloud Shell.

자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.

REST

로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.

    Install the Google Cloud CLI, then initialize it by running the following command:

    gcloud init

자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참고하세요.

모니터링 일정이 있는 특성 모니터 만들기

지형지물 통계를 검색하고 모니터링하려면 지형지물 모니터링 작업을 주기적으로 실행하고 지형지물 그룹에 등록된 지형지물의 지형지물 통계를 검색하는 일정을 지정하는 FeatureMonitor 리소스를 만듭니다.

다음 샘플을 사용하여 FeatureMonitor 리소스를 만듭니다. 동일한 지형지물 그룹에 여러 일정을 설정하려면 여러 개의 FeatureMonitor 리소스를 만들어야 합니다.

REST

FeatureMonitor 리소스를 만들고 기능 모니터링 작업을 예약하려면 featureMonitors.create 메서드를 사용하여 POST 요청을 전송합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터를 만들려는 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: 특성 모니터링을 설정할 특성 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 만들려는 새 특성 모니터의 이름입니다.
  • FEATURE_ID_1FEATURE_ID_2: 모니터링하려는 지형지물의 ID입니다.
  • DRIFT_THRESHOLD_1DRIFT_THRESHOLD_2: 특성 모니터에 포함된 각 특성의 드리프트 기준점입니다. 드리프트 기준점은 특성 드리프트와 같은 이상치를 감지하는 데 사용됩니다. [0, 1) 범위의 값을 입력합니다. 값을 입력하지 않으면 기본적으로 임곗값이 0.3으로 설정됩니다.
    Vertex AI Feature Store는 연속된 특성 모니터 작업 실행의 스냅샷을 비교하고 BigQuery의 ML.TFDV_VALIDATE 함수를 사용하여 드리프트를 계산합니다. 이상치를 분류하기 위해 범주형 특성에는 L-무한대 거리가 사용되고 숫자 특성에는 젠슨-섀넌 발산이 사용됩니다.
  • CRON: 지형지물 모니터링 작업을 실행할 빈도를 나타내는 크론 일정 표현식입니다. 자세한 내용은 크론을 참조하세요.

HTTP 메서드 및 URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors?feature_monitor_id=FEATURE_MONITOR_NAME

JSON 요청 본문:

{
  "feature_selection_config": {
    "feature_configs": [
      {"feature_id":"FEATURE_ID_1", "drift_threshold": "DRIFT_THRESHOLD_1" },
      {"feature_id":"FEATURE_ID_2", "drift_threshold": "DRIFT_THRESHOLD_2" }
    ],
  },
  "schedule_config": {
    "cron": "CRON"
  }
}

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors?feature_monitor_id=FEATURE_MONITOR_NAME"

PowerShell

요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors?feature_monitor_id=FEATURE_MONITOR_NAME" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1beta1.CreateFeatureMonitorOperationMetadata",
    "genericMetadata": {
      "createTime": "2024-12-15T19:35:03.975958Z",
      "updateTime": "2024-12-15T19:35:03.975958Z"
    }
  }
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

def create_feature_monitor_sample(
    project: str,
    location: str,
    existing_feature_group_id: str,
    feature_monitor_id: str,
    feature_selection_configs: List[Tuple[str, float]]
    schedule_config: str # Cron string. For example, "0 * * * *" indicates hourly execution.
):
    aiplatform.init(project="PROJECT_ID", location="LOCATION_ID")
    feature_group = feature_store.FeatureGroup("FEATUREGROUP_NAME")
    feature_monitor = feature_group.create_feature_monitor(
        name= "FEATURE_MONITOR_NAME",
        feature_selection_configs=[("FEATURE_ID_1", DRIFT_THRESHOLD_1),("FEATURE_ID_2", DRIFT_THRESHOLD_2)],
        schedule_config="CRON"
        )

다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터를 만들려는 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: 특성 모니터링을 설정할 특성 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 만들려는 새 특성 모니터의 이름입니다.
  • FEATURE_ID_1FEATURE_ID_2: 모니터링하려는 지형지물의 ID입니다.
  • DRIFT_THRESHOLD_1DRIFT_THRESHOLD_2: 특성 모니터에 포함된 각 특성의 드리프트 기준점입니다. 드리프트 임곗값은 특성 드리프트를 감지하는 데 사용됩니다. 0에서 1 사이의 값을 입력하세요. 값을 입력하지 않으면 기본적으로 임곗값이 0.3으로 설정됩니다.
    Vertex AI Feature Store는 현재 기능 모니터링 작업의 데이터 스냅샷을 이전 기능 모니터링 작업의 데이터 스냅샷과 비교합니다. Vertex AI Feature Store는 분포 편차를 계산하기 위해 BigQuery의 ML.TFDV_VALIDATE 함수를 사용합니다.
    통계를 비교하는 데 사용되는 측정항목의 경우 범주형 특성에는 L-무한대 거리가 사용되고 숫자 특성에는 젠슨-섀넌 발산이 사용됩니다.
  • CRON: 지형지물 모니터링 작업을 실행할 빈도를 나타내는 크론 일정 표현식입니다. 자세한 내용은 크론을 참조하세요.

특성 모니터링 작업 수동 실행

연속으로 예약된 특성 모니터링 작업 간의 대기를 건너뛰고 특성 모니터 작업을 수동으로 실행할 수 있습니다. 이는 다음으로 예약된 모니터링 작업이 실행될 때까지 기다리지 않고 모니터링 정보를 검색하고 지형지물 데이터에서 즉시 이상치를 감지하려는 경우에 유용합니다.

REST

FeatureMonitorJob 리소스를 만들어 기능 모니터링 작업을 수동으로 실행하려면 featureMonitorJobs.create 메서드를 사용하여 POST 요청을 전송합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업을 실행할 리전입니다(예: us-central1).
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATURE_MONITOR_NAME: 기능 모니터링 작업을 실행할 FeatureMonitor 리소스의 이름입니다.

HTTP 메서드 및 URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_ID/featureMonitorJobs

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_ID/featureMonitorJobs"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_ID/featureMonitorJobs" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID"
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

aiplatofrm.init(project="PROJECT_ID", location="LOCATION_ID")

feature_group = FeatureGroup.get("FEATUREGROUP_NAME}")
feature_monitor = feature_group.get_feature_monitor(FEATURE_MONITOR_NAME)
feature_monitor_job = feature_monitor.create_feature_monitor_job()

다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업을 실행할 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 기능 모니터링 작업을 실행할 FeatureMonitor 리소스의 이름입니다.

모니터링 작업에서 기능 통계 가져오기

특성 모니터링 작업 실행 중에 생성된 특성 모니터링 작업 ID를 사용하여 FeatureMonitorJob 리소스를 검색하여 특성 모니터링 작업의 모든 특성에 대한 특성 통계를 검색할 수 있습니다. 최신 모니터링 작업의 특정 리소스에 관한 특성 통계를 검색할 수도 있습니다.

지형지물 모니터링 작업 나열

다음 샘플은 지정된 FeatureMonitor 리소스에 대해 생성된 모든 FeatureMonitorJob 리소스의 목록을 검색하는 방법을 보여줍니다.

REST

지정된 FeatureMonitor 리소스의 FeatureMonitorJob 리소스 목록을 검색하려면 featureMonitorJobs.list 메서드를 사용하여 GET 요청을 전송합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: Feature 리소스가 있는 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 특성 모니터링 작업을 나열하려는 FeatureMonitor 리소스의 이름입니다.

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "featureMonitorJobs": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID_1",
      "createTime": "2024-12-18T19:18:18.077161Z",
      "finalStatus": {},
      "featureSelectionConfig": {
        "featureConfigs": [
          {
            "featureId": "feature_name_1",
            "driftThreshold": 0.2
          },
          {
            "featureId": "feature_name_2",
            "driftThreshold": 0.2
          }
        ]
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID_2",
      "createTime": "2024-12-19T19:18:30.859921Z",
      "finalStatus": {},
      "featureSelectionConfig": {
        "featureConfigs": [
          {
            "featureId": "feature_name_1",
            "driftThreshold": 0.2
          },
          {
            "featureId": "feature_name_2",
            "driftThreshold": 0.2
          }
        ]
      }
    }
  ]
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

aiplatofrm.init(project="PROJECT_ID", location="LOCATION_ID")

feature_group = FeatureGroup.get("FEATUREGROUP_NAME")
feature_monitor = feature_group.get_feature_monitor(FEATURE_MONITOR_NAME)
feature_monitor_jobs = feature_monitor.list_feature_monitor_jobs()

다음을 바꿉니다.

  • LOCATION_ID: Feature 리소스가 있는 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 특성 모니터링 작업을 나열하려는 FeatureMonitor 리소스의 이름입니다.

모니터링 작업의 특성 통계 보기

다음 샘플은 지형지물 모니터링 작업의 모든 지형지물에 대한 지형지물 통계를 보는 방법을 보여줍니다. 각 지형지물의 통계 및 이상치는 FeatureNameStatistics 형식으로 표시됩니다.

REST

FeatureMonitorJob 리소스를 검색하여 모니터링 작업의 지형지물 통계를 보려면 featureMonitorJobs.get 메서드를 사용하여 GET 요청을 전송합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 지형지물 모니터링 작업이 실행된 FeatureMonitor 리소스의 이름입니다.
  • FEATURE_MONITOR_JOB_ID: 가져올 FeatureMonitorJob 리소스의 ID입니다.

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID",
  "createTime": "2024-12-19T19:18:18.077161Z",
  "finalStatus": {},
  "jobSummary": {
    "featureStatsAndAnomalies": [
      {
        "featureId": "feature_id_1",
        "featureStats": {
          "name": "feature_name_1",
          "type": "STRING",
          "stringStats": {
            "commonStats": {
              "numNonMissing": "6",
              "minNumValues": "1",
              "maxNumValues": "1",
              "avgNumValues": 1,
              "numValuesHistogram": {
                "buckets": [
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.6
                  },
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.6
                  }
                ],
                "type": "QUANTILES"
              },
              "totNumValues": "6"
            },
            "unique": "2",
            "topValues": [
              {
                "value": "59",
                "frequency": 2
              },
              {
                "value": "19",
                "frequency": 1
              }
            ],
            "avgLength": 2,
            "rankHistogram": {
              "buckets": [
                {
                  "label": "59",
                  "sampleCount": 2
                },
                {
                  "lowRank": "1",
                  "highRank": "1",
                  "label": "19",
                  "sampleCount": 1
                }
              ]
            }
          }
        },
        "statsTime": "2024-12-19T19:18:18.077161Z",
        "featureMonitorJobId": "FEATURE_MONITOR_JOB_ID",
        "featureMonitorId": "FEATURE_MONITOR_NAME"
      },
      {
        "featureId": "feature_id_2",
        "featureStats": {
          "name": "feature_name_1",
          "type": "STRING",
          "stringStats": {
            "commonStats": {
              "numNonMissing": "6",
              "minNumValues": "1",
              "maxNumValues": "1",
              "avgNumValues": 1,
              "numValuesHistogram": {
                "buckets": [
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.6
                  },
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.6
                  }
                ],
                "type": "QUANTILES"
              },
              "totNumValues": "6"
            },
            "unique": "2",
            "topValues": [
              {
                "value": "59",
                "frequency": 2
              },
              {
                "value": "19",
                "frequency": 1
              }
            ],
            "avgLength": 2,
            "rankHistogram": {
              "buckets": [
                {
                  "label": "59",
                  "sampleCount": 2
                },
                {
                  "lowRank": "1",
                  "highRank": "1",
                  "label": "19",
                  "sampleCount": 1
                }
              ]
            }
          }
        },
        "statsTime": "2024-12-19T19:18:18.077161Z",
        "featureMonitorJobId": "FEATURE_MONITOR_JOB_ID",
        "featureMonitorId": "FEATURE_MONITOR_NAME"
      }
    ]
  },
  "driftBaseFeatureMonitorJobId": "2250003330000300000",
  "driftBaseSnapshotTime": "2024-12-12T16:00:01.211686Z",
  "featureSelectionConfig": {
    "featureConfigs": [
      {
        "featureId": "feature_id_1",
        "driftThreshold": 0.2
      },
      {
        "featureId": "feature_id_2",
        "driftThreshold": 0.2
      }
    ]
  },
  "triggerType": "FEATURE_MONITOR_JOB_TRIGGER_ON_DEMAND"
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

aiplatofrm.init(project="PROJECT_ID", location="LOCATION_ID")
feature_group = FeatureGroup.get("FEATUREGROUP_NAME"})

feature_monitor = feature_group.get_feature_monitor("FEATURE_MONITOR_NAME")
feature_monitor_job = feature_monitor.get_feature_monitor_job("FEATURE_MONITOR_JOB_ID)")

# Retrieve feature stats and anomalies
feature_stats_and_anomalies = feature_monitor_job.feature_stats_and_anomalies
print(feature_stats_and_anomalies)

다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 지형지물 모니터링 작업이 실행된 FeatureMonitor 리소스의 이름입니다.
  • FEATURE_MONITOR_JOB_ID: 가져올 FeatureMonitorJob 리소스의 ID입니다.

지형지물의 지형지물 통계 보기

특성 세부정보를 검색하고 통계를 가져올 모니터링 작업 수를 지정하여 실행된 최근 특성 모니터링 작업에서 특정 특성에 대한 특성 통계를 가져올 수 있습니다. 통계 및 이상치는 FeatureNameStatistics 형식으로 표시됩니다.

다음 샘플은 지정된 수의 최근 기능 모니터링 작업에서 특정 기능의 기능 통계를 보는 방법을 보여줍니다.

REST

Feature 리소스에서 특정 지형지물의 지형지물 통계를 보려면 features.get 메서드를 사용하여 GET 요청을 전송하고 통계를 가져올 모니터링 작업 수를 지정합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: 특성이 포함된 특성 그룹의 이름입니다.
  • FEATURE_NAME: 지형지물 통계를 가져올 Feature 리소스의 이름입니다.
  • LATEST_STATS_COUNT: 특성 통계를 가져올 최신 모니터링 작업 수입니다.

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME?feature_stats_and_anomaly_spec.latest_stats_count=LATEST_STATS_COUNT

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME?feature_stats_and_anomaly_spec.latest_stats_count=LATEST_STATS_COUNT"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME?feature_stats_and_anomaly_spec.latest_stats_count=LATEST_STATS_COUNT" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/features/FEATURE_NAME",
  "createTime": "2024-12-19T21:17:23.373559Z",
  "updateTime": "2024-12-19T21:17:23.373559Z",
  "etag": "sample_etag",
  "featureStatsAndAnomaly": [
    {
      "featureStats": {
        "name": "FEATURE_NAME",
        "type": "STRING",
        "stringStats": {
          "commonStats": {
            "numNonMissing": "4",
            "minNumValues": "1",
            "maxNumValues": "1",
            "avgNumValues": 1,
            "numValuesHistogram": {
              "buckets": [
                {
                  "lowValue": 1,
                  "highValue": 1,
                  "sampleCount": 0.4
                },
                {
                  "lowValue": 1,
                  "highValue": 1,
                  "sampleCount": 0.4
                },
                {
                  "lowValue": 1,
                  "highValue": 1,
                  "sampleCount": 0.4
                },
                {
                  "lowValue": 1,
                  "highValue": 1,
                  "sampleCount": 0.4
                }
              ],
              "type": "QUANTILES"
            },
            "totNumValues": "4"
          },
          "unique": "4",
          "topValues": [
            {
              "value": "feature_value_1",
              "frequency": 1
            },
            {
              "value": "feature_value_2",
              "frequency": 1
            },
            {
              "value": "feature_value_3",
              "frequency": 1
            },
            {
              "value": "feature_value_4",
              "frequency": 1
            }
          ],
          "avgLength": 4,
          "rankHistogram": {
            "buckets": [
              {
                "label": "label_1",
                "sampleCount": 1
              },
              {
                "lowRank": "1",
                "highRank": "1",
                "label": "label_2",
                "sampleCount": 1
              },
              {
                "lowRank": "2",
                "highRank": "2",
                "label": "label_3",
                "sampleCount": 1
              },
              {
                "lowRank": "3",
                "highRank": "3",
                "label": "label_4",
                "sampleCount": 1
              }
            ]
          }
        }
      },
      "driftDetectionThreshold": 0.1,
      "statsTime": "2024-12-19T22:00:02.734796Z",
      "featureMonitorJobId": "feature_monitor_job_id_1",
      "featureMonitorId": "feature_monitor_name_1"
    }
  ],
  "versionColumnName": "version_column_name"
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

aiplatofrm.init(project="PROJECT_ID", location="LOCATION_ID")

feature_group = FeatureGroup.get("FEATUREGROUP_NAME"})
feature_stats_and_anomalies = feature_group.get_feature("FEATURE_NAME", latest_stats_count=LATEST_STATS_COUNT)
print(feature_stats_and_anomalies)

다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_NAME: 지형지물 통계를 가져오려는 지형지물의 이름입니다.
  • LATEST_STATS_COUNT: 특성 통계를 가져올 최근 모니터링 작업 수입니다.

사용 사례 예: 특성 모니터링을 사용하여 특성 드리프트 감지

특성 모니터링을 사용하여 특성 데이터에서 특성 드리프트라는 이상치를 감지할 수 있습니다. 드리프트는 시간 경과에 따라 BigQuery의 지형지물 데이터에 예상치 못한 중대한 변화가 발생하는 것을 말합니다. Vertex AI Feature Store를 사용하면 모니터링 작업이 실행될 때의 스냅샷을 이전 모니터링 작업 실행 중의 데이터 스냅샷과 비교하여 특성 드리프트를 식별할 수 있습니다.

특성 모니터에 포함된 특성의 경우 두 스냅샷의 차이가 drift_threshold 매개변수에 지정된 임곗값을 초과하면 Vertex AI Feature Store는 특성 드리프트를 식별하고 FeatureMonitorJob 리소스에 다음 정보를 반환합니다.

  • driftDetected 매개변수가 true로 설정됩니다.

  • 두 스냅샷 간의 분포 편차입니다. 숫자 특성의 경우 Vertex AI Feature Store는 젠슨-섀넌 발산을 사용하여 이 값을 계산합니다. 범주형 특성의 경우 Vertex AI Feature Store는 L-무한대 거리를 사용하여 이 값을 계산합니다.

  • 분포 편차가 초과한 기준점입니다.

다음 샘플은 FeatureMonitorJob 리소스를 검색하고 편차가 감지되었는지 확인하는 방법을 보여줍니다.

REST

FeatureMonitorJob 리소스를 검색하려면 featureMonitorJobs.get 메서드를 사용하여 GET 요청을 전송합니다.

요청 데이터를 사용하기 전에 다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 지형지물 모니터링 작업이 실행된 FeatureMonitor 리소스의 이름입니다.
  • FEATURE_MONITOR_JOB_ID: 가져올 FeatureMonitorJob 리소스의 ID입니다.

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID

요청을 보내려면 다음 옵션 중 하나를 선택합니다.

curl

다음 명령어를 실행합니다.

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID"

PowerShell

다음 명령어를 실행합니다.

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID" | Select-Object -Expand Content

다음과 비슷한 JSON 응답이 표시됩니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featureGroups/FEATUREGROUP_NAME/featureMonitors/FEATURE_MONITOR_NAME/featureMonitorJobs/FEATURE_MONITOR_JOB_ID",
  "createTime": "2024-12-14T19:45:30.026522Z",
  "finalStatus": {},
  "jobSummary": {
    "featureStatsAndAnomalies": [
      {
        "featureId": "feature_id_1",
        "featureStats": {
          "name": "feature_name_1",
          "type": "STRING",
          "stringStats": {
            "commonStats": {
              "numNonMissing": "3",
              "minNumValues": "1",
              "maxNumValues": "1",
              "avgNumValues": 1,
              "numValuesHistogram": {
                "buckets": [
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.9
                  },
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.9
                  },
                  {
                    "lowValue": 1,
                    "highValue": 1,
                    "sampleCount": 0.9
                  }
                ],
                "type": "QUANTILES"
              },
              "totNumValues": "3"
            },
            "unique": "3",
            "topValues": [
              {
                "value": "sample_value_1",
                "frequency": 1
              },
              {
                "value": "sample_value_2",
                "frequency": 1
              },
              {
                "value": "sample_value_3",
                "frequency": 1
              }
            ],
            "avgLength": 3,
            "rankHistogram": {
              "buckets": [
                {
                  "label": "sample_label_1",
                  "sampleCount": 1
                },
                {
                  "lowRank": "1",
                  "highRank": "1",
                  "label": "sample_label_2",
                  "sampleCount": 1
                },
                {
                  "lowRank": "2",
                  "highRank": "3",
                  "label": "sample_label_3",
                  "sampleCount": 1
                }
              ]
            }
          }
        },
        "distributionDeviation": 0.1388880008888000,
        "driftDetectionThreshold": 0.1,
        "driftDetected": true,
        "statsTime": "2024-12-15T19:45:37.026522Z",
        "featureMonitorJobId": "FEATURE_MONITOR_JOB_ID",
        "featureMonitorId": "FEATURE_MONITOR_NAME"
      }
    ]
  },
  "driftBaseFeatureMonitorJobId": "2250003330000300000",
  "driftBaseSnapshotTime": "2024-12-12T18:18:18.077161Z",
  "description": "sample_feature_monitor_job_description",
  "featureSelectionConfig": {
    "featureConfigs": [
      {
        "featureId": "feature_name",
        "driftThreshold": 0.1
      }
    ]
  },
  "triggerType": "FEATURE_MONITOR_JOB_TRIGGER_ON_DEMAND"
}

Python

이 샘플을 사용해 보기 전에 Vertex AI 빠른 시작: 클라이언트 라이브러리 사용Python 설정 안내를 따르세요. 자세한 내용은 Vertex AI Python API 참고 문서를 참조하세요.

Vertex AI에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

from google.cloud import aiplatform
from vertexai.resources.preview import feature_store

aiplatofrm.init(project="PROJECT_ID", location="LOCATION_ID")
feature_group = FeatureGroup.get("FEATUREGROUP_NAME"})
feature_monitor = feature_group.get_feature_monitor("FEATURE_MONITOR_NAME")
feature_monitor_job = feature_monitor.get_feature_monitor_job("FEATURE_MONITOR_JOB_ID)")

# Retrieve feature stats and anomalies
feature_stats_and_anomalies = feature_monitor_job.feature_stats_and_anomalies
print(feature_stats_and_anomalies)

# Check whether drifts are detected
for feature_stats_and_anomalies in feature_monitor_job.feature_stats_and_anomalies:
    print("feature: ", feature_stats_and_anomalies.feature_id)
    print("distribution deviation: ", feature_stats_and_anomalies.distribution_deviation)
    print("drift detected: ", feature_stats_and_anomalies.drift_detected)

다음을 바꿉니다.

  • LOCATION_ID: 특성 모니터링 작업이 실행된 리전입니다(예: us-central1).
  • PROJECT_ID: 프로젝트 ID입니다.
  • FEATUREGROUP_NAME: FeatureMonitor 리소스가 포함된 지형지물 그룹의 이름입니다.
  • FEATURE_MONITOR_NAME: 지형지물 모니터링 작업이 실행된 FeatureMonitor 리소스의 이름입니다.
  • FEATURE_MONITOR_JOB_ID: 가져올 FeatureMonitorJob 리소스의 ID입니다.