You add the Machine Learning model Mortgage Approval Prediction Model to the Miniloan
decision service in Rule Designer, and run the
application.
About this task
Miniloan is a web-based application that a fictitious lender uses to check the eligibility of
potential borrowers. Loan requests are assessed based on several criteria. In this example, you add
the Machine Learning model
Mortgage Approval Prediction Model to the application. It determines the
probability of a person getting a loan based on their profile.
Procedure
To import the model and run it in the Miniloan sample:
- Open the Miniloan sample in Rule Designer (see Task 1: Designing the main rule project in the decision service)
to enhance it with Machine Learning.
- Next, see Integrating Machine Learning for details on
importing the model. Use the deployment ID you obtained in step 19 of Downloading the Machine Learning model.
- Replace the contents of the ScoringML_1_Call action rule with the
following code:
Then
set the INCOME of 'the scoring' to 100000;
set the YRS AT CURRENT ADDRESS of 'the scoring' to 5;
set the YRS WITH CURRENT EMPLOYER of 'the scoring' to 320;
set the NUMBER OF CARDS of 'the scoring' to 1;
set the CREDITCARD DEBT of 'the scoring' to 1000;
set the LOAN AMOUNT of 'the scoring' to 30;
set the CREDIT SCORE of 'the scoring' to 300;
set the PROPERTY VALUE of 'the scoring' to 750000;
set the AREA AVG PRICE of 'the scoring' to 600000;
set the LOANS of 'the scoring' to 0;
set the GENDER of 'the scoring' to "M";
set the EDUCATION of 'the scoring' to "1";
set the EMPLOYMENT STATUS of 'the scoring' to "1";
set the MARITAL STATUS of 'the scoring' to "1";
set the APPLIEDONLINE of 'the scoring' to "1";
set the RESIDENCE of 'the scoring' to "1";
set the COMMERCIAL CLIENT of 'the scoring' to "0";
set the COMM FRAUD INV of 'the scoring' to "0";
set the deployment ID of 'the scoring' to 'the deploymentID in variable set scoringModel';
make it false that 'the scoring' is permitted to use defaults ;
execute 'the scoring' ;
add "ML return code=" + the return code of 'the scoring' to the messages of 'the loan';
add "Items of the list probabilities:" to the messages of 'the loan';
for each number in the probabilities of 'the scoring' : - add "- " + this number to the messages of 'the loan';
add "prediction=" + the prediction of 'the scoring' to the messages of 'the loan';
The code changes the default values to valid values for a mortgage application, for example:
set the GENDER of 'the scoring' to "M";
set the AREA AVG PRICE of 'the scoring' to 600000;
The last four lines of the code allow the Machine Learning decision to be passed
back via the messages of the loan.
- Replace the contents of the ScoringML_2_Decision action rule with
the following code:
if the prediction of 'the scoring' is at most 10
then add "prediction <= 10" to the messages of 'the loan' ;
else add "prediction > 10" to the messages of 'the loan' ;
- Integrate the Machine Learning rules into the
miniloan ruleflow:
- Open the miniloan ruleflow in the ruleflow editor.
- Drag and drop the rules ScoringML_1_Call and
ScoringML_2_Decision into the editor.
- Move the end of the data approved line to
ScoringML_1_Call.
- Connect ScoringML_1_Call to ScoringML_2_Decision.
- Connect ScoringML_2_Decision to the eligibility
task.
The modified ruleflow should look as follows:
- If you have not already done it, you can configure your Liberty server with the details
of the Machine Learning endpoint
(see Connecting to the Machine Learning service). Use the
URL in step 18 of Downloading the Machine Learning
model.
-
Deploy the rule project to the Rule Execution Server console in the usual manner (see
Task 5: Deploying and running your ruleset).
- In the decision service HTDS endpoint, change
<approved>false<approved> to <approved>true<approved>
in the default input to get the extra loan messages in the output.
- Click Execute Request with the altered input (see step 5 of Task 5: Deploying and running your ruleset).
The
output includes
Machine Learning
messages:
Results
You have added a Machine Learning model to a decision service and run the
application.