Skip to content

Commit d03be3a

Browse files
committed
Revert "Deleted files per Juliana Morais on 5/18/2022"
This reverts commit 2030772.
1 parent 6f277df commit d03be3a

File tree

138 files changed

+100182
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+100182
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
title: Use the AutoML Model Template to Train a Machine Learning Model
3+
description: Train a machine learning model for the Data Attribute Recommendation service, using the AutoML model template.
4+
auto_validation: true
5+
time: 15
6+
tags: [tutorial>beginner, topic>machine-learning, topic>artificial-intelligence, topic>cloud, software-product>sap-business-technology-platform, software-product>sap-ai-business-services, software-product>data-attribute-recommendation, tutorial>free-tier]
7+
primary_tag: topic>machine-learning
8+
author_name: Juliana Morais
9+
author_profile: https://github.com/Juliana-Morais
10+
---
11+
12+
## Details
13+
### You will learn
14+
- How to train a machine learning model using the AutoML model template
15+
- How to deploy a machine learning model to use it for predictions and classifications
16+
17+
---
18+
19+
[ACCORDION-BEGIN [Step 1: ](Authorize Swagger UI)]
20+
21+
In the service key you created for Data Attribute Recommendation in the previous tutorial: [Use Free Tier to Set Up Account for Data Attribute Recommendation and Get Service Key](cp-aibus-dar-booster-free-key) or [Use Trial to Set Up Account for Data Attribute Recommendation and Get Service Key](cp-aibus-dar-booster-key), you find a section called `swagger` (as highlighted in the image below) with three entries, called `dm` (data manager), `inference` and `mm` (model manager).
22+
23+
!![Service Key](png-files/service-key-details.png)
24+
25+
For this tutorial, copy the URL of the Swagger UI for `mm` and open it in a browser tab. The Swagger UI for the model manager allows you to train a machine learning model, to delete it, to deploy the model as well as to undeploy the model.
26+
27+
>After finishing this tutorial, keep the Swagger UI for `mm` open to perform the clean up tasks in [Use the AutoML Model Template to Classify Records](cp-aibus-dar-swagger-automl-predict).
28+
29+
1. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top right corner, click **Authorize**.
30+
31+
!![Authorize](png-files/swagger-authorize.png)
32+
33+
2. Get the `access_token` value created in the previous tutorial: [Get OAuth Access Token for Data Attribute Recommendation Using Any Web Browser](cp-aibus-dar-web-oauth-token), then add **Bearer** (with capitalized "B") in front of it, and enter in the **Value** field.
34+
35+
```
36+
Bearer <access_token>
37+
```
38+
39+
3. Click **Authorize** and then click **Close**.
40+
41+
!![Authorize](png-files/swagger-token.png)
42+
43+
[DONE]
44+
[ACCORDION-END]
45+
46+
47+
[ACCORDION-BEGIN [Step 2: ](Create a training job)]
48+
49+
To train a machine learning model using the data that you uploaded in [Use an AutoML Dataset Schema to Upload Training Data to Data Attribute Recommendation](cp-aibus-dar-swagger-automl-upload), you create a training job. With each training job you provide a model template which combines data processing rules and machine learning model architecture. You can find the list of available model templates [here](https://help.sap.com/docs/Data_Attribute_Recommendation/105bcfd88921418e8c29b24a7a402ec3/1e76e8c636974a06967552c05d40e066.html).
50+
51+
The AutoML model template that you use in this tutorial is suited for datasets with single labels, meaning that the machine learning model only predicts a single field.
52+
53+
To create the training job, proceed as follows:
54+
55+
1. Expand the endpoint **POST /jobs** by clicking on it. Then click **Try it out**.
56+
57+
!![Training Job Endpoint](png-files/job-endpoint.png)
58+
59+
2. In the text area, replace the parameter value for `datasetId` with the ID of your dataset that you have created in [Use an AutoML Dataset Schema to Upload Training Data to Data Attribute Recommendation](cp-aibus-dar-swagger-automl-upload). Replace the parameter value for `modelTemplateId` with `188df8b2-795a-48c1-8297-37f37b25ea00`. Finally, replace the parameter value `modelName` with your model name, `automl_tutorial_model`, for example. Delete the `businessBlueprintId` line from the **Request body**. Click **Execute** to create the training job.
60+
61+
!![Training Job Execute](png-files/job-execute.png)
62+
63+
3. In the response of the service, you find the `id` of your training job. Copy the ID again as you need it in the next step. Along side the ID, you find the training job's current status. Initially, the status is `PENDING` which says that the training job is in queue but has not started yet.
64+
65+
!![Training Job Response](png-files/job-response.png)
66+
67+
You have successfully created a training job.
68+
69+
[DONE]
70+
[ACCORDION-END]
71+
72+
73+
[ACCORDION-BEGIN [Step 3: ](Check training job status)]
74+
75+
To know when your training job has ended, you have to frequently check its status. For that, proceed as follows:
76+
77+
1. Expand the endpoint `GET /jobs/{jobId}` by clicking on it. Then click **Try it out**.
78+
79+
!![Training Job Status Endpoint](png-files/job-status-endpoint.png)
80+
81+
2. Fill the parameter `jobId` with ID of your training job that you copied in the previous step. Click **Execute**.
82+
83+
!![Training Job Status Execute](png-files/job-status-execute.png)
84+
85+
3. In the response, you find again the current status of your training job along with other details. Immediately after creation of the training job, the status is `PENDING`. Shortly after, it changes to `RUNNING` which means that the model is being trained. The training of the sample data usually takes about 5 minutes to complete but may run longer, up to a few hours due to limited availability of resources in the production or trial environments. You can check the status every now and then. Once training is finished, the status changes to `SUCCEEDED` which means the service has created a machine learning model and you can proceed.
86+
87+
!![Training Job Status Response](png-files/job-status-response.png)
88+
89+
You have successfully created a machine learning model.
90+
91+
[DONE]
92+
[ACCORDION-END]
93+
94+
95+
[ACCORDION-BEGIN [Step 4: ](Deploy machine learning model)]
96+
97+
To use the trained model, you need to deploy it. Once deployed, the model is ready to classify records. To deploy your model, proceed as follows:
98+
99+
1. Expand the endpoint `POST /deployments` by clicking on it. Then click **Try it out**.
100+
101+
!![Deployment Endpoint](png-files/deploy-endpoint.png)
102+
103+
2. In the text area, replace the parameter `modelName` with the name of your model (`automl_tutorial_model`). Click **Execute** to deploy the model.
104+
105+
!![Deployment Execute](png-files/deploy-execute.png)
106+
107+
3. In the response of the service, you find the `id` of the deployment and its status. Initially, the status is `PENDING`, indicating the deployment is in progress. Make sure to copy the ID as you need it in the next step.
108+
109+
!![Deployment Response](png-files/deploy-response.png)
110+
111+
[DONE]
112+
[ACCORDION-END]
113+
114+
115+
[ACCORDION-BEGIN [Step 5: ](Check deployment status)]
116+
117+
Finally, you have to ensure that your model is deployed successfully in order to use it for predictions. To check the status of your deployment, proceed as follows:
118+
119+
1. Expand the endpoint `GET /deployments/{id}` by clicking on it. Then click **Try it out**.
120+
121+
!![Deployment Status Endpoint](png-files/deploy-status-endpoint.png)
122+
123+
2. Fill the parameter `deploymentId` with the ID of your deployment that you copied in the previous step. Click **Execute**.
124+
125+
!![Deployment Status Execute](png-files/deploy-status-execute.png)
126+
127+
3. In the response of the service, you find the current status of the deployment. If the status is `SUCCEEDED`, your deployment is done. If the status is still `PENDING`, check back in a few minutes.
128+
129+
!![Deployment Status Execute](png-files/deploy-status-response.png)
130+
131+
You have successfully trained a machine learning model and deployed it. Next, you can use your model to make predictions.
132+
133+
[VALIDATE_1]
134+
[ACCORDION-END]
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
title: Use the AutoML Model Template to Classify Records
3+
description: Classify product data records into product categories using your machine learning model.
4+
auto_validation: true
5+
time: 20
6+
tags: [tutorial>beginner, topic>machine-learning, topic>artificial-intelligence, topic>cloud, software-product>sap-business-technology-platform, software-product>sap-ai-business-services, software-product>data-attribute-recommendation, tutorial>free-tier]
7+
primary_tag: topic>machine-learning
8+
author_name: Juliana Morais
9+
author_profile: https://github.com/Juliana-Morais
10+
---
11+
12+
13+
## Details
14+
### You will learn
15+
- How to classify records using your machine learning model
16+
17+
---
18+
19+
[ACCORDION-BEGIN [Step 1: ](Authorize Swagger UI)]
20+
21+
In the service key you created for Data Attribute Recommendation in the previous tutorial: [Use Free Tier to Set Up Account for Data Attribute Recommendation and Get Service Key](cp-aibus-dar-booster-free-key) or [Use Trial to Set Up Account for Data Attribute Recommendation and Get Service Key](cp-aibus-dar-booster-key), you find a section called `swagger` (as highlighted in the image below) with three entries, called `dm` (data manager), `inference` and `mm` (model manager).
22+
23+
!![Service Key](png-files/service-key-details.png)
24+
25+
For this tutorial, copy the URL of the Swagger UI for `inference` and open it in a browser tab. The Swagger UI for inference allows you to classify new data using your machine learning model that you have created in the previous tutorial: [Use the AutoML Model Template to Train a Machine Learning Model](cp-aibus-dar-swagger-automl-model).
26+
27+
1. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top right corner, click **Authorize**.
28+
29+
!![Authorize](png-files/swagger-authorize.png)
30+
31+
2. Get the `access_token` value created in the previous tutorial: [Get OAuth Access Token for Data Attribute Recommendation Using Any Web Browser](cp-aibus-dar-web-oauth-token), then add **Bearer** (with capitalized "B") in front of it, and enter in the **Value** field.
32+
33+
```
34+
Bearer <access_token>
35+
```
36+
37+
3. Click **Authorize** and then click **Close**.
38+
39+
!![Authorize](png-files/swagger-token.png)
40+
41+
[DONE]
42+
[ACCORDION-END]
43+
44+
45+
[ACCORDION-BEGIN [Step 2: ](Classify records)]
46+
47+
To classify records, proceed as follows:
48+
49+
1. Expand the endpoint `POST /models/{modelName}/versions/1` by clicking on it. Then click **Try it out**.
50+
51+
!![Inference Endpoint](png-files/inference-endpoint.png)
52+
53+
2. Fill the parameter `modelName` with the name of your machine learning model.
54+
55+
3. In the parameter `body`, you have to provide the data that needs to be classified. According to the dataset schema that you have created in [Use the AutoML Model Template to Upload Data to Data Attribute Recommendation with Swagger UI](cp-aibus-dar-swagger-automl-upload), the machine learning model takes the manufacturer, description and price of the product as input and predicts the product category. Replace the text in the parameter `body` with the following:
56+
57+
```JSON
58+
{
59+
"topN":1,
60+
"objects":[
61+
{
62+
"objectId":"optional-identifier-1",
63+
"features":[
64+
{"name":"manufacturer", "value":"Energizer"},
65+
{"name":"description", "value":"Alkaline batteries; 1.5V"},
66+
{"name":"price", "value":"5.99"}
67+
]
68+
},
69+
{
70+
"objectId":"optional-identifier-2",
71+
"features":[
72+
{"name":"manufacturer","value":"Eidos"},
73+
{
74+
"name":"description",
75+
"value":"Unravel a grim conspiracy at the brink of Revolution"
76+
},
77+
{"name":"price","value":"19.99"}
78+
]
79+
}
80+
]
81+
}
82+
```
83+
84+
4. Click **Execute** to send the above input for classification to the service.
85+
86+
!![Inference Execute](png-files/inference-execute.png)
87+
88+
In the response of the service, you find the values that the model predicted. The probability represents how certain the model is about its prediction. The higher the probability the more confident the model is that the prediction is actually correct. If the probability is close to 1, the model is very certain.
89+
90+
!![Inference Execute](png-files/inference-response.png)
91+
92+
```JSON
93+
{
94+
"id": "8caba3f2-f2af-4bb6-7f4c-079b9f87caee",
95+
"predictions": [
96+
{
97+
"labels": [
98+
{
99+
"name": "F3_readable",
100+
"results": [
101+
{
102+
"probability": 1,
103+
"value": "Household Batteries"
104+
}
105+
]
106+
}
107+
],
108+
"objectId": "optional-identifier-1"
109+
},
110+
{
111+
"labels": [
112+
{
113+
"name": "F3_readable",
114+
"results": [
115+
{
116+
"probability": 1,
117+
"value": "Sheet Music"
118+
}
119+
]
120+
}
121+
],
122+
"objectId": "optional-identifier-2"
123+
}
124+
],
125+
"processedTime": "2022-05-16T09:51:36.321470",
126+
"status": "DONE"
127+
}
128+
```
129+
130+
You have successfully classified products into product categories. Feel free to adapt the examples above and retry the classification.
131+
132+
[VALIDATE_1]
133+
[ACCORDION-END]
134+
135+
136+
[ACCORDION-BEGIN [Step 3: ](Undeploy your model)]
137+
138+
Now that you have learned the whole process about how to use the Regression Model Template from the Data Attribute Recommendation service, it's time to clean up. This way, the technical limits won't get in your way when trying out other Data Attribute Recommendation tutorials. See [Technical Constraints](https://help.sap.com/docs/Data_Attribute_Recommendation/105bcfd88921418e8c29b24a7a402ec3/686d2ae094014c8085cebecdb1d37e37.html) and [Free Service Plan and Trial Account Technical Constraints](https://help.sap.com/docs/Data_Attribute_Recommendation/105bcfd88921418e8c29b24a7a402ec3/c03b561eea1744c9b9892b416037b99a.html).
139+
140+
First, undeploy your model. For that, go back to the Swagger UI for `mm` and:
141+
142+
1. Expand the endpoint `DELETE /deployments/{deploymentId}` by clicking on it. Then click **Try it out**.
143+
144+
!![Inference Endpoint](png-files/deploy-endpoint.png)
145+
146+
2. Fill the parameter `deploymentId` with the ID of your deployment. Use the `GET /deployments` endpoint in case you no longer have the deployment `id` in hand.
147+
148+
!![Inference Endpoint](png-files/deploy-execute.png)
149+
150+
If the response code is `204`, the model has been successfully undeployed.
151+
152+
!![Inference Endpoint](png-files/deploy-response.png)
153+
154+
You have successfully undeployed your model, but the model is not yet deleted. Instead it isn't in production which means that you cannot make inference requests. You can deploy it again at any time using the `POST /deployments` endpoint.
155+
156+
[DONE]
157+
[ACCORDION-END]
158+
159+
160+
[ACCORDION-BEGIN [Step 4: ](Delete your model)]
161+
162+
Once undeployed, you can delete your model.
163+
164+
1. Expand the endpoint `DELETE /models/{modelName}` by clicking on it. Then click **Try it out**.
165+
166+
!![Inference Endpoint](png-files/model-endpoint.png)
167+
168+
2. Fill the parameter `modelName` with the name of your machine learning model (`ior_tutorial_model`). Use the `GET /models` endpoint in case you no longer have the model `name` in hand.
169+
170+
!![Inference Endpoint](png-files/model-execute.png)
171+
172+
If the response code is `204`, the model has been successfully deleted.
173+
174+
!![Inference Endpoint](png-files/model-response.png)
175+
176+
[DONE]
177+
[ACCORDION-END]
178+
179+
180+
[ACCORDION-BEGIN [Step 5: ](Delete your training job)]
181+
182+
Now that the model is deleted, you can delete the training job that created the model.
183+
184+
1. Expand the endpoint `DELETE /jobs/{jobId}` by clicking on it. Then click **Try it out**.
185+
186+
!![Inference Endpoint](png-files/job-endpoint.png)
187+
188+
2. Fill the parameter `jobId` with the ID of your training job. Use the `GET /jobs` endpoint in case you no longer have the job `id` in hand.
189+
190+
!![Inference Endpoint](png-files/job-execute.png)
191+
192+
If the response code is `204`, the training job has been successfully deleted.
193+
194+
!![Inference Endpoint](png-files/job-response.png)
195+
196+
[DONE]
197+
[ACCORDION-END]
198+
199+
200+
[ACCORDION-BEGIN [Step 6: ](Delete your dataset)]
201+
202+
To clear the uploaded data, you can now delete the dataset as the associated training job is already deleted. For that, go back to the Swagger UI for `dm` and:
203+
204+
1. Expand the endpoint `DELETE /datasets/{id}` by clicking on it. Then click **Try it out**.
205+
206+
!![Inference Endpoint](png-files/data-endpoint.png)
207+
208+
2. Fill the parameter `id` with the ID of your dataset. Use the `GET /datasets` endpoint in case you no longer have the dataset `id` in hand.
209+
210+
!![Inference Endpoint](png-files/data-execute.png)
211+
212+
If the response code is `204`, the dataset has been successfully deleted.
213+
214+
!![Inference Endpoint](png-files/data-response.png)
215+
216+
[DONE]
217+
[ACCORDION-END]
218+
219+
220+
[ACCORDION-BEGIN [Step 7: ](Delete your dataset schema)]
221+
222+
If you do not need your dataset schema anymore, you can delete it as well.
223+
224+
1. Expand the endpoint `DELETE /datasetSchemas/{id}` by clicking on it. Then click **Try it out**.
225+
226+
!![Inference Endpoint](png-files/schema-endpoint.png)
227+
228+
2. Fill the parameter `id` with the ID of your dataset schema. Use the `GET /datasetSchemas` endpoint in case you no longer have the dataset schema `id` in hand.
229+
230+
!![Inference Endpoint](png-files/schema-execute.png)
231+
232+
If the response code is `204`, the dataset schema has been successfully deleted.
233+
234+
!![Inference Endpoint](png-files/schema-response.png)
235+
236+
Congratulations, you have completed this tutorial.
237+
238+
[DONE]
239+
[ACCORDION-END]
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)