Start tracking your progress
Trailhead Home
Trailhead Home

Use the Model to Make a Prediction

Learning Objectives

After completing this unit, you’ll be able to:
  • Use the Einstein Intent API to categorize text using the model you created.
  • Explain the prediction results returned from the API.

Try Out Your Model

Now for the moment of truth. You created the dataset, trained the dataset to create a model, and at last you’re ready to test it out. You test the model by sending some text into the model and getting a response back.
  1. In the following cURL command, replace <TOKEN> with your token and <MODEL_ID> with the model ID. Then run the command in the command line window.
    Tip

    Tip

    Be sure that the dataset training is complete and the model is ready to use. The training process must be complete before you can use the model to make a prediction.

    curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "modelId=<MODEL_ID>" -F "document=I'd like to buy some shoes" https://api.einstein.ai/v2/language/intent

    In the request, the document parameter contains the string you want to classify. You’re just testing right now, but when you implement Einstein Language for Cloud Kicks, the string to classify will be the text that the user enters in the service request form.

    The API response looks similar to the following JSON. The model predicts that the request is a sales opportunity.
    {
      "probabilities": [
        {
          "label": "Sales Opportunity",
          "probability": 0.99844366
        },
        {
          "label": "Shipping Info",
          "probability": 0.0011946243
        },
        {
          "label": "Order Change",
          "probability": 0.00032401472
        },
        {
          "label": "Password Help",
          "probability": 0.000036838523
        },
        {
          "label": "Billing",
          "probability": 7.9345693e-7
        }
      ],
      "object": "predictresponse"
    }

Interpret the Results

From the prediction response, you can see how the labels come into play when you make a prediction. The model takes the input text and classifies it based on the data associated with each label. In the response, the label value Sales Opportunity has a probability value of 0.9540156. In this case, the model is 95% sure the request is a sales opportunity.

The Cloud Kicks website developer uses the model results to route the service request to the appropriate email address. That developer writes code to route the request based on the highest probability. So this request would go to the sales department.

Each probability value is always a number between 0 and 1. By default, the API returns all the labels in the model. For each label, the API returns a probability that the text belongs in that label. However, you can explicitly specify the number of labels you want to return by using the numResults request parameter.

It’s a wrap! You’ve gone through the full development cycle and your model is ready. However, in the real world, the machine learning development cycle is iterative.

As you test your model and its accuracy, you may find that you need to add labels or data. You may find that users pass in text that you didn’t originally account for, and you need to add data to the model. As you add data to the model and test the accuracy, you can tune the model to make it more accurate. For more information, check out the Einstein Platform Services Developer Guide in the Resources section.

Resources

retargeting