Let's step through the creation of a scoring service:
- create a Watson Studio project
- Locate sample data for basic logistic prediction.
Click on Community in the top menu bar.
Select the GoSales dataset
Click the + symbol in the bottom right corner of the dataset to add to the Project
- Now add a machine learning model to the project
Click + New Watson Machine Learning model
Give it a name so you can find it again. You will see that at this stage there is no Machine Learning service associated with your new model - let's fix that.
** Note the Reload link here ...**
Click the Associate a Machine Learning service instance link
- Create the IBM Cloud service to run the ML instance
Accept the defaults for Price plans, and click the Create button at the bottom
and click Confirm
- Back in the ML model creation page - click the
Reloadlink and recognize the ML instance you just created.
- Now select the Spark runtime for the model (there should only be one ...)
Select Manual for the data preparation choice, and click Create
- Add the sample data to the ML model for training
Click Next
- Now select a technique for to be used for scoring/predicting
For the Label column, select IS_TENT - a yes/no label, so Binary Classification will be fine. Leave the feature colums to default to All. To perform the scoring, we add an "estimator".
Select Logistic Regression, and Click Add
Click Next
You should see a brief popup - Training Models, followed by the model training evaluation view
Click Save
- Create a web service deployment of the model
The web service for scoring needs to be "deployed" - select the Deployments tab.
and click on + Add Deployment
give your deployment a name, and click Add
The web service has been deployed and can now be used to score data. To dat tha, you will need to know some information about where to find it, and how to access it securely. Click on the Model name link ("a tent" in this case) to get to the deplyment details, and do a quick test.
- Testing the model
Click on the Test tab
Use other values to see the effect on the prediction:
- Profession - Trades, Professional, Retired, Hospitality, Retail, Sales, Executive, Other
- Marital_Status - Married, Single, Unspecified
- Gender - M, F
- Age - 17 to 69
- Obtain the scoring endpoint information from the Implementation
Of key interest here is the Scoring End-point URL - this will be used to invoke the service from NodeRED (or any other client ...)
Copy and save this in your favourite scratchpad/clipboard/notepad/notes service - you wil need it later. If you take a look at the Javascript Code Snippet, you will find the section that shows how data needs to be formatted for presenting to the scoring service:
-- copy this to your scratchpad, too. As you can see from the code snippet, you will also need the ML Service credentials from the IBM Cloud instance; let's get that now.
- Get the ML username/password credentials for the scoring service
From the top menu bar, select Services and Watson Services and locate the Machine Learning service instance.
Click service name (in this case "pm-20-brs") to see the detail view.
Now view the Service credentials
Expanding the View credentials option for the wdp-writer key, you will find the username and password required for authenticating to the service, and the host for the authentication URL; again, save these to your scratchpad.
As the code snippet in the Implementation view shows, the authentication endpoint is the /v3/identity/token endpoint at the ML host.
At this stage, you have a Machine Learning service running, with a scoring service which will predict the likelihood that a particular person/customer would buy a tent.
You have five pieces of information needed to call this service:
- authentication endpoint URL
- service username
- service password
- scoring service endpoint URL
- format of the data to send for scoring
Now let's apply that to your NodeRED application ...































