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
description: 'Learn how to train your machine learning model with R for use in Azure Machine Learning.'
5
5
ms.service: machine-learning
6
6
ms.subservice: core
7
-
ms.date: 01/12/2023
7
+
ms.date: 03/22/2024
8
8
ms.topic: how-to
9
9
author: wahalulu
10
10
ms.author: mavaisma
@@ -24,8 +24,8 @@ This article explains how to take the R script that you [adapted to run in produ
24
24
## Prerequisites
25
25
26
26
- An [Azure Machine Learning workspace](quickstart-create-resources.md).
27
-
-[A registered data asset](how-to-create-data-assets.md) that your training job will use.
28
-
- Azure [CLI and ml extension installed](how-to-configure-cli.md). Or use a [compute instance in your workspace](quickstart-create-resources.md), which has the CLI preinstalled.
27
+
-[A registered data asset](how-to-create-data-assets.md) that your training job uses.
28
+
- Azure [CLI and ml extension installed](how-to-configure-cli.md). Or use a [compute instance in your workspace](quickstart-create-resources.md), which has the CLI preinstalled.
29
29
-[A compute cluster](how-to-create-attach-compute-cluster.md) or [compute instance](quickstart-create-resources.md#create-a-compute-instance) to run your training job.
30
30
-[An R environment](how-to-r-modify-script-for-production.md#create-an-environment) for the compute cluster to use to run the job.
31
31
@@ -44,18 +44,17 @@ Create this folder structure for your project:
44
44
> [!IMPORTANT]
45
45
> All source code goes in the `src` directory.
46
46
47
-
* The **r-source.R** file is the R script that you adapted to run in production
48
-
* The **azureml_utils.R** file is necessary. The source code is shown [here](how-to-r-modify-script-for-production.md#source-the-azureml_utilsr-helper-script)
49
-
47
+
* The **r-source.R** file is the R script that you adapted to run in production. Make sure you follow the steps to [crate and log your model](how-to-r-modify-script-for-production.md#crate-your-models-with-the-carrier-package) in this script.
48
+
* The **azureml_utils.R** file is necessary. Use [this source code](how-to-r-modify-script-for-production.md#source-the-azureml_utilsr-helper-script) for the contents of the file.
50
49
51
50
52
51
## Prepare the job YAML
53
52
54
-
Azure Machine Learning CLI v2 has different [different YAML schemas](reference-yaml-overview.md) for different operations. You'll use the [job YAML schema](reference-yaml-job-command.md) to submit a job. This is the **job.yml** file that is a part of this project.
53
+
Azure Machine Learning CLI v2 has different [different YAML schemas](reference-yaml-overview.md) for different operations. You use the [job YAML schema](reference-yaml-job-command.md) to submit a job in the **job.yml** file that is a part of this project.
55
54
56
-
You'll need to gather specific pieces of information to put into the YAML:
55
+
You need to gather specific pieces of information to put into the YAML:
57
56
58
-
- The name of the registered data asset you'll use as the data input (with version): `azureml:<REGISTERED-DATA-ASSET>:<VERSION>`
57
+
- The name of the registered data asset you use as the data input (with version): `azureml:<REGISTERED-DATA-ASSET>:<VERSION>`
59
58
- The name of the environment you created (with version): `azureml:<R-ENVIRONMENT-NAME>:<VERSION>`
60
59
- The name of the compute cluster: `azureml:<COMPUTE-CLUSTER-NAME>`
61
60
@@ -66,7 +65,7 @@ You'll need to gather specific pieces of information to put into the YAML:
66
65
67
66
### Sample YAML schema to submit a job
68
67
69
-
Edit your **job.yml** file to contain the following. Make sure to replace values shown `<IN-BRACKETS-AND-CAPS>` and remove the brackets.
68
+
Edit your **job.yml** file to contain the following. Make sure to replace values shown `<IN-BRACKETS-AND-CAPS>` and remove the brackets.
@@ -102,7 +101,7 @@ Find these values from [Azure Machine Learning studio](https://ml.azure.com):
102
101
103
102
1. Sign in and open your workspace.
104
103
1. In the upper right Azure Machine Learning studio toolbar, select your workspace name.
105
-
1. You can copy the values from the section that appears.
104
+
1. You can copy the values from the section that appears.
106
105
107
106
:::image type="content" source="media/how-to-r-train-model/find-values.png" alt-text="Screenshot: Find the values to use in your CLI command." lightbox="media/how-to-r-train-model/find-values.png":::
108
107
@@ -114,7 +113,7 @@ To submit the job, run the following commands in a terminal window:
114
113
cd r-job-azureml
115
114
```
116
115
117
-
1. Sign in to Azure. If you're doing this from an [Azure Machine Learning compute instance](quickstart-create-resources.md#create-a-compute-instance), use:
116
+
1. Sign in to Azure. If you're doing this from an [Azure Machine Learning compute instance](quickstart-create-resources.md#create-a-compute-instance), use:
118
117
119
118
```azurecli
120
119
az login --identity
@@ -128,13 +127,13 @@ To submit the job, run the following commands in a terminal window:
128
127
az upgrade
129
128
```
130
129
131
-
1. If you have multiple Azure subscriptions, set the active subscription to the one you're using for your workspace. (You can skip this step if you only have access to a single subscription.) Replace `<SUBSCRIPTION-NAME>` with your subscription name. Also remove the brackets `<>`.
130
+
1. If you have multiple Azure subscriptions, set the active subscription to the one you're using for your workspace. (You can skip this step if you only have access to a single subscription.) Replace `<SUBSCRIPTION-NAME>` with your subscription name. Also remove the brackets `<>`.
132
131
133
132
```azurecli
134
133
az account set --subscription "<SUBSCRIPTION-NAME>"
135
134
```
136
135
137
-
1. Now use CLI to submit the job. If you're doing this on a compute instance in your workspace, you can use environment variables for the workspace name and resource group as show in the following code. If you aren't on a compute instance, replace these values with your workspace name and resource group.
136
+
1. Now use CLI to submit the job. If you're doing this on a compute instance in your workspace, you can use environment variables for the workspace name and resource group as show in the following code. If you aren't on a compute instance, replace these values with your workspace name and resource group.
138
137
139
138
```azurecli
140
139
az ml job create -f job.yml --workspace-name $CI_WORKSPACE --resource-group $CI_RESOURCE_GROUP
@@ -146,28 +145,28 @@ Once you've submitted the job, you can check the status and results in studio:
146
145
1. Select your workspace if it isn't already loaded.
147
146
1. On the left navigation, select **Jobs**.
148
147
1. Select the **Experiment name** that you used to train your model.
149
-
1. Select the **Display name** of the job to view details and artifacts of the job, including metrics, images, child jobs, outputs, logs, and code used in the job.
148
+
1. Select the **Display name** of the job to view details and artifacts of the job, including metrics, images, child jobs, outputs, logs, and code used in the job.
150
149
151
150
152
151
## Register model
153
152
154
-
Finally, once the training job is complete, register your model if you want to deploy it. Start in the studio from the page showing your job details.
153
+
Finally, once the training job is complete, register your model if you want to deploy it. Start in the studio from the page showing your job details.
155
154
156
155
1. Once your job completes, select **Outputs + logs** to view outputs of the job.
157
-
1. Open the **models** folder to verify that **crate.bin** and **MLmodel** are present. If not, check the logs to see if there was an error.
156
+
1. Open the **models** folder to verify that **crate.bin** and **MLmodel** are present. If not, check the logs to see if there was an error.
158
157
1. On the toolbar at the top, select **+ Register model**.
159
158
160
159
:::image type="content" source="media/how-to-r-train-model/register-model.png" alt-text="Screenshot shows the Job section of studio with the Outputs section open.":::
161
160
162
-
1. For **Model type**, change the default from **MLflow** to **Unspecified type**.
161
+
1. Don't use the **MLflow** model type, even though it's detected. Change **Model type** from the default **MLflow** to **Unspecified type**. Leaving it as **MLflow** will cause an error.
163
162
1. For **Job output**, select **models**, the folder that contains the model.
164
163
1. Select **Next**.
165
-
1. Supply the name you wish to use for your model. Add **Description**, **Version**, and **Tags** if you wish.
164
+
1. Supply the name you wish to use for your model. Add **Description**, **Version**, and **Tags** if you wish.
166
165
1. Select **Next**.
167
166
1. Review the information.
168
167
1. Select **Register**.
169
168
170
-
At the top of the page, you'll see a confirmation that the model is registered. The confirmation looks similar to this:
169
+
At the top of the page, you'll see a confirmation that the model is registered. The confirmation looks similar to this:
171
170
172
171
:::image type="content" source="media/how-to-r-train-model/registered.png" alt-text="Screenshot shows example of successful registration.":::
0 commit comments