Cruising through our machine learning journey and starting from where we left in the previous installment, the next step is to expose our machine learning model as a web service so that it can be invoked from within Dynamics CRM.

Azure Machine Learning has this fantastic concept of converting an experiment into a trained model. Trained model is like a compiled version of your experiment that can be exposed via a web service, all with the click of just one button, i.e. Setup Web Service.

set up web service

Azure Machine Learning takes care of the rest by deploying the model. Once deployed, you can inspect its configuration by going to the Web Services section as shown here:

microsoft azure machine learning

Connect Web Service within Dynamics CRM

In order to connect to this web service from within Dynamics CRM, we can use the below JavaScript. We can pass CRM objects to this service in JSON format and get prediction results back.

 

Let us prepare Dynamics CRM to start consuming this web service. I have created an event onSave() of the Telecom Customer form which passes the relevant data to the Azure Service and gets the score. The JavaScript for that is as below:

 

Key Points

These scripts are trivial and should be self-explanatory. Basically, we are passing the highly correlated features to the prediction service and getting two outputs

Prediction score → assigned to → manny_predictedchurnstatus

Prediction confidence → assigned to → manny_predictionconfidencepercentage

And they are displayed on the form like this, it’s integrated, i.e. the moment you change the data, the score is updated.

In the next blog post, we will touch upon the insights that can be gained from a machine learning integration.