특성 관리 및 찾기

특성을 관리하고 찾는 방법을 알아봅니다.

특성 만들기

기존 항목 유형의 단일 특성을 만듭니다. 단일 요청에서 특성 여러 개를 만들려면 특성 일괄 만들기를 참조하세요.

웹 UI

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 특성 페이지로 이동합니다.

    특성 페이지로 이동

  2. 리전 드롭다운 목록에서 리전을 선택합니다.
  3. 특성 테이블에서 항목 유형 열을 확인하고 특성을 추가할 항목 유형을 클릭합니다.
  4. 특성 추가를 클릭하여 특성 추가 창을 엽니다.
  5. 특성의 이름, 값 유형, 설명(선택사항)을 지정합니다.
  6. 특성 값 모니터링(미리보기)을 사용 설정하려면 특성 모니터링에서 항목 유형 모니터링 구성 재정의를 선택한 후 스냅샷 사이의 간격(일 수)을 입력합니다. 이 구성은 특성의 항목 유형에 대한 기존 또는 향후 모니터링 구성을 재정의합니다. 자세한 내용은 특성 값 모니터링을 참조하세요.
  7. 더 많은 특성을 추가하려면 다른 특성 추가를 클릭합니다.
  8. 저장을 클릭합니다.

REST

기존 항목 유형의 특성을 만들려면 featurestores.entityTypes.features.create 메서드를 사용하여 POST 요청을 전송합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID
  • FEATURESTORE_ID: 피처스토어의 ID
  • ENTITY_TYPE_ID: 항목 유형의 ID
  • FEATURE_ID: 특성의 ID
  • DESCRIPTION: 특성 설명
  • VALUE_TYPE: 특성의 값 유형

HTTP 메서드 및 URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID

JSON 요청 본문:

{
  "description": "DESCRIPTION",
  "valueType": "VALUE_TYPE"
}

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

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/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID"

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/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID" | Select-Object -Expand Content

다음과 비슷한 출력이 표시됩니다. 응답의 OPERATION_ID를 사용하여 작업 상태를 가져올 수 있습니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-02T00:04:13.039166Z",
      "updateTime": "2021-03-02T00:04:13.039166Z"
    }
  }
}

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def create_feature_sample(
    project: str,
    location: str,
    feature_id: str,
    value_type: str,
    entity_type_id: str,
    featurestore_id: str,
):

    aiplatform.init(project=project, location=location)

    my_feature = aiplatform.Feature.create(
        feature_id=feature_id,
        value_type=value_type,
        entity_type_name=entity_type_id,
        featurestore_id=featurestore_id,
    )

    my_feature.wait()

    return my_feature

Python

Vertex AI 클라이언트 라이브러리는 Python용 Vertex AI SDK를 설치할 때 포함됩니다. Python용 Vertex AI SDK를 설치하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참고 문서를 확인하세요.

from google.cloud import aiplatform

