Task 3: Defining and using a predictive model
You create a predictive model that connects to your machine learning deployment and use
it in your decision service.
Step 1: Creating and connecting a predictive model
You create a predictive model and link it to the machine learning model deployed in Task 1.
- Open the Complete machine learning loan approval decision service.
- Click Create + in the Models tab.
- Select Predictive model. Enter Loan risk score as the name. Then, click Create.
- In the right panel, the machine learning model status shows Not connected. Click Configure to connect the predictive model to the provider you defined in Task 2: Defining a machine learning provider in Decision Designer.
- Keep Remote machine learning model selected and click Next.
- Select the provider wml-complete.
- Select the machine learning model:
- Expand the name of the model you created in Task 1.
- Select the deployment that you want to use.
- Click Next to review the input schema.
- Click Next to run a test invocation. Then, click
Run to validate the model. You get the following
output:
{ "fields": [ "probability_0", "probability_1", "predicted_paymentDefault" ], "values": [ [ 0.17825993285555802, 0.821740067144442, 1 ] ] }Values may differ depending on training method or PMML precision.
- Click Next to define the output schema. Select Generate from test output. Then, click OK.
- Click Apply to connect the predictive model.
Step 2: Editing input and output mapping
You define how the decision service data maps to the machine learning model input and output.
- Create input nodes:
- Rename the Input node to Loan and set its output type to loan.
- Hover over the Loan node and click the Copy node
icon to duplicate it. Rename it to Borrower and set its output type to borrower.
- Define the input mapping rule:
- Click the Input mapping node.
- Go to the Logic tab and create a new business rule named input mapping rule.
- Enter the following rule in the
editor:
definitions set 'duration' to the number of monthly payments of Loan ; set 'rate' to the rate of Loan ; set 'yearlyreimbursement' to 'rate' * the amount of Loan / (1 - pow ( 1 + 'rate' , -duration)); then set decision to a new ML model input where the creditscore is the credit score of Borrower, the income is the yearly income of Borrower , the loanamount is the amount of Loan, the monthduration is the number of monthly payments of Loan , the rate is 'rate' , the yearlyreimbursement is 'yearlyreimbursement' ; - Navigate back to the diagram.
- Define the output mapping rule:
- Click the Output mapping node.
- Set its output type to risk probabilities.
- Go to the Logic tab and create a new business rule named output mapping rule.
- Enter the following rule in the
editor:
if 'ML model invocation' is in error then set decision to a new risk probabilities where the payment default is 0, the probability is 1 ; else set decision to a new risk probabilities where the payment default is the predicted paymentdefault of 'ML model invocation' , the probability is max ( the probability0 of 'ML model invocation' , the probability1 of 'ML model invocation' );
- Go back to the diagram. It should now look like this:

Step 3: Running the predictive model
You create and run test data sets to validate your predictive model.
- Go to the Run tab.
- Create a test data set named John Good Score.
- Edit its content as JSON and enter the following
data:
{ "loan": { "rate": 0.7, "numberOfMonthlyPayments": 72, "amount": 185000 }, "borrower": { "creditScore": 750, "yearlyIncome": 1000000, "firstName": "John" } } - Click Run. The result indicates that there is no risk.
- Create another test data set named Paul Bad Score and enter the following
data as JSON:
{ "borrower": { "creditScore": 100, "yearlyIncome": 100000, "firstName": "Paul" }, "loan": { "numberOfMonthlyPayments": 72, "amount": 520000, "rate": 0.7 } } - Click Run. The result indicates that there is a risk.
Step 4: Integrating the predictive model into the decision model
You update the decision model by replacing an input node with a prediction node that calls your predictive model. The prediction result is stored in a variable so it can be reused across multiple rules.
- In the Navigation history, select Loan Validation Decision Model to open the decision model.
- Remove the Loan Risk Score node.
- Hover over the Risk Score node and click Add prediction. Then, click Select a prediction and choose Loan risk score.
- Select the Risk Score node.
- Go to the Logic tab and edit the loan risk score rule. Then, enter the
following
rule:
set decision to the loan risk score computed from Borrower being Borrower, Loan being Loan; - Return to the diagram. The updated decision model should now look like this:

- Run your decision model:
- Go to the Run tab.
- Execute both the John Good Score and Paul Bad Score test data sets.