L-diversity is a property of a dataset and an extension of k-anonymity that measures the diversity of sensitive values for each column in which they occur. A dataset has l-diversity if, for every set of rows with identical quasi-identifiers, there are at least l distinct values for each sensitive attribute.
You can compute the l-diversity value based on one or more columns, or fields, of a dataset. This topic demonstrates how to compute l-diversity values for a dataset using Sensitive Data Protection. For more information about l-diversity or risk analysis in general, see the risk analysis concept topic before continuing on.
Before you begin
Before continuing, be sure you've done the following:
- Sign in to your Google Account.
- In the Google Cloud console, on the project selector page, select or create a Google Cloud project. Go to the project selector
- Make sure that billing is enabled for your Google Cloud project. Learn how to confirm billing is enabled for your project.
- Enable Sensitive Data Protection. Enable Sensitive Data Protection
- Select a BigQuery dataset to analyze. Sensitive Data Protection calculates the l-diversity metric by scanning a BigQuery table.
- Determine a sensitive field identifier (if applicable) and at least one quasi-identifier in the dataset. For more information, see Risk analysis terms and techniques.
Compute l-diversity
Sensitive Data Protection performs risk analysis whenever a risk analysis job runs. You must create the job first, either by using the Google Cloud console, sending a DLP API request, or using a Sensitive Data Protection client library.
Console
In the Google Cloud console, go to the Create risk analysis page.
In the Choose input data section, specify the BigQuery table to scan by entering the project ID of the project containing the table, the dataset ID of the table, and the name of the table.
Under Privacy metric to compute, select l-diversity.
In the Job ID section, you can optionally give the job a custom identifier and select a resource location in which Sensitive Data Protection will process your data. When you're done, click Continue.
In the Define fields section, you specify sensitive fields and quasi-identifiers for the l-diversity risk job. Sensitive Data Protection accesses the metadata of the BigQuery table you specified in the previous step and attempts to populate the list of fields.
- Select the appropriate checkbox to specify a field as either a sensitive field (S) or quasi-identifier (QI). You must select 1 sensitive field and at least 1 quasi-identifier.
- If Sensitive Data Protection isn't able to populate the fields, click Enter field name to manually enter one or more fields and set each one as sensitive field or quasi-identifier. When you're done, click Continue.
In the Add actions section, you can add optional actions to perform when the risk job is complete. The available options are:
- Save to BigQuery: Saves the results of the risk analysis scan to a BigQuery table.
Publish to Pub/Sub: Publishes a notification to a Pub/Sub topic.
Notify by email: Sends you an email with results. When you're done, click Create.
The l-diversity risk analysis job starts immediately.
C#
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.