Train a model using Vertex AI and the Python SDK

This tutorial takes between 30 and 60 minutes to complete.

This tutorial is a start-to-finish guide that shows you how to use theVertex AI SDK for Python to create a custom-trained model. You run code in anotebook (IPYNB) file that uses a Docker container to train and create themodel. The tutorial is for data scientists who are new to Vertex AI andfamiliar with notebooks, Python, and the Machine Learning (ML) workflow.

The process starts using the Google Cloud console to create the project thatcontains your work. In your project, you use Vertex AI Workbench tocreate a Jupyter notebook. The notebook environment is where you run codethat downloads and prepares a dataset, then use the dataset to create and traina model. At the end of the tutorial, the trained model generates predictions.

The goal of this tutorial is to walk you through every step required to createpredictions in less than an hour. The dataset used is relatively small so that itdoesn't take very long to train your model. When you're done, you can apply whatyou learn to larger datasets. The larger your dataset is, the more accurate yourpredictions are.

Tutorial steps

  1. Prerequisites - Create your Google Cloudaccount and project.

  2. Create anotebook -Create and prepare a Jupyter notebook and its environment. You use thenotebook to run code that creates your dataset, creates and trains yourmodel, and generates your predictions.

  3. Create a dataset - Download a publiclyavailable BigQuery dataset, then use it to create a Vertex AItabular dataset. The dataset contains the data you use to train your model.

  4. Create a training script - Createa Python script that you pass to your training job. The script runs when thetraining job trains and creates your model.

  5. Train a model - Use your tabulardataset to train and deploy a model. You use the model to create yourpredictions.

  6. Make predictions - Use your model tocreate predictions. This section also walks you through deleting resourcesyou create while running this tutorial so you don't incur unnecessarycharges.

What you accomplish

This tutorial walks you through how to use the Vertex AI SDK for Python to do thefollowing:

  • Create a Cloud Storage bucket to store a dataset
  • Preprocess data for training
  • Use the processed data to create a dataset in BigQuery
  • Use the BigQuery dataset to create a Vertex AI tabulardataset
  • Create and train a custom-trained model
  • Deploy the custom-trained model to an endpoint
  • Generate a prediction
  • Undeploy the model
  • Delete all resources created in the tutorial so you don't incur furthercharges

Billable resources used

This tutorial uses billable resources associated with the Vertex AI,BigQuery, and Cloud Storage Google Cloud services. If you'renew to Google Cloud, you might be able to use one or more of these services atno cost. Vertex AI offers $300 in free credits to new customers, andCloud Storage and BigQuery havefreetiers. For more information, see the following:

To prevent further charges, the final step of this tutorial walks youthrough removing all billable Google Cloud resources you created.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.