Create or delete an experiment

You can use either the Vertex AI SDK for Python or the Google Cloud console to create or delete an experiment. The SDK is a library of Python code that you can use to programmatically create and manage experiments. The console is a web-based user interface that you can use to create and manage experiments visually.

Create experiment with a TensorBoard instance

Vertex AI SDK for Python

Create an experiment and, optionally, associate a Vertex AI TensorBoard instance using the Vertex AI SDK for Python. Add a description for the experiment to document its purpose. See init in the Vertex AI SDK reference documentation.

Python

from typing import Optional, Union

from google.cloud import aiplatform


def create_experiment_sample(
    experiment_name: str,
    experiment_description: str,
    experiment_tensorboard: Optional[Union[str, aiplatform.Tensorboard]],
    project: str,
    location: str,
):
    aiplatform.init(
        experiment=experiment_name,
        experiment_description=experiment_description,
        experiment_tensorboard=experiment_tensorboard,
        project=project,
        location=location,
    )

  • experiment_name: Provide a name for your experiment.
  • experiment_description: Provide a description for your experiment.
  • experiment_tensorboard: Optional. The Vertex TensorBoard instance to use as a backing TensorBoard for the provided experiment. If no experiment_tensorboard is provided, a default TB instance is created and used by this experiment. Note: If CMEK (encryption keys) need to be associated with the TensorBoard instance, then experiment_tensorboard is no longer optional.
  • project: Your project ID. You can find these IDs in the Google Cloud console welcome page.
  • location: See List of available locations Be sure to use a region that supports TensorBoard if creating a TensorBoard instance.

Google Cloud console

Use these instructions to create an experiment.

  1. In the Google Cloud console, go to the Experiments page.
    Go to Experiments
  2. Be sure you're in the project you want to create the experiment in.
    Vertex AI select project
  3. Click Create to open the Experiment pane. The Create experiment pane appears.
  4. In the Experiment name field, provide a name to uniquely identify your experiment.
  5. Optional. In the TensorBoard instance field, select an instance from the drop-down or provide a name for your new TensorBoard instance.
  6. Click Create to create your experiment.

Create an experiment without a default TensorBoard instance

Vertex AI SDK for Python

Create an experiment. Add a description for the experiment to document its purpose. See init in the Vertex AI SDK reference documentation.

Python

from google.cloud import aiplatform


def create_experiment_without_default_tensorboard_sample(
    experiment_name: str,
    experiment_description: str,
    project: str,
    location: str,
):
    aiplatform.init(
        experiment=experiment_name,
        experiment_description=experiment_description,
        experiment_tensorboard=False,
        project=project,
        location=location,
    )

  • experiment_name: Provide a name for your experiment.
  • experiment_description: Provide a description for your experiment.
  • project: Your project ID. You can find these IDs in the Google Cloud console welcome page.
  • location: See List of available locations Be sure to use a region that supports TensorBoard if creating a TensorBoard instance.

Delete experiment

Deleting an experiment deletes that experiment and all experiment runs associated with the experiment. The Vertex AI TensorBoard experiment associated with the experiment is not deleted. To delete a TensorBoard experiment, see Delete outdated Vertex AI TensorBoard experiment.

Also, any pipeline runs, artifacts, and executions associated with the deleted experiment are not removed. These can be found in the Google Cloud console. For artifacts and executions, a $10/GB monthly charge is handled by the Vertex ML Metadata service.

Vertex AI SDK for Python

The following sample uses the delete method from the ExperimentClass.

Python

from google.cloud import aiplatform


def delete_experiment_sample(
    experiment_name: str,
    project: str,
    location: str,
    delete_backing_tensorboard_runs: bool = False,
):
    experiment = aiplatform.Experiment(
        experiment_name=experiment_name, project=project, location=location
    )

    experiment.delete(delete_backing_tensorboard_runs=delete_backing_tensorboard_runs)

  • experiment_name: Provide a name for your experiment.
  • project: Your project ID. You can find these IDs in the Google Cloud console welcome page.
  • location: See List of available locations
  • delete_backing_tensorboard_runs: If True will also delete the Vertex AI TensorBoard runs associated with the experiment runs under this experiment that we used to store time series metrics.

Console

Use the following instructions to delete an experiment.

  1. In the Google Cloud console, go to the Experiments page.
    Go to Experiments
  2. Select the checkbox associated with the experiment you want to delete. The Delete option appears.
  3. Click Delete.
    • Alternatively, you can go to the  options menu that is in the same row as the experiment and select delete.

View list of experiments in Google Cloud console

  1. In the Google Cloud console, in the Vertex AI section, go to the Experiments page.

    Go to the Experiments page

  2. Check to be sure you are in the correct project.

  3. A list of experiments for your project appears in the Experiment tracking view.
    If you associated a Vertex AI TensorBoard instance with your experiment it shows up in the list as "your-experiment Backing TensorBoard Experiment".

Vertex AIList of experiments

What's next

Relevant notebook sample