def create_feature_sample(
    project: str,
    featurestore_id: str,
    entity_type_id: str,
    feature_id: str,
    value_type: aiplatform.gapic.Feature.ValueType,
    description: str = "sample feature",
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints, which need to be
    # in the same region or multi-region overlap with the Feature Store location.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.FeaturestoreServiceClient(client_options=client_options)
    parent = f"projects/{project}/locations/{location}/featurestores/{featurestore_id}/entityTypes/{entity_type_id}"
    create_feature_request = aiplatform.gapic.CreateFeatureRequest(
        parent=parent,
        feature=aiplatform.gapic.Feature(
            value_type=value_type, description=description
        ),
        feature_id=feature_id,
    )
    lro_response = client.create_feature(request=create_feature_request)
    print("Long running operation:", lro_response.operation.name)
    create_feature_response = lro_response.result(timeout=timeout)
    print("create_feature_response:", create_feature_response)

Java

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

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


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.CreateFeatureOperationMetadata;
import com.google.cloud.aiplatform.v1.CreateFeatureRequest;
import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.Feature.ValueType;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateFeatureSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String description = "YOUR_FEATURE_DESCRIPTION";
    ValueType valueType = ValueType.STRING;
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 900;
    createFeatureSample(
        project,
        featurestoreId,
        entityTypeId,
        featureId,
        description,
        valueType,
        location,
        endpoint,
        timeout);
  }

  static void createFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String description,
      ValueType valueType,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      Feature feature =
          Feature.newBuilder().setDescription(description).setValueType(valueType).build();

      CreateFeatureRequest createFeatureRequest =
          CreateFeatureRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .setFeature(feature)
              .setFeatureId(featureId)
              .build();

      OperationFuture<Feature, CreateFeatureOperationMetadata> featureFuture =
          featurestoreServiceClient.createFeatureAsync(createFeatureRequest);
      System.out.format("Operation name: %s%n", featureFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      Feature featureResponse = featureFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Create Feature Response");
      System.out.format("Name: %s%n", featureResponse.getName());
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const valueType = 'FEATURE_VALUE_DATA_TYPE';
// const description = 'YOUR_ENTITY_TYPE_DESCRIPTION';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function createFeature() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const feature = {
    valueType: valueType,
    description: description,
  };

  const request = {
    parent: parent,
    feature: feature,
    featureId: featureId,
  };

  // Create Feature request
  const [operation] = await featurestoreServiceClient.createFeature(request, {
    timeout: Number(timeout),
  });
  const [response] = await operation.promise();

  console.log('Create feature response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
createFeature();

특성 일괄 생성

기존 유형의 특성을 일괄 생성합니다. 일괄 생성 요청의 경우 Vertex AI Feature Store(기존)가 한 번에 특성 여러 개를 만들므로 featurestores.entityTypes.features.create 메서드보다 많은 특성을 더 빠르게 만들 수 있습니다.

웹 UI

특성 만들기를 참조하세요.

REST

기존 항목 유형의 특성을 하나 이상 만들려면 다음 샘플과 같이 featurestores.entityTypes.features.batchCreate 메서드를 사용하여 POST 요청을 전송합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID
  • FEATURESTORE_ID: 피처스토어의 ID
  • ENTITY_TYPE_ID: 항목 유형의 ID
  • PARENT: 특성을 만들 항목 유형의 리소스 이름입니다. 필수 형식:
    projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID
  • FEATURE_ID: 특성의 ID
  • DESCRIPTION: 특성 설명
  • VALUE_TYPE: 특성의 값 유형
  • DURATION: (선택사항) 스냅샷 간의 간격(초). 값은 `s`로 끝나야 합니다.

HTTP 메서드 및 URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate

JSON 요청 본문:

{
  "requests": [
    {
      "parent" : "PARENT_1",
      "feature": {
        "description": "DESCRIPTION_1",
        "valueType": "VALUE_TYPE_1",
        "monitoringConfig": {
          "snapshotAnalysis": {
            "monitoringInterval": "DURATION"
          }
        }
      },
      "featureId": "FEATURE_ID_1"
    },
    {
      "parent" : "PARENT_2",
      "feature": {
        "description": "DESCRIPTION_2",
        "valueType": "VALUE_TYPE_2",
        "monitoringConfig": {
          "snapshotAnalysis": {
            "monitoringInterval": "DURATION"
          }
        }
      },
      "featureId": "FEATURE_ID_2"
    }
  ]
}

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

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/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate"

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/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate" | Select-Object -Expand Content

다음과 비슷한 출력이 표시됩니다. 응답의 OPERATION_ID를 사용하여 작업 상태를 가져올 수 있습니다.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.BatchCreateFeaturesOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-02T00:04:13.039166Z",
      "updateTime": "2021-03-02T00:04:13.039166Z"
    }
  }
}

Python

Python을 설치하거나 업데이트하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python API 참고 문서를 참조하세요.

from google.cloud import aiplatform

def batch_create_features_sample(
    project: str,
    location: str,
    entity_type_id: str,
    featurestore_id: str,
    sync: bool = True,
):

    aiplatform.init(project=project, location=location)

    my_entity_type = aiplatform.featurestore.EntityType(
        entity_type_name=entity_type_id, featurestore_id=featurestore_id
    )

    FEATURE_CONFIGS = {
        "age": {"value_type": "INT64", "description": "User age"},
        "gender": {"value_type": "STRING", "description": "User gender"},
        "liked_genres": {
            "value_type": "STRING_ARRAY",
            "description": "An array of genres this user liked",
        },
    }

    my_entity_type.batch_create_features(feature_configs=FEATURE_CONFIGS, sync=sync)

