AI Builder now supports predicting multiple outcomes (Preview)
AI Builder prediction models now support a preview capability to predict multiple outcomes. Now you can use AI builder intelligence to predict things like is shipping going to be early, on time or late. Or will the business flow be completed as a success, a failure or cancelled.
In this post, we demonstrate how multiple outcomes prediction works by building an example of an end to end scenario for how AI Builder can help to optimize delivery performance and improve customer satisfaction for an e-commerce company.
Let’s say I’m a maker in a typical e-commerce company in Brazil. My CDS database contains typical entities like Order, Product, Customer, etc. I’m noticing that there have been a lot of complaints about delivery delays. But the cost of upgrading shipping from regular to express is very high so I don’t want to upgrade every order that is likely to be late. Instead, I just want to upgrade orders that are going to be late for more than 2 days and for the rest likely to be late orders, I’ll offer some coupons to the customers.
To meet this business goal, I need to create a prediction model which can tell me which orders are going to be late and which are going to be very late (more than 2 days).
Create output fields
I’m going to create an output field to denote what constitutes a delayed delivery. In my Order entity, I have the estimated delivery date and the actual delivery date. Every record where actual delivery date is later than estimated delivery date is considered as a late delivery, and if actual delivery date is more than 2 days later than estimated, the order is considered as very late.
I will create two calculated fields:
Delivery Delta – this is the difference in days between Delivered Date and Estimated Delivery Date.
Delivery timeliness – this field categorizes the Delivery Delta column into Early, On time, Late and Very Late.
And I’m going to user Delivery timeliness as my target outcome.
Create prediction model
First, let’s create a new prediction model from AI Builder section of Power Apps. More information about how to do this: Creating a prediction model.
We use my BC_orders entity and the Delivery timeliness field. Note, multiple outcomes prediction is still in preview. You can also click Manage outcomes on the top navigation bar and select group to two outcomes to switch to binary prediction if needed.
Next, I select my related entities, Customer and Product.
Also, make sure that Delivery Date and Delivery Delta are not selected, because the model should not have information that is only known after the product has been delivered. If you do keep it selected, then the model will show that it has 100% accuracy, but it will not be able to properly predict new orders. This is known in machine learning as target leak, and you can learn more about it here.
Here, let’s skip adding a filter as this data should be sufficient to train the model.
Once all that is done, it is time to train the model. For this model, we have a performance grade of B, which means it’s correct most of the time. The most influential data is also reasonable. I know I can keep improving my model to reach an A grade. However, I decide to use this B model for now to unblock my business.
Publish and use your model
As part of publishing, we actually create three outputs:
- Predicted – The predicted outcome
- Probability – The probability of the true outcome, from 0 – 1
- Explanation – A JSON text field that contains the record level influencers
After model is published, select Use model, and then select Run now to get the prediction results immediately. Let’s give it a few minutes to let the model run on our data set. The model will predict for any records with empty Delivery timeliness field.
After above step is done, we can use the view feature to quickly see the predicted output. Refer to this document for more info.
Now, we’re ready to connect the prediction model to our Power Automate flow. For this example, we can set the flow to be triggered when the Delivery timeliness is Late then send this customer a coupon.
Now, go ahead and try this scenario on your own! Your feedback will help us continue to build on and improve AI Builder. We want to hear from you!
You can refer to this document for guidance about how to import the sample data set so you can try it on your own!