You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/machine-learning/how-to-train-scikit-learn.md
+57-37Lines changed: 57 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,70 +43,90 @@ You can run this code in either an Azure Machine Learning compute instance, or y
43
43
44
44
## Set up the experiment
45
45
46
-
This section sets up the training experiment by loading the required Python packages, initializing a workspace, defining the training environment, and preparing the training script.
46
+
This section sets up the training experiment by loading the required Python packages, connecting to a workspace, creating a compute resource to run a training job, and creating an environment to run the job.
47
47
48
-
### Initialize a workspace
48
+
### Connect to the workspace
49
49
50
-
The [Azure Machine Learning workspace](concept-workspace.md) is the top-level resource for the service. It provides you with a centralized place to work with all the artifacts you create.
50
+
First, you'll need to connect to your Azure Machine Learning workspace. The [AzureML workspace](concept-workspace.md) is the top-level resource for the service. It provides you with a centralized place to work with all the artifacts you create when you use Azure Machine Learning.
51
51
52
-
First, you'll need to connect to your Azure ML workspace. The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning.
52
+
We are using `DefaultAzureCredential`to get access to the workspace. `DefaultAzureCredential` should be capable of handling most Azure SDK authentication scenarios.
53
53
54
-
We are using DefaultAzureCredential to get access to workspace. DefaultAzureCredential should be capable of handling most Azure SDK authentication scenarios.
54
+
<!-- M.A: link to "configure credential example" is missing (broken in notebook) -->
55
+
If this credential does not work for you, see configure credential example and [`azure-identity reference documentation`](/python/api/azure-identity/azure.identity?view=azure-python) for more available credentials.
55
56
56
-
Reference for more available credentials if it does not work for you: configure credential example, azure-identity reference doc.
<!-- In the Python SDK, you can access the workspace artifacts by creating a [`workspace`](/python/api/azureml-core/azureml.core.workspace.workspace) object. -->
59
+
If you prefer to use a browser to sign in and authenticate, you can use the following code instead:
59
60
60
-
<!-- Create a workspace object from the `config.json` file created in the [prerequisites section](#prerequisites). -->
from azure.identity import InteractiveBrowserCredential
63
67
68
+
credential = InteractiveBrowserCredential()
69
+
```
64
70
65
-
### Prepare scripts
71
+
Next, get a handle to the workspace by providing your Subscription ID, Resource Group name, and Workspace name. To find your Subscription ID and Resource Group:
66
72
67
-
In this tutorial, the [training script **train_iris.py**](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/scikit-learn/train-hyperparameter-tune-deploy-with-sklearn/train_iris.py) is already provided for you. In practice, you should be able to take any custom training script as is and run it with Azure ML without having to modify your code.
73
+
1. Select your workspace name from the upper-right corner of the Azure Machine Learning Studio toolbar.
74
+
2. Copy the value for Resource group and Subscription ID into the code.
68
75
69
-
Notes:
70
-
- The provided training script shows how to log some metrics to your Azure ML run using the `Run` object within the script.
71
-
- The provided training script uses example data from the `iris = datasets.load_iris()` function. To use and access your own data, see [how to train with datasets](v1/how-to-train-with-datasets.md) to make data available during training.
The result of this example script is a workspace handle that you'll use to manage other resources and jobs.
74
79
75
-
To define the Azure ML [Environment](concept-environments.md) that encapsulates your training script's dependencies, you can either define a custom environment or use and Azure ML curated environment.
80
+
Note:
76
81
77
-
#### Use a curated environment
78
-
Optionally, Azure ML provides prebuilt, [curated environments](resource-curated-environments.md) if you don't want to define your own environment.
82
+
- Creating `MLClient` will not connect the client to the workspace. The client initialization is lazy and will wait for the first time it needs to make a call. In this article, this will happen during compute creation.
79
83
80
-
If you want to use a curated environment, you can run the following command instead:
84
+
### Create a Compute Resource to run the job
81
85
82
-
```python
83
-
from azureml.core import Environment
86
+
AzureML needs a compute resource to run a job. This resource can be single or multi-node machines with Linux or Windows OS, or a specific compute fabric like Spark.
<!-- MA: find proper way to link to the marketing page (second link) -->
89
+
In the following example script, we provision a Linux [`compute cluster`](/azure/machine-learning/how-to-create-attach-compute-cluster?tabs=python). You can see the [`Azure Machine Learning pricing`](https://azure.microsoft.com/en-us/pricing/details/machine-learning/) page for the full list of VM sizes and prices. Also, we only need a basic cluster for this example. Let's pick a Standard_DS3_v2 model with 2 vCPU cores and 7 GB RAM to create an AzureML Compute.
To run an AzureML job, you'll need an environment. An AzureML [Environment](concept-environments.md) encapsulates the dependencies (such as software runtime and libraries) needed to run your machine learning training script on your compute resource. This environment is similar to a Python environment on your local machine.
96
+
97
+
AzureML allows you to use either a curated (or ready-made) environment or define a custom environment using a Docker image or a Conda configuration. This article uses a custom environment.
87
98
88
99
#### Create a custom environment
89
100
90
-
You can also create your own your own custom environment. Define your conda dependencies in a YAML file; in this example the file is named `conda_dependencies.yml`.
101
+
To create your custom environment, you'll define your Conda dependencies in a YAML file. First, create a directory for storing the file. In this example, we've named the directory `dependencies_dir.yml`.
For more information on creating and using environments, see [Create and use software environments in Azure Machine Learning](how-to-use-environments.md).
109
116
117
+
### Data for training
118
+
119
+
<!-- ### Prepare scripts
120
+
121
+
For this tutorial, we've provided the [training script **train_iris.py**](https://github.com/Azure/MachineLearningNotebooks/blob/master/how-to-use-azureml/ml-frameworks/scikit-learn/train-hyperparameter-tune-deploy-with-sklearn/train_iris.py) for you. In practice, you should be able to take any custom training script as is and run it with AzureML without having to modify your code.
122
+
123
+
Notes:
124
+
125
+
The provided training script,
126
+
- Shows how to log some metrics to your AzureML run using the `Run` object .
127
+
- Uses example data from the `iris = datasets.load_iris()` function. To use and access your own data, see [how to train with datasets](v1/how-to-train-with-datasets.md) to make data available during training. -->
0 commit comments