Python

Vertex AI 클라이언트 라이브러리는 Python용 Vertex AI SDK를 설치할 때 포함됩니다. Python용 Vertex AI SDK를 설치하는 방법은 Python용 Vertex AI SDK 설치를 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참고 문서를 확인하세요.

from google.cloud import aiplatform

def batch_create_features_sample(
    project: str,
    featurestore_id: str,
    entity_type_id: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints, which need to be
    # in the same region or multi-region overlap with the Feature Store location.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.FeaturestoreServiceClient(client_options=client_options)
    parent = f"projects/{project}/locations/{location}/featurestores/{featurestore_id}/entityTypes/{entity_type_id}"
    age_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.INT64, description="User age",
    )
    age_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=age_feature, feature_id="age"
    )

    gender_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.STRING, description="User gender"
    )
    gender_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=gender_feature, feature_id="gender"
    )

    liked_genres_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.STRING_ARRAY,
        description="An array of genres that this user liked",
    )
    liked_genres_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=liked_genres_feature, feature_id="liked_genres"
    )

    requests = [
        age_feature_request,
        gender_feature_request,
        liked_genres_feature_request,
    ]
    batch_create_features_request = aiplatform.gapic.BatchCreateFeaturesRequest(
        parent=parent, requests=requests
    )
    lro_response = client.batch_create_features(request=batch_create_features_request)
    print("Long running operation:", lro_response.operation.name)
    batch_create_features_response = lro_response.result(timeout=timeout)
    print("batch_create_features_response:", batch_create_features_response)

