Skip to content

SOP-004: Managing Data

DOCUMENT CONTROL

FieldValue
SOP IDSOP-004
Version1.0
StatusActive

INFO

Document ControlTitle: Managing Data in Vertex AI Studio Version: 1.0 Date: 2023-04-26 Author: [Your Name] Approver: [Manager's Name]

Purpose

This Standard Operating Procedure (SOP) outlines the processes for importing, preprocessing, and managing data within Vertex AI Studio. It provides a step-by-step guide to ensure consistent and effective data management practices, enabling efficient model development and deployment.

Procedure

The following flowchart depicts the overall data management process in Vertex AI Studio:

1. Import Data

WARNING

Ensure that you have the necessary permissions and access to the data sources before proceeding with the import process.

  1. Connect to Data Source:

    • Navigate to the "Datasets" section in Vertex AI Studio.
    • Click on "Create Dataset" and select the appropriate data source (e.g., Google Cloud Storage, BigQuery, CSV file).
    • Follow the prompts to connect to the data source and authenticate your access.
  2. Configure Data Import:

    • Specify the dataset location and file format.
    • Review the dataset schema and make any necessary adjustments.
    • Set the appropriate data split (e.g., train, validation, test) if applicable.
  3. Import Data:

    • Initiate the data import process and monitor the progress.
    • Ensure that the data is successfully imported without any errors.

INFO

Example code for importing data from Google Cloud Storage:

python
from google.cloud import storage

# Set up the Google Cloud Storage client
storage_client = storage.Client()

# Specify the bucket and file path
bucket_name = "your-bucket-name"
file_path = "path/to/your/file.csv"

# Create a dataset and import the data
dataset = vertex_client.create_dataset(
    dataset_name="your-dataset-name",
    location="us-central1",
    import_config=vertex.ImportDataConfig(
        gcs_source=vertex.GcsSource(uri=f"gs://{bucket_name}/{file_path}")
    ),
)

2. Preprocess Data

WARNING

Ensure that you have a clear understanding of the data requirements for your specific use case before proceeding with data preprocessing.

  1. Explore and Inspect Data:

    • Analyze the imported data to understand its characteristics, distributions, and potential issues.
    • Use data visualization tools (e.g., Vertex AI Workbench, Jupyter Notebooks) to gain insights into the data.
  2. Perform Data Cleaning:

    • Handle missing values (e.g., imputation, dropping rows/columns).
    • Remove duplicates or inconsistencies in the data.
    • Normalize or scale numeric features as needed.
  3. Engineer Features:

    • Create new features based on the problem requirements and data characteristics.
    • Transform or combine existing features to improve model performance.
  4. Split Data:

    • Divide the data into appropriate subsets (e.g., train, validation, test) based on the project requirements.
    • Ensure that the data splits are representative and do not introduce bias.

INFO

Example code for data preprocessing in Vertex AI Studio:

python
import numpy as np
from sklearn.preprocessing import StandardScaler

# Explore and inspect the data
dataset.preview()

# Handle missing values
dataset.dropna(inplace=True)

# Scale numeric features
scaler = StandardScaler()
X_scaled = scaler.fit_transform(dataset[['feature1', 'feature2']])

# Split the data
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X_scaled, dataset['target'], test_size=0.2, random_state=42)

3. Manage Data

WARNING

Ensure that you have appropriate data versioning and backup strategies in place to maintain data integrity and traceability.

  1. Version Control:

    • Use Git or a version control system to track changes and maintain a history of the data.
    • Create branches or tags to manage different versions of the data.
  2. Data Backup and Archiving:

    • Implement regular backup procedures to ensure the safety and recoverability of the data.
    • Archive older versions of the data to maintain a comprehensive history.
  3. Access Control and Permissions:

    • Manage user access and permissions to the data, ensuring appropriate levels of visibility and modification rights.
    • Implement security measures to protect sensitive or confidential data.
  4. Metadata Management:

    • Document and maintain metadata, including dataset descriptions, feature definitions, and processing steps.
    • Utilize Vertex AI Metadata or a metadata management system to store and retrieve this information.

INFO

Example code for managing data in Vertex AI Studio:

python
from google.cloud import aiplatform

# Create a new data version
new_version = dataset.create_version(
    version_display_name="Version 2",
    description="Updated dataset with feature engineering"
)

# Backup the data to Google Cloud Storage
bucket_name = "your-backup-bucket"
backup_path = "path/to/backup/location"
dataset.export_data(
    output_uri_prefix=f"gs://{bucket_name}/{backup_path}"
)

# Manage metadata
metadata = vertex.Metadata(
    description="Customer sales dataset",
    labels={"department": "sales", "year": "2022"},
    uri="gs://your-bucket/dataset.csv"
)
metadata_store = aiplatform.MetadataStore(location="us-central1")
metadata_store.put_artifact(metadata)

Verification Checklist

  • [ ] Data import process completed successfully without errors.
  • [ ] Data preprocessing steps (cleaning, feature engineering, splitting) executed as planned.
  • [ ] Data versioning and backup procedures are in place.
  • [ ] Appropriate access controls and permissions are configured for the data.
  • [ ] Metadata is properly documented and managed.

Troubleshooting

IssuePossible CauseResolution
Data import failsIncorrect data source configurationReview the data source connection details and permissions
Missing or invalid dataIssues with the raw dataInvestigate the data source, identify and fix data quality problems
Slow data processingLarge dataset or complex preprocessingOptimize preprocessing steps, consider sampling or distributed processing
Metadata management issuesInconsistent or incomplete metadataReview metadata documentation, ensure proper metadata capture and storage
Access control problemsIncorrect user permissionsVerify user access rights and update as needed

See Also