Bluemix NL Classifier Tutorial

Post on 08-Jan-2017

12,823 views 4 download

transcript

Configuring the Classifieron IBM Bluemix

craigtrim@gmail.com

QUESTION TYPE CLASSIFICATIONDATA PREPARATION ...

Part 1

1. Verification: invites a yes or no answer.

2. Disjunctive: Is X, Y, or Z the case?

3. Concept completion: Who? What? When? Where?

4. Example: What is an example of X?

5. Feature specification: What are the properties of X?

6. Quantification: How much? How many?

7. Definition: What does X mean?8. Comparison: How is X similar to Y?

9. Interpretation: What is the significance of X?

10. Causal antecedent: Why/how did X occur?

11. Causal consequence: What next? What if?

12. Goal orientation: Why did an agent do X?

13. Instrumental/procedural: How did an agent do X?

14. Enablement: What enabled X to occur?

15. Expectation: Why didn't X occur?

16. Judgmental: What do you think of X?

Questions are often generated by a person's knowledge deficits and cognitive disequilibrium, which occurs when there are obstacles to goals, contradictions, impasses during problem solving, anomalous information, and uncertainty.

Question Types

A total of 5 points are distributed for each question

Questions are gathered from public domain sources off the internet

Point distribution is manual

Classification

Python script to take CSV formatted data from Excel Spreadsheet

Creates a CSV file that the NL Classifier can understand

Classification

DEPLOYING TO BLUEMIXIN 5 SIMPLE STEPS ...

Part 2

Step 1: Access the Service (Slide 1)

IBM Bluemix Homepage

Step 1: Access the Service (Slide 2)

IBM Bluemix Homepage

Step 1: Access the Service (Slide 3)

Step 1: Access the Service (Slide 4)

Step 1: Access the Service (Slide 5)

Step 1: Access the Service (Slide 6)

Step 2: Add the Service (Slide 1)

Step 3: Access the Toolkit (Slide 1)

Step 3: Access the Toolkit (Slide 2)

Step 4: Deploy to Bluemix (Slide 1)

Step 4: Deploy to Bluemix (Slide 2)

Step 4: Deploy to Bluemix (Slide 3)

Step 5: View the App (Slide 1)

Step 5: View the App (Slide 2)

Step 5: View the App (Slide 3)

Step 5: View the App (Slide 3)

Step 5: View the App (Slide 4)

Step 5: View the App (Slide 5)

TRAINING A CLASSIFIERIN 5 SIMPLE STEPS ...

Part 3

Step 1: Train a Classifier (Slide 1)

Step 1: Train a Classifier (Slide 2)

Step 2: Prepare the Data (Slide 1)

Format• The data format is:

text,class

• The text is the actual question or user statement; some real world example

• The class is the classification of this real world example– Only [A-Za-z0-9] are permitted– Use “myClassName” rather than

“my_class_name”• The text and the class are comma

separated, with the text occurring first

Examplewhat is the difference between being alive and truly living?,comparison"when is it time to stop calculating risk and rewards and just go ahead and do what you know is right?”,conceptCompletion"when is it time to stop calculating risk and rewards and just go ahead and do what you know is right?”,interpretation"if we learn from our mistakes why are we always so afraid to make a mistake?”,enablement

Step 2: Prepare the Data (Slide 2)

Step 3: Import the Data (Slide 1)

Step 4: Train the Classifier (Slide 1)

Step 4: Train the Classifier (Slide 2)

Step 4: Train the Classifier (Slide 3)

Step 5: Use the Classifier (Slide 1)

Step 5: Use the Classifier (Slide 3)

Step 5: Use the Classifier (Slide 4)

Step 5: Use the Classifier (Slide 4)

Step 5: Use the Classifier (Slide 4)

ACCESSIBILITYACCESS AND GET/POST

Part 4

Optional: Rename the Service (Slide 1)

Optional: Add another Route (Slide 1)

Optional: Add another Route (Slide 2)

@RequestMapping(value="/classify",params="text", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)

@ResponseBodypublic String classify(

@RequestParam("text") String text) {

NaturalLanguageClassifier classifierService = new NaturalLanguageClassifier();classifierService.setUsernameAndPassword(username, password);

Classification classification = classifierService.classify(route, text);ObjectMapper mapper = new ObjectMapper();

try{return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(classification);} catch(JsonProcessingException e){logger.error(e);}

}

Optional: Java Code(Slide 1)

<dependency> <groupId>com.ibm.watson.developer_cloud</groupId> <artifactId>java-wrapper</artifactId> <version>1.1.0</version></dependency>