# Get the prediction for each set of input data.
species_predictions = np.argmax(predictions.predictions, axis=1)
# View the best prediction for the penguin characteristics in each row.
species_predictions
importos# Delete the training jobjob.delete()# Delete the endpoint and undeploy the model from itendpoint.delete(force=True)# Delete the modelmodel.delete()# Delete the storage bucket and its contentsbucket.delete(force=True)
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Make a prediction\n\nYou're now ready to use the test data in `df_for_prediction` to make a prediction request. The prediction request invokes your model to predict what species of penguin is represented by the penguin characteristics in each row in `df_for_prediction`.\n\n\u003cbr /\u003e\n\nPrepare prediction test data\n----------------------------\n\nBefore you can use the test data to create predictions, you remove the `species`\ncolumn. Because the species of penguin is what you're predicting, it can't be\nincluded in the test data used to create a prediction. After you remove the\n`species` column, you convert the data to a Python list because that's what the\n`predict` method takes as input. Run the following code convert your data\nto a Python list: \n\n # Remove the species column\n df_for_prediction.pop(LABEL_COLUMN)\n\n # Convert data to a Python list\n test_data_list = df_for_prediction.values.tolist()\n\n(Optional) View test data\n-------------------------\n\nTo help you understand the test data, you can run the following line of code to\nview it: \n\n test_data_list\n\nIn each row, the respective values in each of the six columns refer to the following\ncharacteristics of one penguin:\n\nSend the prediction request\n---------------------------\n\nTo create a prediction request, pass the Python list of test data you created to\nthe `endpoint`'s\n[`predict`](https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform.Endpoint#google_cloud_aiplatform_Endpoint_predict) method.\n\nThe `predict` method evaluates the characteristics in each row and uses them to\npredict what kind of penguin they represent. Run the following code to create\nyour predictions. The returned predictions contain a list of rows, where each\nrow has three columns (*Adelie Penguin (Pygoscelis adeliae)* (column 1),\n*Chinstrap penguin (Pygoscelis antarctica)* (column 2), or *Gentoo penguin\n(Pygoscelis papua)* (column 3)). \n\n # Get your predictions.\n predictions = endpoint.predict(instances=test_data_list)\n\n # View the predictions\n predictions.predictions\n\nEach column in a row contains a value, and the higher the value, the greater the\nconfidence that the species of the penguin represented by that column is a\ncorrect prediction. For example, in the following sample prediction output row,\nthe model uses the characteristics of the sample penguin data row to predict\nthat the penguin is most likely of the *Adelie Penguin (Pygoscelis adeliae)*\nspecies. This is because the highest value, `0.732703805`, is in the first\ncolumn.\n\n`[0.732703805, 0.233752429, 0.0335437432]`\n\nIn the following code, the NumPy `argmax` method returns the column for each row\nthat contains the highest value. The highest value corresponds to the prediction\nthat is most likely correct. The second line displays the array of predictions. \n\n # Get the prediction for each set of input data.\n species_predictions = np.argmax(predictions.predictions, axis=1)\n\n # View the best prediction for the penguin characteristics in each row.\n species_predictions\n\nEach result in the `species_predictions` array predicts which penguin species\nthe values in the corresponding row of test data corresponds to. For example,\nthe first value is `0`, which maps to the *Adelie Penguin (Pygoscelis adeliae)*\nspecies. This means that your model predicts that the species of a penguin with\nthe characteristics in the first row of your test data is *Adelie Penguin\n(Pygoscelis adeliae)*.\n\nClean up resources\n------------------\n\nNow that you're done, you can continue to use your notebook to explore and learn\nmore about the resources you created and how they work.\n\n### Delete your resources\n\nWhen you're ready, we recommend that you delete the Google Cloud resources you\ncreated during this tutorial so that you don't incur unnecessary charges. There\nare two ways to delete your resources:\n\n- Delete your project, which also deletes all the resources associated with your\n project. For more information, see [Shutting down (deleting)\n projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects).\n\n- Run code that deletes your training job (a `CustomTrainingJob` object), model\n (a `Model` object), endpoint (an `Endpoint` object), and Cloud Storage\n bucket. This option retains your project and any other resources you might\n have created that you don't explicitly delete with your code.\n\n You must undeploy your model before you can delete it by passing `force=True`\n to the\n [`endpoint.delete`](https://cloud.google.com/python/docs/reference/aiplatform/latest/google.cloud.aiplatform.Endpoint#google_cloud_aiplatform_Endpoint_delete)\n method.\n\n To retain your project and delete only resources you created during this\n tutorial, run the following code in your notebook:\n\n import os\n\n # Delete the training job\n job.delete()\n\n # Delete the endpoint and undeploy the model from it\n endpoint.delete(force=True)\n\n # Delete the model\n model.delete()\n\n # Delete the storage bucket and its contents\n bucket.delete(force=True)\n\n### Delete your Vertex AI Workbench instance\n\nYou can keep your Vertex AI Workbench instance to use for future\nwork. If you keep it, make sure you are aware of its cost. For more\ninformation, see [Vertex AI Workbench\npricing](/vertex-ai/pricing#notebooks).\n\nIf you want to delete the Vertex AI Workbench instance,\ndo the following:\n\n1. In the Google Cloud console, go to the\n Vertex AI Workbench **Instances** page.\n\n [Go to Instances](https://console.cloud.google.com/vertex-ai/workbench/instances)\n2. Select your Vertex AI Workbench instance.\n\n3. In the upper menu, click\n delete **Delete**.\n\n4. In the **Delete instance** confirmation dialog, click **Confirm**. It takes\n a few minutes for the deletion to complete."]]