Skip to content

Latest commit

 

History

History
171 lines (94 loc) · 5.87 KB

File metadata and controls

171 lines (94 loc) · 5.87 KB

Creating a Machine learning service in Watson Studio

Let's step through the creation of a scoring service:

  1. create a Watson Studio project

add project
Select Complete, and click OK

select Complete project

  1. Locate sample data for basic logistic prediction.

Click on Community in the top menu bar.

find sample in community

Select the GoSales dataset

results

Click the + symbol in the bottom right corner of the dataset to add to the Project

add to project

data added

  1. Now add a machine learning model to the project

add ML instance

Click + New Watson Machine Learning model

Adding ML instance

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

  1. Create the IBM Cloud service to run the ML instance

add new ML instance

Accept the defaults for Price plans, and click the Create button at the bottom

create ML instance

and click Confirm

confirm ML instance

  1. Back in the ML model creation page - click the Reload link and recognize the ML instance you just created.

load ML instance into

  1. Now select the Spark runtime for the model (there should only be one ...)

add ML runtime

Select Manual for the data preparation choice, and click Create

  1. Add the sample data to the ML model for training

add data to ML model

Click Next

  1. Now select a technique for to be used for scoring/predicting

add ML technique

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".

add ML estimator

choose estimator

Select Logistic Regression, and Click Add

estimated added

Click Next

You should see a brief popup - Training Models, followed by the model training evaluation view

status of trained model

Click Save

  1. Create a web service deployment of the model

model overview

The web service for scoring needs to be "deployed" - select the Deployments tab.

select deployments

and click on + Add Deployment

add ML deployment

give your deployment a name, and click Add

deployment added

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.

  1. Testing the model

quick test of model

Click on the Test tab

test data

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
  1. Obtain the scoring endpoint information from the Implementation

find scoring endpoint 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 ...)

capture url

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:

scoring data format

-- 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.

  1. Get the ML username/password credentials for the scoring service

get creds from IBM Cloud

From the top menu bar, select Services and Watson Services and locate the Machine Learning service instance.

select ML instance

Click service name (in this case "pm-20-brs") to see the detail view.

view ML instance details

Now view the Service credentials

capture ML instance 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.

Summary

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:

  1. authentication endpoint URL
  2. service username
  3. service password
  4. scoring service endpoint URL
  5. format of the data to send for scoring

Now let's apply that to your NodeRED application ...

Invoking ML Scoring from NodeRED