Skip to Content

Use the Regression Model Template to Train a Machine Learning Model

Train a machine learning model for the Data Attribute Recommendation service, using the regression model template.
You will learn
  • How to train a machine learning model using the regression model template
  • How to deploy a machine learning model to use it to predict data records
Juliana-MoraisJuliana MoraisJune 29, 2022
Created by
Juliana-Morais
May 16, 2022
Contributors
Juliana-Morais
  • Step 1

    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 or Use Trial to Set Up Account for Data Attribute Recommendation and Get Service 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.

    Service Key

    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.

    After finishing this tutorial, keep the Swagger UI for mm open to perform the clean up tasks in Use the Regression Model Template to Predict Data Records.

    1. To be able to use the Swagger UI endpoints, you need to authorize yourself. In the top right corner, click Authorize.

      Authorize
    2. Get the access_token value created in the previous tutorial: Get OAuth Access Token for Data Attribute Recommendation Using Any Web Browser, then add Bearer (with capitalized “B”) in front of it, and enter in the Value field.

      Bearer <access_token>
      
    3. Click Authorize and then click Close.

      Authorize
    Log in to complete tutorial
  • Step 2

    To train a machine learning model using the data that you uploaded in Use a Regression Dataset Schema to Upload Training Data to Data Attribute Recommendation, 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.

    The regression 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.

    To create the training job, proceed as follows:

    1. Expand the endpoint POST /jobs by clicking on it. Then click Try it out.

      Training Job Endpoint
    2. In the text area, replace the parameter value for datasetId with the ID of your dataset that you have created in Use a Regression Dataset Schema to Upload Training Data to Data Attribute Recommendation. Replace the parameter value for modelTemplateId with bdbcd699-4419-40a5-abb8-e7ad43dde49b. Finally, replace the parameter value modelName with your model name, regression_tutorial_model, for example. Delete the businessBlueprintId line from the Request body. Click Execute to create the training job.

      Training Job Execute
    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.

      Training Job Response

    You have successfully created a training job.

    Log in to complete tutorial
  • Step 3

    To know when your training job has ended, you have to frequently check its status. For that, proceed as follows:

    1. Expand the endpoint GET /jobs/{jobId} by clicking on it. Then click Try it out.

      Training Job Status Endpoint
    2. Fill the parameter jobId with ID of your training job that you copied in the previous step. Click Execute.

      Training Job Status Execute
    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.

      Training Job Status Response

    You have successfully created a machine learning model.

    Choose the correct status of your training job to continue with the deployment of the machine learning model.

    Log in to complete tutorial
  • Step 4

    To use the trained model, you need to deploy it. Once deployed, the model is ready to predict data records. To deploy your model, proceed as follows:

    1. Expand the endpoint POST /deployments by clicking on it. Then click Try it out.

      Deployment Endpoint
    2. In the text area, replace the parameter modelName with the name of your model (regression_tutorial_model). Click Execute to deploy the model.

      Deployment Execute
    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.

      Deployment Response
    Log in to complete tutorial
  • Step 5

    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:

    1. Expand the endpoint GET /deployments/{id} by clicking on it. Then click Try it out.

      Deployment Status Endpoint
    2. Fill the parameter deploymentId with the ID of your deployment that you copied in the previous step. Click Execute.

      Deployment Status Execute
    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.

      Deployment Status Execute

    You have successfully trained a machine learning model and deployed it. Next, you can use your model to make predictions.

    Log in to complete tutorial
Back to top