Java

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

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


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesOperationMetadata;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesResponse;
import com.google.cloud.aiplatform.v1.CreateFeatureRequest;
import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.Feature.ValueType;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchCreateFeaturesSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;
    batchCreateFeaturesSample(project, featurestoreId, entityTypeId, location, endpoint, timeout);
  }

  static void batchCreateFeaturesSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      List<CreateFeatureRequest> createFeatureRequests = new ArrayList<>();

      Feature titleFeature =
          Feature.newBuilder()
              .setDescription("The title of the movie")
              .setValueType(ValueType.STRING)
              .build();
      Feature genresFeature =
          Feature.newBuilder()
              .setDescription("The genres of the movie")
              .setValueType(ValueType.STRING)
              .build();
      Feature averageRatingFeature =
          Feature.newBuilder()
              .setDescription("The average rating for the movie, range is [1.0-5.0]")
              .setValueType(ValueType.DOUBLE)
              .build();

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder().setFeature(titleFeature).setFeatureId("title").build());

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder()
              .setFeature(genresFeature)
              .setFeatureId("genres")
              .build());

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder()
              .setFeature(averageRatingFeature)
              .setFeatureId("average_rating")
              .build());

      BatchCreateFeaturesRequest batchCreateFeaturesRequest =
          BatchCreateFeaturesRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .addAllRequests(createFeatureRequests)
              .build();

      OperationFuture<BatchCreateFeaturesResponse, BatchCreateFeaturesOperationMetadata>
          batchCreateFeaturesFuture =
              featurestoreServiceClient.batchCreateFeaturesAsync(batchCreateFeaturesRequest);
      System.out.format(
          "Operation name: %s%n", batchCreateFeaturesFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      BatchCreateFeaturesResponse batchCreateFeaturesResponse =
          batchCreateFeaturesFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Batch Create Features Response");
      System.out.println(batchCreateFeaturesResponse);
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function batchCreateFeatures() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const ageFeature = {
    valueType: 'INT64',
    description: 'User age',
  };

  const ageFeatureRequest = {
    feature: ageFeature,
    featureId: 'age',
  };

  const genderFeature = {
    valueType: 'STRING',
    description: 'User gender',
  };

  const genderFeatureRequest = {
    feature: genderFeature,
    featureId: 'gender',
  };

  const likedGenresFeature = {
    valueType: 'STRING_ARRAY',
    description: 'An array of genres that this user liked',
  };

  const likedGenresFeatureRequest = {
    feature: likedGenresFeature,
    featureId: 'liked_genres',
  };

  const requests = [
    ageFeatureRequest,
    genderFeatureRequest,
    likedGenresFeatureRequest,
  ];

  const request = {
    parent: parent,
    requests: requests,
  };

  // Batch Create Features request
  const [operation] = await featurestoreServiceClient.batchCreateFeatures(
    request,
    {timeout: Number(timeout)}
  );
  const [response] = await operation.promise();

  console.log('Batch create features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
batchCreateFeatures();

특성 나열

지정된 위치의 모든 특성을 나열합니다. 지정된 위치의 모든 항목 유형 및 피처스토어에서 특성을 검색하려면 특성 검색 메서드를 참조하세요.

웹 UI

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 특성 페이지로 이동합니다.

    특성 페이지로 이동

  2. 리전 드롭다운 목록에서 리전을 선택합니다.
  3. 특성 테이블의 특성 열에서 선택한 리전에 있는 프로젝트의 특성을 확인합니다.

REST

단일 항목 유형의 모든 특성을 나열하려면 featurestores.entityTypes.features.list 메서드를 사용하여 GET 요청을 전송합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID
  • FEATURESTORE_ID: 피처스토어의 ID
  • ENTITY_TYPE_ID: 항목 유형의 ID

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features"

PowerShell

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

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features" | Select-Object -Expand Content

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

{
  "features": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_1",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-03-01T22:41:20.626644Z",
      "updateTime": "2021-03-01T22:41:20.626644Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yP0qJeLao6P3fl9cKEGY4ie5-SanQaiN7c_Ca4QOa0u7AxwO6i75Vbp0Cr51MSf"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_2",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-02-25T01:27:00.544230Z",
      "updateTime": "2021-02-25T01:27:00.544230Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yMdrLZ7Waty0ane-DkHq4kcsIVC-piqJq7n6A_Y-BjNzPY4rNlokDHNyUqC7edw"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_3",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-03-01T22:41:20.628493Z",
      "updateTime": "2021-03-01T22:41:20.628493Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yM-sAkv-u-jzkUOToaAVovK7GKbrubd9DbmAonik-ojTWG8-hfSRYt6jHKRTQ35"
    }
  ]
}

Java

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

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


import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.ListFeaturesRequest;
import java.io.IOException;

public class ListFeaturesSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";

    listFeaturesSample(project, featurestoreId, entityTypeId, location, endpoint);
  }

  static void listFeaturesSample(
      String project, String featurestoreId, String entityTypeId, String location, String endpoint)
      throws IOException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      ListFeaturesRequest listFeaturesRequest =
          ListFeaturesRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .build();
      System.out.println("List Features Response");
      for (Feature element :
          featurestoreServiceClient.listFeatures(listFeaturesRequest).iterateAll()) {
        System.out.println(element);
      }
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function listFeatures() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const request = {
    parent: parent,
  };

  // List Features request
  const [response] = await featurestoreServiceClient.listFeatures(request, {
    timeout: Number(timeout),
  });

  console.log('List features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
listFeatures();

추가 언어

Python용 Vertex AI SDK를 설치하고 사용하는 방법은 Python용 Vertex AI SDK 사용을 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참조 문서를 확인하세요.

특성 검색

특성 ID, 항목 유형 ID, 특성 설명 등 하나 이상의 속성을 기반으로 특성을 검색합니다. Vertex AI Feature Store(기존)는 지정된 위치의 모든 피처스토어와 항목 유형을 검색합니다. 특정 피처스토어, 값 유형, 라벨을 필터링하여 결과를 제한할 수도 있습니다.

모든 특성을 나열하려면 특성 나열을 참조하세요.

웹 UI

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 특성 페이지로 이동합니다.

    특성 페이지로 이동

  2. 리전 드롭다운 목록에서 리전을 선택합니다.
  3. 특성 테이블의 필터 필드를 클릭합니다.
  4. ID에서 일치하는 문자열이 포함된 특성을 반환하는 특성와 같은 속성을 선택합니다.
  5. 필터 값을 입력한 후 Enter 키를 누릅니다. Vertex AI Feature Store(기존)는 특성 테이블에 결과를 반환합니다.
  6. 필터를 추가하려면 필터 필드를 다시 클릭합니다.

REST

특성을 검색하려면 featurestores.searchFeatures 메서드를 사용하여 GET 요청을 전송합니다. 다음 샘플에서는 featureId:test AND valueType=STRING으로 작성된 여러 검색 매개변수를 사용합니다. 쿼리는 ID에 test가 포함되고 값이 STRING 유형인 특성을 반환합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING"

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING""

PowerShell

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

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

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING"" | Select-Object -Expand Content

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

{
  "features": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_IDfeature-delete.html/featurestores/featurestore_demo/entityTypes/testing/features/test1",
      "description": "featurestore test1",
      "createTime": "2021-02-26T18:16:09.528185Z",
      "updateTime": "2021-02-26T18:16:09.528185Z",
      "labels": {
        "environment": "testing"
      }
    }
  ]
}

