Imagine that you have built a predictive model with R and you would like to predict in real time, whether it is profitable to grant a loan and you wonder how to publish the script written in the R language as a Web Service.
At first glance, this task seems to be complex, however, it turns out to be a piece of cake. With the help of predictive models it is possible to predict occurrence of specific events on the basis of historical data. Predictive models have various applications, yet in this example we will use a model that assesses the probability of loan repayment.
Scoring.One is a tool which enables quick implementation of predictive models, creating decision-making scenarios with extremely high efficiency (processing hundreds of thousands of queries for many predictive models at the same time).
Sign up for free!
In order to use a R model in Scoring.One you need a .zip file containing the:
The worst part’s over, and now is the time for sheer pleasure – deploying your model!
Go to the “Scoring Code Management” tab and click on the “Upload new scoring code” button.
Enter the name for your scoring code and drop the .zip file in the box or click to upload it.
After saving the code it is time for a scenario. Choose “Scenario” tab and create new one. Drag&drop blocks to the center of the grey area. In this case (although probably like in all cases – the name says it all 🙂 ) we start with the “Start” block.
You do not need to enter the variables, since they have been imported in .zip file. Choose “Scoring Code” and “End” buttons using drag&drop method and connect them in order.
Click on the “Scoring Code” and select the previously uploaded code from which you also import the variables. Save and click “Deploy”. Then, the scenario will be processed and you can select in the “End” block the variables to be returned as a result of the scenario. Then click “Deploy” button once again.
You can see that creating scenario is like a walk in the park!
Let’s test your scenario: choose “Forms”, find your scenario and enter the data. As a result you will obtain scoring results saved as rResult variable. Now the model has been queried.
You can add more variables, for example, in order to categorise on the basis of results. To add more variables go back to the scenario and add one more block.
In “Expressions” you can add a code in R or Groovy. The variables created there will also be returned by the model.
If you add the variable “category”, you will get not only the scoring results, but also the category to which its value belongs.
In the place where the URL should be entered, insert:
How to find this mysterious Score Token?
It is hidden in User Settings 🙂 .
As Body of the query enter the variables needed for the model in the JSON form.
Press “Send” button. And that’s all it takes. You have finished the task!