Skip to content

Commit 51bbf98

Browse files
Merge pull request #270986 from sdgilley/sdg-freshness
Freshness update v1 tutorial-train-deploy-notebook
2 parents 20d5662 + bc51721 commit 51bbf98

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

articles/machine-learning/v1/tutorial-train-deploy-notebook.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ms.topic: tutorial
99
author: sdgilley
1010
ms.author: sgilley
1111
ms.reviewer: sgilley
12-
ms.date: 09/14/2022
12+
ms.date: 04/02/2024
1313
ms.custom: UpdateFrequency5, sdkv1, devx-track-python
1414
#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.
1515
---
@@ -18,7 +18,7 @@ ms.custom: UpdateFrequency5, sdkv1, devx-track-python
1818

1919
[!INCLUDE [sdk v1](../includes/machine-learning-sdk-v1.md)]
2020

21-
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.
2222

2323
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.
2424

@@ -38,7 +38,7 @@ Learn how to take the following actions:
3838

3939
## Run a notebook from your workspace
4040

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.
4242

4343
## Clone a notebook folder
4444

@@ -70,7 +70,7 @@ You complete the following experiment setup and run steps in Azure Machine Learn
7070

7171
## Install packages
7272

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.
7474

7575
1. At the top of the notebook, add a code cell.
7676
:::image type="content" source="media/tutorial-train-deploy-notebook/add-code-cell.png" alt-text="Screenshot of add code cell for notebook.":::
@@ -82,26 +82,28 @@ Once the compute instance is running and the kernel appears, add a new code cell
8282
%pip install scipy==1.5.2
8383
```
8484

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.
8686

8787
## Run the notebook
8888

8989
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.
9090
9191
> [!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.
9393
>
9494
> Switch to the Jupyter Notebook now if you want to run the code while you read along.
9595
> 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.
9696
97+
<!-- nbstart https://raw.githubusercontent.com/Azure/MachineLearningNotebooks/master/tutorials/compute-instance-quickstarts/quickstart-azureml-in-10mins/quickstart-azureml-in-10mins.ipynb -->
98+
9799
## Import data
98100
99101
Before you train a model, you need to understand the data you're using to train it. In this section, learn how to:
100102

101103
* Download the MNIST dataset
102104
* Display some sample images
103105

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.
106+
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 for better models. Each dataset has a corresponding class, `MNIST` in this case, to retrieve the data in different ways.
105107

106108

107109
```python
@@ -119,7 +121,7 @@ mnist_file_dataset.download(data_folder, overwrite=True)
119121

120122
Load the compressed files into `numpy` arrays. Then use `matplotlib` to plot 30 random images from the dataset with their labels above them.
121123

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` function simply parses the compressed files into numpy arrays.
124+
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` function simply parses the compressed files into numpy arrays.
123125

124126

125127
```python
@@ -175,18 +177,18 @@ for i in np.random.permutation(X_train.shape[0])[:sample_size]:
175177
plt.imshow(X_train[i].reshape(28, 28), cmap=plt.cm.Greys)
176178
plt.show()
177179
```
178-
The code above displays a random set of images with their labels, similar to this:
180+
The code displays a random set of images with their labels, similar to this:
179181
180182
:::image type="content" source="media/tutorial-train-deploy-notebook/image-data-with-labels.png" alt-text="Sample images with their labels.":::
181183
182184
## Train model and log metrics with MLflow
183185
184-
You'll train the model using the code below. Note that you are using MLflow autologging to track metrics and log model artifacts.
186+
Train the model using the following code. This code uses MLflow autologging to track metrics and log model artifacts.
185187
186188
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.
187189
188190
> [!NOTE]
189-
> The model training takes approximately 2 minutes to complete.**
191+
> The model training takes approximately 2 minutes to complete.
190192
191193
192194
```python
@@ -217,16 +219,15 @@ clf = LogisticRegression(
217219
with mlflow.start_run() as run:
218220
clf.fit(X_train, y_train)
219221
```
220-
221222
## View experiment
222223
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+
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.
224225
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.
226+
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'll see various tabs containing metrics, logs, explanations, etc.
226227
227228
## Version control your models with the model registry
228229
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.
230+
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.
230231
231232
```python
232233
# register the model
@@ -236,11 +237,11 @@ model = mlflow.register_model(model_uri, "sklearn_mnist_model")
236237
237238
## Deploy the model for real-time inference
238239
239-
In this section you learn how to deploy a model so that an application can consume (inference) the model over REST.
240+
In this section, learn how to deploy a model so that an application can consume (inference) the model over REST.
240241
241242
### Create deployment configuration
242243
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.
244+
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.
244245
245246
246247
```python
@@ -252,8 +253,7 @@ from azureml.core.webservice import AciWebservice
252253
# get a curated environment
253254
env = Environment.get(
254255
workspace=ws,
255-
name="AzureML-sklearn-0.24.1-ubuntu18.04-py37-cpu-inference",
256-
version=1
256+
name="AzureML-sklearn-1.0"
257257
)
258258
env.inferencing_stack_version='latest'
259259
@@ -271,7 +271,7 @@ aciconfig = AciWebservice.deploy_configuration(
271271
This next code cell deploys the model to Azure Container Instance.
272272
273273
> [!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.**
275275
276276
277277
```python
@@ -300,14 +300,14 @@ service = Model.deploy(
300300
service.wait_for_deployment(show_output=True)
301301
```
302302
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:
304304
305305
1. An `init` function that executes once when the service starts - in this function you normally get the model from the registry and set global variables
306306
1. A `run(data)` function that 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.
307307
308308
### View endpoint
309309
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).
311311
312312
## Test the model service
313313
@@ -340,7 +340,9 @@ If you're not going to continue to use this model, delete the Model service usin
340340
service.delete()
341341
```
342342
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.
344+
345+
<!-- nbend -->
344346
345347
### Delete everything
346348
@@ -349,7 +351,7 @@ Use these steps to delete your Azure Machine Learning workspace and all compute
349351
[!INCLUDE [aml-delete-resource-group](../includes/aml-delete-resource-group.md)]
350352
351353
352-
## Next steps
354+
## Related resources
353355
354356
+ Learn about all of the [deployment options for Azure Machine Learning](../how-to-deploy-online-endpoints.md).
355357
+ Learn how to [authenticate to the deployed model](../how-to-authenticate-online-endpoint.md).

0 commit comments

Comments
 (0)