Recently, Microsoft have released new Artificial Intelligent functionality, which can easily be added to Power Apps and Microsoft Flow (now called Power Automate).
At the time of writing this blog there are four AI Models, Form Processing, Object Detection, Prediction and Text Classification.
This blog will focus only on the AI Prediction Model. We will be setting up the AI Model and then looking at how we can use it in Dynamics 365.
First, what is Prediction?
Prediction (also known as Binary Classification) can be used to predict an outcome by looking at existing data within the Common Data Service (for example records within Dynamics 365).
The first step for setting up the Model after you’ve given it a name is choosing where the data for prediction should come from. Here you need to choose an Entity - I selected the Contact Entity and the Gender field to use to perform the prediction against.
From here you’ll need to select mapping values for each available option. Here I’ve set up the model to predict Contacts are ‘Male’ where the Gender has ‘No value’.
The next step is to select fields which can be used to check against for the prediction. This page will show all the available fields for the selected Entity (in this case the Contact Entity), you’ll need to choose at least two fields to progress.
For this example, I’ll select the First Name and Middle Name fields to predict the gender of a Contact. We could use more meaningful information, but I want to illustrate later how the prediction can be improved.
Note: Two fields are the minimum required fields to progress, however the more fields you add the better the AI feature will work, as it will have more information that it can use for training and analytics.
Once fields have been chosen, you’re able to train the model. To train the model, you’ll need a minimum of 50 records for the selected Entity and only then be able to select the Train button.
Once trained you’ll be shown an initial performance score from your existing data and will be given the ability to Publish for use in Power Apps and Microsoft Power Automate.
Great, you’ve now built your own custom Artificial Intelligence Model, that can predict the Gender of Contact Records within Dynamics 365 using information from the Contact First Name and Middle Name.
You can use the AI Model outputs in several ways, a couple of examples being to incorporate it within a Microsoft Power Automate to trigger an action or simply pull them into a Contacts View.
For this scenario I’ll take you through incorporating them into a View within Dynamics 365.
Let’s update the already existing out of the box ‘All Contacts’ view.
You will see that you now have three new fields (automatically created to store the AI Prediction Model’s outputs in) available to add to your view:
Explanation - Showing what field criteria weighting have been applied
Predicted - Showing the true/false prediction outcome
Probability - Showing the AI estimation of accuracy to its prediction
Add these columns and move them along with the ‘Gender’ column to the left-hand side for ease of reference.
I also renamed the Field labels for usability to: AI Prediction, AI Probability and AI Explanation.
You can see that a Prediction was made for every Contact Record that did not have the ‘Gender’ field populated, along with a Probability of its accuracy and an Explanation of what criteria impacted the decision.
When we built the AI Model, we set that the output should be yes if the gender is predicted as ‘Male’ and no if ‘Female’.
In the above screenshot you can see that the AI Prediction Model predicted that Bette, Bob, Bobbi and Brady are predicted as gender ‘Male’ and Angelo, Ashley, Bernadette, Bertie, Brian and Brandie are predicted as gender ‘Female’.
The results look good considering the data we supplied the AI Model with it estimated an effectiveness of only 54%.
If the model performance is low, you can improve the model’s accuracy with the following options:
Create a New Version of the AI Model where you add additional fields for it to incorporate into its learnings, such as the ‘Salutation’ field.
Supply it with more data samples to train on and then Retrain the AI Model to incorporate it into its learnings.
You can gauge the improvement via the Performance outcome and continue until you’re satisfied with the outputs.