Check data quality for media recommendations

This page describes how to call the check requirements method that returns information about whether various metrics for your media data meet their requirement thresholds.

About checking media data quality

Because recent user events are so important for media recommendations, you must regularly check the quality of your ingested data and user events. You can do this by running the check requirements method on your media data store.

If a metric's threshold isn't met, then the curl command outputs a warning. Then, you need to review the metric and its description to determine what action you should take to improve your media quality.

All models and objectives need to pass general metric thresholds. Some model and objectives have additional metrics and thresholds and require that you run a second requirements check.

For information about the recommendation models and objectives, see About media app recommendations types.

Check data quality

Use the requirements:checkRequirement method to check the quality of your media recommendations data, as follows.

REST

To check the quality from the command line, follow these steps:

  1. Find your data store ID. If you already have your data store ID, skip to the next step.

    1. In the Google Cloud console, go to the Agent Builder page and in the navigation menu, click Data Stores.

      Go to the Data Stores page

    2. Click the name of your data store.

    3. On the Data page for your data store, get the data store ID.

  2. Run the following curl command to learn if your media recommendations meets the thresholds for the general metrics:

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -H "X-GFE-SSL: yes" \
    -H "X-Goog-User-Project: PROJECT_ID" \
    "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/requirements:checkRequirement" \
    -d '{
          "location": "projects/PROJECT_ID/locations/global",
          "requirementType": "discoveryengine.googleapis.com/media_recs/general/all/warning",
          "resources": [
            {
              "labels": {
                "branch_id": "0",
                "collection_id": "default_collection",
                "datastore_id": "DATA_STORE_ID",
                "location_id": "global",
                "project_number": "PROJECT_ID"
              },
              "type": "discoveryengine.googleapis.com/Branch"
            },
            {
              "labels": {
                "collection_id": "default_collection",
                "datastore_id": "DATA_STORE_ID",
                "location_id": "global",
                "project_number": "PROJECT_ID"
              },
              "type": "discoveryengine.googleapis.com/DataStore"
            }
          ]
        }'
    
    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
  3. Review the output:

    1. Look for the value of requirementResult:

      • If the value is SUCCESS, then your data passes the general requirements; continue to step 4.

      • If the value is WARNING, continue to step b.

      • If you don't see requirementResult in the output, there are a couple possible reasons:

        • The PROJECT_ID or DATA_STORE_ID in the request is incorrect.

        • Some metric values are unavailable. Try again in 6 hours or reach out to a customer engineer for help.

    2. Look for the expression (requirement.Condition.Expression): If this expression evaluates to false, then there is a problem with your data.

      The value of the metrics are in the requirementCondition.metricResults.value field. The warning threshold values are in the MetricBindings.warningThreshold fields. The description fields can help you understand the purpose of the metric.

      For example, the value of doc_with_same_title_percentage is 30.47 and the warning threshold for doc_with_same_title_percentage_threshold is 1. There is a data problem that so many of the titles in the data store are the same, and this needs to be investigated.

  4. If the model and objective combination used for your recommendations app appears in this table, then you also need to call the check requirement method, updated with the values for your model and objective:

    Model Objective MODEL_OBJ
    Others You May Like Conversion rate oyml/cvr
    Recommended for You Conversion rate rfy/cvr
    More Like This Conversion rate mlt/cvr
    Most Popular Conversion rate mp/cvr
    Others You May Like Watch duration per session oyml/wdps
    Recommended for You Watch duration per session rfy/wdps
    More Like This Watch duration per session mlt/wdps

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json" \
    -H "X-GFE-SSL: yes" \
    -H "X-Goog-User-Project: PROJECT_ID" \
    "https://discoveryengine.googleapis.com/v1alpha/projects/PROJECT_ID/locations/global/requirements:checkRequirement" \
    -d '{
          "location": "projects/PROJECT_ID/locations/global",
          "requirementType": "discoveryengine.googleapis.com/media_recs/MODEL_OBJ/warning",
          "resources": [
            {
              "labels": {
                "branch_id": "0",
                "collection_id": "default_collection",
                "datastore_id": "DATA_STORE_ID",
                "location_id": "global",
                "project_number": "PROJECT_ID"
              },
              "type": "discoveryengine.googleapis.com/Branch"
            },
            {
              "labels": {
                "collection_id": "default_collection",
                "datastore_id": "DATA_STORE_ID",
                "location_id": "global",
                "project_number": "PROJECT_ID"
              },
              "type": "discoveryengine.googleapis.com/DataStore"
            }
          ]
        }'
    
    • PROJECT_ID: the ID of your Google Cloud project.
    • DATA_STORE_ID: the ID of the Vertex AI Search data store.
    • MODEL_OBJ: See the preceding table to choose the correct value for your recommendations app.
  5. Review the output:

    1. Look for the value of requirementResult:

      • If the value is SUCCESS, then your data is good enough.

      • If the value is WARNING, continue to step b.

      • If you don't see requirementResult in the output, there are a couple possible reasons:

        • The PROJECT_ID or DATA_STORE_ID in the request is incorrect.

        • Some metric values are unavailable. Try again in 6 hours or reach out to a customer engineer for help.

    2. Look the expression (requirement.Condition.Expression). If this expression evaluates to false, then there is a problem with your data.

      The value of the metrics can be found in the requirementCondition.metricResults.value field, and the warning threshold values, in the MetricBindings.warningThreshold fields. The description fields can help you understand the purpose of the metric.