Addestrare un modello utilizzando Vertex AI e l'SDK Python
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo tutorial è una guida completa che mostra come utilizzare l'SDK Vertex AI per Python per creare un modello addestrato personalizzato. Esegui il codice in un
file del notebook (IPYNB) che utilizza un container Docker per addestrare e creare il
modello. Il tutorial è rivolto ai data scientist che non hanno dimestichezza con Vertex AI, ma conoscono i notebook, Python e il flusso di lavoro di machine learning (ML).
Il processo inizia utilizzando la Google Cloud console per creare il progetto che contiene il tuo lavoro. Nel tuo progetto, utilizzi Vertex AI Workbench per creare un blocco note Jupyter. Nell'ambiente del notebook esegui il codice
che scarica e prepara un set di dati, quindi utilizza il set di dati per creare e addestrare
un modello. Al termine del tutorial, il modello addestrato genera le previsioni.
L'obiettivo di questo tutorial è illustrare tutti i passaggi necessari per creare predizioni in meno di un'ora. Il set di dati utilizzato è relativamente piccolo, quindi l'addestramento del modello non richiede molto tempo. Al termine, puoi applicare ciò che hai imparato a set di dati più grandi. Maggiore è il set di dati, più accurate sono le tue
predizioni.
Passaggi del tutorial
Prerequisiti: crea il tuo Google Cloud
account e il tuo progetto.
Crea un
blocco note:
crea e prepara un blocco note Jupyter e il relativo ambiente. Utilizzi il
notebook per eseguire il codice che crea il set di dati, crea e addestra il
modello e genera le previsioni.
Crea un set di dati: scarica un set di dati BigQuery disponibile pubblicamente, quindi utilizzalo per creare un set di dati tabulari Vertex AI. Il set di dati contiene i dati che utilizzi per addestrare il modello.
Crea uno script di addestramento: crea un script Python da passare al job di addestramento. Lo script viene eseguito quando il job di addestramento addestra e crea il modello.
Addestramento di un modello: utilizza il set di dati tabulare per addestrare ed eseguire il deployment di un modello. Utilizza il modello per creare le tue
predizioni.
Fai previsioni: utilizza il modello per creare previsioni. Questa sezione illustra anche la procedura di eliminazione delle risorse
che crei durante l'esecuzione di questo tutorial per evitare addebiti
superflui.
I risultati che raggiungi
Questo tutorial illustra come utilizzare l'SDK Vertex AI per Python per svolgere quanto segue:
Creare un bucket Cloud Storage per archiviare un set di dati
Pre-elaborazione dei dati per l'addestramento
Utilizza i dati elaborati per creare un set di dati in BigQuery
Utilizza il set di dati BigQuery per creare un set di dati tabulare Vertex AI
Crea e addestra un modello con addestramento personalizzato
Esegui il deployment del modello con addestramento personalizzato su un endpoint
Generare una previsione
Annullare il deployment del modello
Elimina tutte le risorse create nel tutorial per evitare ulteriori addebiti
Risorse fatturabili utilizzate
Questo tutorial utilizza risorse fatturabili associate ai servizi Google Cloud Vertex AI, BigQuery e Cloud Storage. Se non hai mai utilizzato Google Cloud, potresti essere in grado di utilizzare uno o più di questi servizi senza costi. Vertex AI offre 300 $di crediti gratuiti ai nuovi clienti e Cloud Storage e BigQuery hanno livelli gratuiti. Per ulteriori informazioni, consulta le seguenti risorse:
Per evitare ulteriori addebiti, il passaggio finale di questo tutorial illustra la procedura per rimuovere tutte le risorse Google Cloud fatturabili che hai creato.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[],[],null,["# Train a model using Vertex AI and the Python SDK\n\n| This tutorial takes between 30 and 60 minutes to complete.\n\n\u003cbr /\u003e\n\nThis tutorial is a start-to-finish guide that shows you how to use the\nVertex AI SDK for Python to create a custom-trained model. You run code in a\nnotebook (IPYNB) file that uses a Docker container to train and create the\nmodel. The tutorial is for data scientists who are new to Vertex AI and\nfamiliar with notebooks, Python, and the Machine Learning (ML) workflow.\n\nThe process starts using the Google Cloud console to create the project that\ncontains your work. In your project, you use Vertex AI Workbench to\ncreate a Jupyter notebook. The notebook environment is where you run code\nthat downloads and prepares a dataset, then use the dataset to create and train\na model. At the end of the tutorial, the trained model generates predictions.\n\nThe goal of this tutorial is to walk you through every step required to create\npredictions in less than an hour. The dataset used is relatively small so that it\ndoesn't take very long to train your model. When you're done, you can apply what\nyou learn to larger datasets. The larger your dataset is, the more accurate your\npredictions are.\n\nTutorial steps\n--------------\n\n1. [Prerequisites](/vertex-ai/docs/tutorials/tabular-bq-prediction/prerequisites) - Create your Google Cloud\n account and project.\n\n2. [Create a\n notebook](/vertex-ai/docs/tutorials/tabular-bq-prediction/create-notebook) -\n Create and prepare a Jupyter notebook and its environment. You use the\n notebook to run code that creates your dataset, creates and trains your\n model, and generates your predictions.\n\n3. [Create a dataset](/vertex-ai/docs/tutorials/tabular-bq-prediction/create-dataset) - Download a publicly\n available BigQuery dataset, then use it to create a Vertex AI\n tabular dataset. The dataset contains the data you use to train your model.\n\n4. [Create a training script](/vertex-ai/docs/tutorials/tabular-bq-prediction/create-training-script) - Create\n a Python script that you pass to your training job. The script runs when the\n training job trains and creates your model.\n\n5. [Train a model](/vertex-ai/docs/tutorials/tabular-bq-prediction/train-and-deploy-model) - Use your tabular\n dataset to train and deploy a model. You use the model to create your\n predictions.\n\n6. [Make predictions](/vertex-ai/docs/tutorials/tabular-bq-prediction/make-prediction) - Use your model to\n create predictions. This section also walks you through deleting resources\n you create while running this tutorial so you don't incur unnecessary\n charges.\n\nWhat you accomplish\n-------------------\n\nThis tutorial walks you through how to use the Vertex AI SDK for Python to do the\nfollowing:\n\n- Create a Cloud Storage bucket to store a dataset\n- Preprocess data for training\n- Use the processed data to create a dataset in BigQuery\n- Use the BigQuery dataset to create a Vertex AI tabular dataset\n- Create and train a custom-trained model\n- Deploy the custom-trained model to an endpoint\n- Generate a prediction\n- Undeploy the model\n- Delete all resources created in the tutorial so you don't incur further charges\n\nBillable resources used\n-----------------------\n\nThis tutorial uses billable resources associated with the Vertex AI,\nBigQuery, and Cloud Storage Google Cloud services. If you're\nnew to Google Cloud, you might be able to use one or more of these services at\nno cost. Vertex AI offers $300 in free credits to new customers, and\nCloud Storage and BigQuery have [free\ntiers](https://cloud.google.com/free). For more information, see the following:\n\n- [Vertex AI pricing](/vertex-ai/pricing) and [Free cloud features and trial offer](https://cloud.google.com/free/docs/free-cloud-features#free-trial)\n- [BigQuery pricing](/bigquery/pricing) and [BigQuery free tier usage](https://cloud.google.com/free/docs/free-cloud-features?#bigquery)\n- [Cloud Storage pricing](/storage/pricing) and [Cloud Storage free tier usage](https://cloud.google.com/free/docs/free-cloud-features#storage)\n- [Google Cloud pricing calculator](/products/calculator)\n\nTo prevent further charges, the final step of this tutorial walks you\nthrough removing all billable Google Cloud resources you created."]]