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
#Customer intent: As a professional data scientist, I can build an image classification model with Azure Machine Learning by using Python in a Jupyter Notebook.
In this tutorial, you train a machine learning model on remote compute resources. You'll use the training and deployment workflow for Azure Machine Learning in a Python Jupyter Notebook. You can then use the notebook as a template to train your own machine learning model with your own data.
21
+
In this tutorial, you train a machine learning model on remote compute resources. You use the training and deployment workflow for Azure Machine Learning in a Python Jupyter Notebook. You can then use the notebook as a template to train your own machine learning model with your own data.
22
22
23
23
This tutorial trains a simple logistic regression by using the [MNIST](http://yann.lecun.com/exdb/mnist/) dataset and [scikit-learn](https://scikit-learn.org) with Azure Machine Learning. MNIST is a popular dataset consisting of 70,000 grayscale images. Each image is a handwritten digit of 28 x 28 pixels, representing a number from zero to nine. The goal is to create a multi-class classifier to identify the digit a given image represents.
24
24
@@ -38,7 +38,7 @@ Learn how to take the following actions:
38
38
39
39
## Run a notebook from your workspace
40
40
41
-
Azure Machine Learning includes a cloud notebook server in your workspace for an install-free and pre-configured experience. Use [your own environment](how-to-configure-environment.md) if you prefer to have control over your environment, packages, and dependencies.
41
+
Azure Machine Learning includes a cloud notebook server in your workspace for an install-free and preconfigured experience. Use [your own environment](how-to-configure-environment.md) if you prefer to have control over your environment, packages, and dependencies.
42
42
43
43
## Clone a notebook folder
44
44
@@ -70,7 +70,7 @@ You complete the following experiment setup and run steps in Azure Machine Learn
70
70
71
71
## Install packages
72
72
73
-
Once the compute instance is running and the kernel appears, add a new code cell to install packages needed for this tutorial.
73
+
Once the compute instance is running and the kernel appears, add a new code cell to install packages needed for this tutorial.
74
74
75
75
1. At the top of the notebook, add a code cell.
76
76
:::image type="content" source="media/tutorial-train-deploy-notebook/add-code-cell.png" alt-text="Screenshot of add code cell for notebook.":::
@@ -82,14 +82,14 @@ Once the compute instance is running and the kernel appears, add a new code cell
82
82
%pip install scipy==1.5.2
83
83
```
84
84
85
-
You may see a few install warnings. These can safely be ignored.
85
+
You may see a few install warnings. These can safely be ignored.
86
86
87
87
## Run the notebook
88
88
89
89
This tutorial and accompanying **utils.py** file is also available on [GitHub](https://github.com/Azure/MachineLearningNotebooks/tree/master/tutorials) if you wish to use it on your own [local environment](how-to-configure-environment.md). If you aren't using the compute instance, add `%pip install azureml-sdk[notebooks] azureml-opendatasets matplotlib` to the install above.
90
90
91
91
> [!Important]
92
-
> The rest of this article contains the same content as you see in the notebook.
92
+
> The rest of this article contains the same content as you see in the notebook.
93
93
>
94
94
> Switch to the Jupyter Notebook now if you want to run the code while you read along.
95
95
> To run a single code cell in a notebook, click the code cell and hit **Shift+Enter**. Or, run the entire notebook by choosing **Run all** from the top toolbar.
@@ -101,7 +101,7 @@ Before you train a model, you need to understand the data you're using to train
101
101
* Download the MNIST dataset
102
102
* Display some sample images
103
103
104
-
You'll use Azure Open Datasets to get the raw MNIST data files. Azure Open Datasets are curated public datasets that you can use to add scenario-specific features to machine learning solutions for better models. Each dataset has a corresponding class, `MNIST` in this case, to retrieve the data in different ways.
104
+
You use Azure Open Datasets to get the raw MNIST data files. Azure Open Datasets are curated public datasets that you can use to add scenario-specific features to machine learning solutions forbetter models. Each dataset has a corresponding class, `MNIST`in this case, to retrieve the data in different ways.
Load the compressed files into `numpy` arrays. Then use `matplotlib` to plot 30 random images from the dataset with their labels above them.
121
121
122
-
Note this step requires a `load_data` function that's included in an `utils.py` file. This file is placed in the same folder as this notebook. The `load_data`functionsimply parses the compressed files into numpy arrays.
122
+
Note this step requires a `load_data` function, included in an `utils.py` file. This file is placed in the same folder as this notebook. The `load_data`functionsimply parses the compressed files into numpy arrays.
123
123
124
124
125
125
```python
@@ -175,13 +175,13 @@ for i in np.random.permutation(X_train.shape[0])[:sample_size]:
The code above displays a random set of images with their labels, similar to this:
178
+
The code displays a random set of images with their labels, similar to this:
179
179
180
180
:::image type="content" source="media/tutorial-train-deploy-notebook/image-data-with-labels.png" alt-text="Sample images with their labels.":::
181
181
182
182
## Train model and log metrics with MLflow
183
183
184
-
You'll train the model using the code below. Note that you are using MLflow autologging to track metrics and log model artifacts.
184
+
Train the model using the following code. This code uses MLflow autologging to track metrics and log model artifacts.
185
185
186
186
You'll be using the [LogisticRegression](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html) classifier from the [SciKit Learn framework](https://scikit-learn.org/) to classify the data.
187
187
@@ -220,13 +220,13 @@ with mlflow.start_run() as run:
220
220
221
221
## View experiment
222
222
223
-
In the left-hand menu in Azure Machine Learning studio, select__Jobs__ and thenselectyour job (__azure-ml-in10-mins-tutorial__). A job is a grouping of many runs from a specified script or piece of code. Multiple jobs can be grouped together as an experiment.
223
+
In the left-hand menu in Azure Machine Learning studio, select __Jobs__ and then select your job (__azure-ml-in10-mins-tutorial__). A job is a grouping of many runs from a specified script or piece of code. Multiple jobs can be grouped together as an experiment.
224
224
225
-
Information for the run is stored under that job. If the name doesn't exist when you submit a job, if you select your run you will see various tabs containing metrics, logs, explanations, etc.
225
+
Information for the run is stored under that job. If the name doesn't exist when you submit a job, if you selectyour run you'll see various tabs containing metrics, logs, explanations, etc.
226
226
227
227
## Version control your models with the model registry
228
228
229
-
You can use model registration to store and version your models in your workspace. Registered models are identified by name and version. Each time you register a model with the same name as an existing one, the registry increments the version. The code below registers and versions the model you trained above. Once you have executed the code cell below you will be able to see the model in the registry by selecting __Models__ in the left-hand menu in Azure Machine Learning studio.
229
+
You can use model registration to store and version your models in your workspace. Registered models are identified by name and version. Each time you register a model with the same name as an existing one, the registry increments the version. The code below registers and versions the model you trained above. Once you execute the following code cell, you'll see the model in the registry by selecting __Models__ in the left-hand menu in Azure Machine Learning studio.
230
230
231
231
```python
232
232
# register the model
@@ -236,11 +236,11 @@ model = mlflow.register_model(model_uri, "sklearn_mnist_model")
236
236
237
237
## Deploy the model for real-time inference
238
238
239
-
In this section you learn how to deploy a model so that an application can consume (inference) the model over REST.
239
+
In this section, learn how to deploy a model so that an application can consume (inference) the model over REST.
240
240
241
241
### Create deployment configuration
242
242
243
-
The code cell gets a _curated environment_, which specifies all the dependencies required to host the model (for example, the packages like scikit-learn). Also, you create a _deployment configuration_, which specifies the amount of compute required to host the model. In this case, the compute will have 1CPU and 1GB memory.
243
+
The code cell gets a _curated environment_, which specifies all the dependencies required to host the model (for example, the packages like scikit-learn). Also, you create a _deployment configuration_, which specifies the amount of compute required to host the model. In this case, the compute has 1CPU and 1-GB memory.
This next code cell deploys the model to Azure Container Instance.
272
272
273
273
> [!NOTE]
274
-
> The deployment takes approximately 3 minutes to complete.**
274
+
> The deployment takes approximately 3 minutes to complete. But it might be longer to until it is available for use, perhaps as long as 15 minutes.**
275
275
276
276
277
277
```python
@@ -300,14 +300,14 @@ service = Model.deploy(
300
300
service.wait_for_deployment(show_output=True)
301
301
```
302
302
303
-
The scoring script file referenced in the code above can be found in the same folder as this notebook, and has two functions:
303
+
The scoring script file referenced in the preceding code can be found in the same folder as this notebook, and has two functions:
304
304
305
305
1. An `init`functionthat executes once when the service starts - in this functionyou normally get the model from the registry and set global variables
306
306
1. A `run(data)`functionthat executes each time a call is made to the service. In this function, you normally format the input data, run a prediction, and output the predicted result.
307
307
308
308
### View endpoint
309
309
310
-
Once the model has been successfully deployed, you can view the endpoint by navigating to __Endpoints__ in the left-hand menu in Azure Machine Learning studio. You will be able to see the state of the endpoint (healthy/unhealthy), logs, and consume (how applications can consume the model).
310
+
Once the model is successfully deployed, you can view the endpoint by navigating to __Endpoints__ in the left-hand menu in Azure Machine Learning studio. You'll see the state of the endpoint (healthy/unhealthy), logs, and consume (how applications can consume the model).
311
311
312
312
## Test the model service
313
313
@@ -340,7 +340,7 @@ If you're not going to continue to use this model, delete the Model service usin
340
340
service.delete()
341
341
```
342
342
343
-
If you want to control cost further, stop the compute instance by selecting the "Stop compute" button next to the **Compute** dropdown. Then start the compute instance again the next time you need it.
343
+
If you want to control cost further, stop the compute instance by selecting the "Stop compute" button next to the **Compute** dropdown. Then start the compute instance again the next time you need it.
0 commit comments