This tutorial demonstrates how to create a model for classifying content using Vertex AI. The tutorial trains an AutoML model by using a corpus of crowd-sourced "happy moments" from the Kaggle open-source dataset HappyDB. The resulting model classifies happy moments into categories reflecting the causes of happiness.
To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:
For this part of the tutorial, you set up your Google Cloud project to use Vertex AI and a Cloud Storage bucket that contains the documents for training your AutoML model.
This tutorial has several pages:
Setting up your project and environment.
Each page assumes that you have already performed the instructions from the previous pages of the tutorial.
Set up your project
Throughout this tutorial, use Google Cloud console to interact with Google Cloud. Complete the following steps before using Vertex AI functionality.
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project. Learn how to check if billing is enabled on a project.
-
Enable the Vertex AI API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
To provide access to your project, grant the Project > Owner role to your service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project. Learn how to check if billing is enabled on a project.
-
Enable the Vertex AI API.
-
Create a service account:
-
In the Google Cloud console, go to the Create service account page.
Go to Create service account - Select your project.
-
In the Service account name field, enter a name. The Google Cloud console fills in the Service account ID field based on this name.
In the Service account description field, enter a description. For example,
Service account for quickstart
. - Click Create and continue.
-
To provide access to your project, grant the Project > Owner role to your service account.
To grant the role, find the Select a role list, then select Project > Owner.
- Click Continue.
-
Click Done to finish creating the service account.
Do not close your browser window. You will use it in the next step.
-
-
Create a service account key:
- In the Google Cloud console, click the email address for the service account that you created.
- Click Keys.
- Click Add key, and then click Create new key.
- Click Create. A JSON key file is downloaded to your computer.
- Click Close.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your service account key. This variable only applies to your current shell session, so if you open a new session, set the variable again. -
In the Google Cloud console, activate Cloud Shell.
At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.
Create a Cloud Storage bucket and copy the sample dataset
Create a Cloud Storage bucket to store the documents that you use to train your AutoML model.
Set the PROJECT_ID variable to the ID of your project.
export PROJECT_ID=PROJECT_ID
Set the BUCKET variable, which you use to create a Cloud Storage bucket.
export BUCKET=${PROJECT_ID}-lcm
Create a Cloud Storage bucket in the
us-central1
region with theBUCKET
variable.gsutil mb -p ${PROJECT_ID} -l us-central1 gs://${BUCKET}/
Copy the
happiness.csv
sample training dataset into your bucket.gsutil -m cp -R gs://cloud-ml-data/NL-classification/happiness.csv gs://${BUCKET}/text/
What's next
Follow the next page of this tutorial to use the Vertex AI console to create a text classification dataset and import the documents you copied to your Cloud Storage bucket.