|
| 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 | +! |
| 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 | + ! |
| 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 | + ! |
| 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 | + ! |
| 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 | + ! |
| 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 | +! |
| 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 | + ! |
| 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 | + ! |
| 149 | + |
| 150 | +If the response code is `204`, the model has been successfully undeployed. |
| 151 | + |
| 152 | +! |
| 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 | + ! |
| 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 | + ! |
| 171 | + |
| 172 | +If the response code is `204`, the model has been successfully deleted. |
| 173 | + |
| 174 | +! |
| 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 | + ! |
| 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 | + ! |
| 191 | + |
| 192 | +If the response code is `204`, the training job has been successfully deleted. |
| 193 | + |
| 194 | +! |
| 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 | + ! |
| 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 | + ! |
| 211 | + |
| 212 | +If the response code is `204`, the dataset has been successfully deleted. |
| 213 | + |
| 214 | +! |
| 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 | + ! |
| 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 | + ! |
| 231 | + |
| 232 | +If the response code is `204`, the dataset schema has been successfully deleted. |
| 233 | + |
| 234 | +! |
| 235 | + |
| 236 | +Congratulations, you have completed this tutorial. |
| 237 | + |
| 238 | +[DONE] |
| 239 | +[ACCORDION-END] |
0 commit comments