Java

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

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


import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.LocationName;
import com.google.cloud.aiplatform.v1.SearchFeaturesRequest;
import java.io.IOException;

public class SearchFeaturesSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String query = "YOUR_QUERY";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    searchFeaturesSample(project, query, location, endpoint);
  }

  static void searchFeaturesSample(String project, String query, String location, String endpoint)
      throws IOException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      SearchFeaturesRequest searchFeaturesRequest =
          SearchFeaturesRequest.newBuilder()
              .setLocation(LocationName.of(project, location).toString())
              .setQuery(query)
              .build();
      System.out.println("Search Features Response");
      for (Feature element :
          featurestoreServiceClient.searchFeatures(searchFeaturesRequest).iterateAll()) {
        System.out.println(element);
      }
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function searchFeatures() {
  // Configure the locationResource resource
  const locationResource = `projects/${project}/locations/${location}`;

  const request = {
    location: locationResource,
    query: query,
  };

  // Search Features request
  const [response] = await featurestoreServiceClient.searchFeatures(request, {
    timeout: Number(timeout),
  });

  console.log('Search features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
searchFeatures();

추가 언어

Python용 Vertex AI SDK를 설치하고 사용하는 방법은 Python용 Vertex AI SDK 사용을 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참조 문서를 확인하세요.

특성 세부정보 보기

값 유형 또는 설명과 같은 특성에 대한 세부정보를 봅니다. Google Cloud 콘솔을 사용하고 특성 모니터링이 사용 설정되었으면 시간에 따라 특성 값 분포를 확인할 수도 있습니다.

웹 UI

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 특성 페이지로 이동합니다.

    특성 페이지로 이동

  2. 리전 드롭다운 목록에서 리전을 선택합니다.
  3. 특성 테이블의 특성 열에서 세부정보를 확인할 특성을 찾습니다.
  4. 특성 이름을 클릭하여 세부정보를 확인합니다.
  5. 측정항목을 보려면 측정항목을 클릭합니다. Vertex AI Feature Store(기존)는 이 특성에 대한 특성 배포 측정항목을 제공합니다.

REST

특성에 대한 세부정보를 가져오려면 featurestores.entityTypes.features.get 메서드를 사용하여 GET 요청을 전송합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID
  • FEATURESTORE_ID: 피처스토어의 ID
  • ENTITY_TYPE_ID: 항목 유형의 ID
  • FEATURE_ID: 특성의 ID

HTTP 메서드 및 URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID

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

curl

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

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_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/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID" | Select-Object -Expand Content

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

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID",
  "description": "DESCRIPTION",
  "valueType": "VALUE_TYPE",
  "createTime": "2021-03-01T22:41:20.628493Z",
  "updateTime": "2021-03-01T22:41:20.628493Z",
  "labels": {
    "environment": "testing"
  },
  "etag": "AMEw9yOZbdYKHTyjV22ziZR1vUX3nWOi0o2XU3-OADahSdfZ8Apklk_qPruhF-o1dOSD",
  "monitoringConfig": {}
}

Java

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

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


import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeatureName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.GetFeatureRequest;
import java.io.IOException;

public class GetFeatureSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";

    getFeatureSample(project, featurestoreId, entityTypeId, featureId, location, endpoint);
  }

  static void getFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String location,
      String endpoint)
      throws IOException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      GetFeatureRequest getFeatureRequest =
          GetFeatureRequest.newBuilder()
              .setName(
                  FeatureName.of(project, location, featurestoreId, entityTypeId, featureId)
                      .toString())
              .build();

      Feature feature = featurestoreServiceClient.getFeature(getFeatureRequest);
      System.out.println("Get Feature Response");
      System.out.println(feature);
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function getFeature() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}/features/${featureId}`;

  const request = {
    name: name,
  };

  // Get Feature request
  const [response] = await featurestoreServiceClient.getFeature(request, {
    timeout: Number(timeout),
  });

  console.log('Get feature response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
getFeature();

추가 언어

Python용 Vertex AI SDK를 설치하고 사용하는 방법은 Python용 Vertex AI SDK 사용을 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참조 문서를 확인하세요.

특성 삭제

특성 및 특성의 모든 값을 삭제합니다.

웹 UI

  1. Google Cloud 콘솔의 Vertex AI 섹션에서 특성 페이지로 이동합니다.

    특성 페이지로 이동

  2. 리전 드롭다운 목록에서 리전을 선택합니다.
  3. 특성 테이블에서 특성 열을 보고 삭제할 특성을 찾습니다.
  4. 특성의 이름을 클릭합니다.
  5. 작업 모음에서 삭제를 클릭합니다.
  6. 확인을 클릭하여 특성 및 특성 값을 삭제합니다.

REST

특성을 삭제하려면 featurestores.entityTypes.features.delete 메서드를 사용하여 DELETE 요청을 전송합니다.

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

  • LOCATION_ID: 피처스토어가 있는 리전(예: us-central1)
  • PROJECT_ID: 프로젝트 ID
  • FEATURESTORE_ID: 피처스토어의 ID
  • ENTITY_TYPE_ID: 항목 유형의 ID
  • FEATURE_ID: 특성의 ID

HTTP 메서드 및 URL:

DELETE https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID

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

curl

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

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID"

PowerShell

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

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

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID" | Select-Object -Expand Content

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

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-02-26T17:32:56.008325Z",
      "updateTime": "2021-02-26T17:32:56.008325Z"
    }
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Java

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

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


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.DeleteFeatureRequest;
import com.google.cloud.aiplatform.v1.DeleteOperationMetadata;
import com.google.cloud.aiplatform.v1.FeatureName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteFeatureSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;

    deleteFeatureSample(
        project, featurestoreId, entityTypeId, featureId, location, endpoint, timeout);
  }

  static void deleteFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      DeleteFeatureRequest deleteFeatureRequest =
          DeleteFeatureRequest.newBuilder()
              .setName(
                  FeatureName.of(project, location, featurestoreId, entityTypeId, featureId)
                      .toString())
              .build();

      OperationFuture<Empty, DeleteOperationMetadata> operationFuture =
          featurestoreServiceClient.deleteFeatureAsync(deleteFeatureRequest);
      System.out.format("Operation name: %s%n", operationFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      operationFuture.get(timeout, TimeUnit.SECONDS);
      System.out.format("Deleted Feature.");
      featurestoreServiceClient.close();
    }
  }
}

Node.js

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

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

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function deleteFeature() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}/features/${featureId}`;

  const request = {
    name: name,
  };

  // Delete Feature request
  const [operation] = await featurestoreServiceClient.deleteFeature(request, {
    timeout: Number(timeout),
  });
  const [response] = await operation.promise();

  console.log('Delete feature response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
deleteFeature();

추가 언어

Python용 Vertex AI SDK를 설치하고 사용하는 방법은 Python용 Vertex AI SDK 사용을 참조하세요. 자세한 내용은 Python용 Vertex AI SDK API 참고 문서를 확인하세요.

다음 단계