Get Started with Azure Machine Learning
This tutorial will guide you through the essential steps to set up and begin your first machine learning project using Azure Machine Learning. You'll learn how to create an Azure ML workspace, connect to it, and perform basic operations.
Prerequisites
- An Azure subscription. If you don't have one, you can create a free account.
- Azure CLI installed and configured. Install Azure CLI.
- Python 3.7 or later installed. Download Python.
Step 1: Create an Azure Machine Learning Workspace
An Azure Machine Learning workspace is the top-level resource for Azure Machine Learning. It provides a centralized place to work with all the artifacts you create when you use Azure Machine Learning.
You can create a workspace using the Azure portal, Azure CLI, or SDKs. We'll use the Azure CLI for this tutorial.
az login
.
Run the following commands in your terminal:
az group create --name my-ml-resource-group --location eastus
az ml workspace create --name my-ml-workspace --resource-group my-ml-resource-group --location eastus
These commands will create a new resource group and then create your Azure Machine Learning workspace within that group.
Step 2: Install the Azure ML SDK for Python
The Azure ML SDK for Python allows you to interact with your workspace programmatically.
Install the SDK using pip:
pip install azure-ai-ml azure-identity
Step 3: Connect to Your Workspace
Now, let's connect to your newly created workspace using Python.
from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential
# Define your workspace details
subscription_id = ""
resource_group = "my-ml-resource-group"
workspace_name = "my-ml-workspace"
# Authenticate and create the MLClient object
credential = DefaultAzureCredential()
ml_client = MLClient(credential, subscription_id, resource_group, workspace_name)
print(f"Connected to workspace: {ml_client.workspace_name}")
Remember to replace <YOUR_SUBSCRIPTION_ID>
with your actual Azure subscription ID.
Step 4: Explore Workspace Information
You can retrieve various details about your workspace:
print(f"Workspace ID: {ml_client.workspace_id}")
print(f"Location: {ml_client.location}")
print(f"Creation time: {ml_client.creation_time}")