Watson
Create and train a classifier
Overview
error_outline This BLOCK is currently in beta and will become unavailable post official release. Please use the official version once it is released.
As a beta release, there is the possibility that some functions may not execute properly. We appreciate feedback from users regarding bugs or ways to improve BLOCKS.
warning Your IBM Cloud open_in_new account must be configured to allow use of the Natural Language Classifier service open_in_new in order to use this BLOCK. You must also have Natural Language Classifier service credentials.
This BLOCK allows you to use Create classifier from the IBM Watson Natural Language Classifier API open_in_new from BLOCKS.
You can create and train a natural language classifier by executing this BLOCK. The following image shows the placement for using this BLOCK:
-
Create and train a classifier BLOCK
The classifier learns (does its training) from text format data.
-
Classify text BLOCK
The trained classifier takes new text data (untrained data) and interprets it to determine its class. It classifies the data as the most appropriate class from among the ones set during the training.
You can prepare your training data as one of the following three formats:
- Natural Language Classifier-specific text format (CSV)open_in_new
- Google Spreadsheet (BLOCKS-specific function)
- Array data (BLOCKS-specific function)
The following sections will briefly explain each training data format and how to use them with a BLOCKS Big Data Board.
Natural Language Classifier-specific text format (CSV)
info_outline Refer to the IBM Cloud documentationopen_in_new for details about text data formatting for the Natural Language Classifier.
This section will explain how to use the Natural Language Classifier API’s specific text data format from a Big Data Board.
On your Big Data Board, you will place a Load to variable from GCS BLOCK to read a file stored in Google Cloud Storage (GCS), then simply connect a Create and train a classifier BLOCK.
First, upload your data to GCS. For this example, assume we’ve uploaded a file called weather_data_train.csv to a GCS bucket named my-blocks-bucket (GCS URL: gs://my-blocks-bucket/weather_data_train.csv.
info_outline You can use the GCS Explorer BLOCKS service to easily upload files from your PC to GCS.
Then, create a Flow like the following to create and train your classifier.
warning You must set the file format property for both the Load to variable from GCS and Create and train a classifier BLOCKS to none.
Google Spreadsheet (BLOCKS-specific function)
You can use Google Spreadsheet data as your training data by using BLOCKS. Your data must be formatted as follows:
Once you have prepared your spreadsheet, you can create and train your classifier using a Flow like the one shown below:
warning You must share the Google Spreadsheet with the email for your GCP service account. Also, be sure to set the file format property of the Create and train a classifier BLOCK to JSON.
Array format (BLOCKS-specific function)
You can also use an object whose members are each arrays as the training data (BLOCKS-specific function).
The following example shows how to create training data using the Construct object BLOCK. The contents of the data are the same as in the previous Google Spreadsheet example.
(Click image to enlarge)
- Create one Object. The object in this example has the key name
data
. - Inside the object, create Array type members.
- Enter the classes as the Key for each array. In this example, the classes are
temperature
andconditions
. - Enter the elements of the array as the text to classify (string format).
Once you have finished preparing the Construct object BLOCK, you can create and train your classifier with a Flow like the one shown below:
warning Make sure to set the file format property of the Create and train a classifier BLOCK to None.
Properties
Property | Explanation |
---|---|
BLOCK name |
Configure the name displayed on this BLOCK |
Username |
The value of "username" from your Natural Language Classifier service credentials (as shown below). (Click image to enlarge) |
Password |
The value of "password" from your Natural Language Classifier service credentials (as shown below). (Click image to enlarge) |
Variable containing training data |
Designate the variable that contains the training data. |
File format |
Designate the format of the training data.
|
Classifier name |
Designate a unique name to identify this classifier. |
BLOCK memos |
Make notes about this BLOCK. |
Language |
Designate the language of the training data. |