快速入門:使用您自有的 Notebook 伺服器來開始使用 Azure Machine LearningQuickstart: Use your own notebook server to get started with Azure Machine Learning

使用您自有的 Python 環境和 Jupyter Notebook 伺服器,開始使用 Azure Machine Learning 服務。Use your own Python environment and Jupyter Notebook Server to get started with Azure Machine Learning service. 如需不安裝 SDK 的快速入門,請參閱快速入門:使用雲端式 Notebook 伺服器開始使用 Azure Machine LearningFor a quickstart with no SDK installation, see Quickstart: Use a cloud-based notebook server to get started with Azure Machine Learning.

本快速入門顯示您可以如何使用 Azure Machine Learning 服務工作區來追蹤您的機器學習實驗。This quickstart shows how you can use the Azure Machine Learning service workspace to keep track of your machine learning experiments. 您將會執行將值記錄到工作區中的 Python 程式碼。You will run Python code that log values into the workspace.

檢視本快速入門的影片版本:View a video version of this quickstart:

如果您沒有 Azure 訂用帳戶,請在開始前先建立一個免費帳戶。If you don’t have an Azure subscription, create a free account before you begin. 立即試用免費或付費版本的 Azure Machine Learning 服務Try the free or paid version of Azure Machine Learning service today.

必要條件Prerequisites

  • 已安裝 Azure Machine Learning SDK 的 Python 3.6 Notebook 伺服器A Python 3.6 notebook server with the Azure Machine Learning SDK installed
  • Azure Machine Learning 服務工作區An Azure Machine Learning service workspace
  • 工作區設定檔 ( .azureml/config.json)。A workspace configuration file (.azureml/config.json).

建立 Azure Machine Learning 服務工作區取得上述所有必要條件。Get all these prerequisites from Create an Azure Machine Learning service workspace.

使用工作區Use the workspace

在與工作區設定檔 ( .azureml/config.json) 相同的目錄中建立指令碼或啟動 Notebook。Create a script or start a notebook in the same directory as your workspace configuration file (.azureml/config.json).

連結到工作區Attach to workspace

此程式碼會從設定檔讀取資訊以連結到工作區。This code reads information from the configuration file to attach to your workspace.

from azureml.core import Workspace

ws = Workspace.from_config()

記錄值Log values

執行使用基本 SDK API 的程式碼以追蹤實驗執行。Run this code that uses the basic APIs of the SDK to track experiment runs.

  1. 在工作區中建立實驗。Create an experiment in the workspace.
  2. 將單一值記錄到實驗中。Log a single value into the experiment.
  3. 將值清單記錄到實驗中。Log a list of values into the experiment.
from azureml.core import Experiment

# Create a new experiment in your workspace.
exp = Experiment(workspace=ws, name='myexp')

# Start a run and start the logging service.
run = exp.start_logging()

# Log a single  number.
run.log('my magic number', 42)

# Log a list (Fibonacci numbers).
run.log_list('my list', [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) 

# Finish the run.
run.complete()

檢視記錄的值View logged results

執行完成時,您可以在 Azure 入口網站中檢視實驗執行。When the run finishes, you can view the experiment run in the Azure portal. 若要列印會瀏覽至前次執行結果的 URL,請使用下列程式碼:To print a URL that navigates to the results for the last run, use the following code:

print(run.get_portal_url())

在瀏覽器中,此程式碼會傳回連結供您用來檢視 Azure 入口網站中的記錄值。This code returns a link you can use to view the logged values in the Azure portal in your browser.

Azure 入口網站中已記錄的值

清除資源Clean up resources

重要

您可以使用在此處建立的資源,作為其他 Machine Learning 教學課程和操作說明文章的必要條件。You can use the resources you've created here as prerequisites to other Machine Learning tutorials and how-to articles.

如果您不打算繼續使用您在本文中建立的資源,請加以刪除,以避免產生費用。If you don't plan to use the resources that you created in this article, delete them to avoid incurring any charges.

ws.delete(delete_dependent_resources=True)

後續步驟Next steps

在本文中,您已建立進行實驗和部署模型所需的資源。In this article, you created the resources you need to experiment with and deploy models. 您在 Notebook 中執行了程式碼,並且在雲端的工作區中探索了該程式碼的執行歷程記錄。You ran code in a notebook, and you explored the run history for the code in your workspace in the cloud.

您也可以探索 GitHub 上更進階的範例或檢視 SDK 使用者指南You can also explore more advanced examples on GitHub or view the SDK user guide.