|
| 1 | +--- |
| 2 | +parser: v2 |
| 3 | +auto_validation: true |
| 4 | +time: 15 |
| 5 | +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] |
| 6 | +primary_tag: topic>machine-learning |
| 7 | +author_name: Juliana Morais |
| 8 | +author_profile: https://github.com/Juliana-Morais |
| 9 | +--- |
| 10 | + |
| 11 | +# Use the Sales Order Completion (SOC) Business Blueprint to Train a Machine Learning Model |
| 12 | +<!-- description --> Train a machine learning model for the Data Attribute Recommendation service, using the Sales Order Completion (SOC) business blueprint. |
| 13 | + |
| 14 | +## You will learn |
| 15 | + - How to train a machine learning model using the Sales Order Completion (SOC) business blueprint |
| 16 | + - How to deploy a machine learning model to get predictions for missing fields in sales order documents |
| 17 | + |
| 18 | +--- |
| 19 | + |
| 20 | +### Authorize Swagger UI |
| 21 | + |
| 22 | + |
| 23 | +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), `mm` (model manager) and `inference`. |
| 24 | + |
| 25 | +<!-- border --> |
| 26 | + |
| 27 | +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. |
| 28 | + |
| 29 | +>After finishing this tutorial, keep the Swagger UI for `mm` open to perform the clean up tasks in [Use the Sales Order Completion (SOC) Business Blueprint to Predict Missing Sales Order Fields](cp-aibus-dar-swagger-soc-predict). |
| 30 | +
|
| 31 | +1. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top right corner, click **Authorize**. |
| 32 | + |
| 33 | + <!-- border --> |
| 34 | + |
| 35 | +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. |
| 36 | + |
| 37 | + ``` |
| 38 | + Bearer <access_token> |
| 39 | + ``` |
| 40 | +
|
| 41 | +3. Click **Authorize** and then click **Close**. |
| 42 | +
|
| 43 | + <!-- border --> |
| 44 | +
|
| 45 | +
|
| 46 | +
|
| 47 | +### Create a training job |
| 48 | +
|
| 49 | +
|
| 50 | +To train a machine learning model using the data that you uploaded in [Use a Sales Order Completion (SOC) Dataset Schema to Upload Training Data to Data Attribute Recommendation](cp-aibus-dar-swagger-soc-upload), you create a training job. |
| 51 | +
|
| 52 | +With each training job you provide a model template or a business blueprint 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), and the list of available business blueprints [here](https://help.sap.com/docs/Data_Attribute_Recommendation/105bcfd88921418e8c29b24a7a402ec3/091eace025e14793be0e83ef2109b349.html). |
| 53 | +
|
| 54 | +The Sales Order Completion (SOC) business blueprint that you use in this tutorial is suited to predict missing sales order fields that are needed for completion. |
| 55 | +
|
| 56 | +To create the training job, proceed as follows: |
| 57 | +
|
| 58 | +1. Expand the endpoint **POST /jobs** by clicking on it. Then click **Try it out**. |
| 59 | +
|
| 60 | + <!-- border --> |
| 61 | +
|
| 62 | +2. In the text area, replace the parameter value for `datasetId` with the `id` of your dataset that you have created in [Use a Sales Order Completion (SOC) Dataset Schema to Upload Training Data to Data Attribute Recommendation](cp-aibus-dar-swagger-soc-upload). Delete the `modelTemplateId` line from the **Request body**. Replace the parameter value `modelName` with your model name, `soc_tutorial_model`, for example. Make sure the parameter value for `businessBlueprintId` is `9d15125d-2b7b-4136-8872-1ddd337cf36f`, which is the ID of the SOC business blueprint. Click **Execute** to create the training job. |
| 63 | +
|
| 64 | + <!-- border --> |
| 65 | +
|
| 66 | +3. In the response of the service, you find the `id` of your training job. Copy the `id` as you'll 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. |
| 67 | +
|
| 68 | + <!-- border --> |
| 69 | +
|
| 70 | +You have successfully created a training job. |
| 71 | +
|
| 72 | +
|
| 73 | +
|
| 74 | +### Check training job status |
| 75 | +
|
| 76 | +
|
| 77 | +To know when your training job has ended, you have to frequently check its status. For that, proceed as follows: |
| 78 | +
|
| 79 | +1. Expand the endpoint `GET /jobs/{jobId}` by clicking on it. Then click **Try it out**. |
| 80 | +
|
| 81 | + <!-- border --> |
| 82 | +
|
| 83 | +2. Fill the parameter `jobId` with `id` of your training job that you copied in the previous step. Click **Execute**. |
| 84 | +
|
| 85 | + <!-- border --> |
| 86 | +
|
| 87 | +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 free tier environment. 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. |
| 88 | +
|
| 89 | + <!-- border --> |
| 90 | +
|
| 91 | +You have successfully trained a machine learning model. |
| 92 | +
|
| 93 | +
|
| 94 | +
|
| 95 | +### Deploy machine learning model |
| 96 | +
|
| 97 | +
|
| 98 | +To use the trained model, you need to deploy it. Once deployed, the model is ready to make predictions. To deploy your model, proceed as follows: |
| 99 | +
|
| 100 | +1. Expand the endpoint `POST /deployments` by clicking on it. Then click **Try it out**. |
| 101 | +
|
| 102 | + <!-- border --> |
| 103 | +
|
| 104 | +2. In the text area, replace the parameter `modelName` with the name of your model (`soc_tutorial_model`). Click **Execute** to deploy the model. |
| 105 | +
|
| 106 | + <!-- border --> |
| 107 | +
|
| 108 | +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. |
| 109 | +
|
| 110 | + <!-- border --> |
| 111 | +
|
| 112 | +
|
| 113 | +
|
| 114 | +### Check deployment status |
| 115 | +
|
| 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 | + <!-- border --> |
| 122 | +
|
| 123 | +2. Fill the parameter `deploymentId` with the `id` of your deployment that you copied in the previous step. Click **Execute**. |
| 124 | +
|
| 125 | + <!-- border --> |
| 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 | + <!-- border --> |
| 130 | +
|
| 131 | +You have successfully trained a machine learning model and deployed it. Next, you'll use your model to make predictions. |
0 commit comments