SAAI3-AI Analyst 2022-Course Guide
SAAI3-AI Analyst 2022-Course Guide
cover
Front cover
Notebook
Artificial Intelligence Analyst 2022
Course code SAAI ERC 3.0
Ahmed Abdel-Baky
Heba Aboulmagd
Nouran Attia
Islam Helal
Norhan Khaled
Dina Sayed
IBM Training
July 2022 edition
Notices
This information was developed for products and services offered in the US.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM
representative for information on the products and services currently available in your area. Any reference to an IBM product, program,
or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent
product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's
responsibility to evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this
document does not grant you any license to these patents. You can send license inquiries, in writing, to:
IBM Director of Licensing
IBM Corporation
North Castle Drive, MD-NC119
Armonk, NY 10504-1785
United States of America
INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some jurisdictions do not allow disclaimer of express or implied
warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein;
these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s)
and/or the program(s) described in this publication at any time without notice.
Any references in this information to non-IBM websites are provided for convenience only and do not in any manner serve as an
endorsement of those websites. The materials at those websites are not part of the materials for this IBM product and use of those
websites is at your own risk.
IBM may use or distribute any of the information you provide in any way it believes appropriate without incurring any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other
publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any
other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of
those products.
This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible,
the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to
actual people or business enterprises is entirely coincidental.
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corp., registered in many
jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM
trademarks is available on the web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml.
© Copyright International Business Machines Corporation 2018, 2022.
This document may not be reproduced in whole or in part without the prior written permission of IBM.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
V12.0
Contents
TOC
Contents
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Agenda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
TMK
Trademarks
The reader should recognize that the following terms, which appear in the content of this training
document, are official trademarks of IBM or other companies:
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International
Business Machines Corp., registered in many jurisdictions worldwide.
The following are trademarks of International Business Machines Corporation, registered in many
jurisdictions worldwide:
Cloudant® Db2® IBM Cloud®
IBM Cloud Pak® IBM Research® IBM Watson®
Maximo® OpenWhisk® Resource®
SPSS® Think® With Watson®
Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both.
Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other
countries, or both.
Java™ is a trademark or registered trademark of Oniqua Pty. Ltd., an IBM Company.
RStudio® and Shiny® are registered trademarks of RStudio, Inc.
Social® is a trademark or registered trademark of TWC Product and Technology, LLC, an IBM
Company.
Other product and service names might be trademarks of IBM or other companies.
pref
Course description
Artificial Intelligence Analyst 2022
Duration: 5 days
Purpose
The Artificial Intelligence Analyst career path prepares students to apply AI concepts to build
real-life solutions. This career path introduces students to basic concepts of AI, machine learning
algorithms, natural language processing, chatbots, and computer vision. Students apply the
concepts they learn to practical examples by using IBM Watson services and tools on IBM Cloud
Audience
• Undergraduate senior students from IT related academic programs, for example, computer
science, software engineering, information systems and others.
• IT and business professionals who want to explore how AI technologies can be applied to
solve business problems or build business solutions.
Prerequisites
Before attending Module III AI Analyst classroom, students must meet the following
prerequisites:
• Successful completion of Module I AI Overview (self-study).
• Successful completion of Module II Prerequisites (self-study).
• Successful completion of Exercise 0, Setting up your hands-on environment.
Objectives
After completing this course, you should be able to:
• Explain what artificial intelligence (AI) is.
• Describe the field of AI and its subfields: Machine learning, natural language processing (NLP),
and computer vision.
• List applications of AI in the industry and government.
• Describe machine learning.
• Describe different type of machine learning algorithms.
• Apply machine learning algorithms to specific problems.
• Explain deep learning.
• Explain convolutional neural networks and neural networks.
pref
Agenda
Note
The following unit and exercise durations are estimates, and might not reflect every class
experience.
Day 1
(00:30) Welcome
(01:30) Unit 1 - Introduction to machine learning
(01:00) Exercise 1 - Applying machine learning algorithms
(01:00) Unit 2 - Introduction to IBM Watson
(01:00) Exercise 2 - Exploring IBM Watson services
Day 2
(00:30) Unit 3 - Introduction to IBM Watson Studio
(01:30) Exercise 3 - Getting started with IBM Watson Studio
(01:00) Unit 4 - Introduction to IBM Watson Machine Learning and AutoAI
(01:00) Exercise 4 Section 1 - Getting started with IBM Watson Machine Learning
(01:00) Exercise 4 Section 2 - Creating an AutoAI experiment from marketing data
(00:45) Exercise 5 - Building and deploying a regression analysis model with Watson Machine
Learning
Day 3
(00:30) Unit 5 - Introduction to natural language processing
(00:30) Unit 6 - Natural language processing concepts and components
(00:30) Unit 7 - Natural language processing evaluation metrics
(00:30) Unit 8 - Natural language processing and IBM Watson
(01:30) Exercise 6 - Ingesting, converting, enriching, and querying data with the IBM Watson
Discovery service
(00:45) Unit 9 - Introduction to IBM Watson Knowledge Studio
(01:30) Exercise 7 - Creating a machine learning model with Watson Knowledge Studio
pref
Day 4
(00:30) Unit 10 - Introduction to chatbots
(01:30) Unit 11 - Introduction to IBM Watson Assistant
(00:45) Exercise 8 - Getting started with IBM Watson Assistant
(01:30) Exercise 9 - Help Desk chatbot
(01:00) Exercise 10 - Exploring the new Watson Assistant: Creating a retail customer service
chatbot
(00:30) Unit 12 - Introduction to computer vision
(00:30) Unit 13 - Computer vision fundamentals
(01:00) Exercise 11 - Using a basic deep neural network to solve an image recognition problem
Day 5
(01:00) Unit 14 - Designing and building an intelligent solution
(02:00) Exercise 12 - Building a chatbot and movie recommender solution with Watson services
and Node-RED
(01:30) Unit 15- Getting started with AI ethics
(01:00) Exercise 13 - Monitoring fairness in a credit risk prediction model
(01:00) Exercise 14 - Monitoring weather conditions bias in a model that predicts
telecommunications call drops
Uempty
Overview
This unit recaps the main topics in Module I, AI overview and provides a deeper view into complex
subjects, such as:
• Machine learning
• Machine learning algorithms
• Neural networks
• Deep learning
Uempty
Uempty
Uempty
1.1. What is machine learning?
Uempty
What is machine
learning?
Uempty
Machine learning
• In 1959, the term “machine learning” was first introduced by Arthur Samuel. He defined it as
the “field of study that gives computers the ability to learn without being explicitly
programmed”.
• The learning process improves the machine model over time by using training data.
• The evolved model is used to make future predictions.
Arthur Samuel, former IBM engineer and a professor at Stanford, was one of the pioneers in the
field of computer gaming and artificial intelligence. He was the first one to introduce the term
“machine learning”. Machine learning is a field of artificial intelligence. It uses statistical methods
to give computer the ability to "learn" from data, without being explicitly programmed.
If a computer program can improve how it performs certain tasks based on past experiences, then
it has learned. This differs from performing the task always the same way because it has been
programmed to do so.
The learning process improves the so-called “model” over time by using different data points
(training data). The evolved model is used to make future predictions.
References:
Machine Learning
https://link.springer.com/chapter/10.1007/978-1-4302-5990-9_1
Automated Design of Both the Topology and Sizing of Analog Electrical Circuits Using Genetic
Programming
https://link.springer.com/chapter/10.1007/978-94-009-0279-4_9
Uempty
Uempty
1.2. Machine learning algorithms
Uempty
Machine learning
algorithms
Uempty
To estimate the function that represents the model, an appropriate learning algorithm must be
used. In this context, the learning algorithm represents the technique through which the system
extracts useful patterns from the input historical data. These patterns can be applied to new data
in new situations. The objective is to have the system learn a specific input/output transformation
and to make future predictions for a new data point. Finding the appropriate algorithms to solve
complex problems in various domains and knowing how and when to apply them is an important
skill that machine learning engineers should acquire. Because the machine learning algorithms
depend on data, understanding and acquiring data with high quality is crucial for accurate results.
Uempty
• Classification is the task of predicting a discrete class label, such as “black, white, or gray” and
“tumor or not tumor”.
• Regression is the task of predicting a continuous quantity, such as “weight”, “probability”, and
“cost”.
Supervised learning is one of the main categories of machine learning. In supervised machine
learning, input data (also known as training examples) comes with a label, and the goal of learning
is to predict the label for new, unforeseen examples. A supervised learning algorithm analyzes the
training data and produces an inferred function, which can be used for mapping new examples.
In practice, the problems that are solved by using supervised learning are grouped into either
regression or classification problems.
Classification is the task of predicting a discrete class label, such as “black, white, or gray” and
“tumor or not tumor”.
Regression is the task of predicting a continuous quantity, such as “weight”, “probability” and
“cost”.
Uempty
• Clustering algorithms: Discover how to split the data set into a number of groups such that
the data points in the same groups are more similar to each other compared to data points in
other groups.
Unsupervised learning is a machine learning type that learns from data that has not been
labeled. The goal of unsupervised learning is to detect patterns in the data. One of the most
popular types of unsupervised learning is clustering algorithms.
Clustering algorithms are algorithms that discover how to split the data set into a number of
groups such that the data points in the same groups are more similar to each other compared to
data points in other groups.
Uempty
• A machine learning technique that falls between supervised and unsupervised learning.
c. Use the labeled data and the newly generated labeled data to create a new model.
Many real practical problems fall into this category of machine learning where you have little
labeled data and the rest of the data is unlabeled.
Labeling data is an expensive or time-consuming process. In addition, it mandates having domain
experts to label data accurately. Think about labeling skin diseases images that must be labeled
by a domain expert. Also, too much labeling data might introduce human biases into the model.
In semi-supervised learning, you try to get the best out of your unlabeled data. There are different
techniques to achieve this task. For example, you can use pseudo-labeling, which aims to give
approximate labels to unlabeled data. Pseudo-labeling works as follows:
1. Use labeled data to train a model.
2. Use the model to predict labels for the unlabeled data.
3. Use the labeled data and the newly generated labeled data to create a model.
References:
Introduction to Pseudo-Labelling : A Semi-Supervised learning technique
https://www.analyticsvidhya.com/blog/2017/09/pseudo-labelling-semi-supervised-learning-tec
hnique/
Uempty
• The algorithm discovers an association between the goal and the sequence of events that
leads to a successful outcome.
Self-driving cars.
Uempty
In the following slides, we explore different machine learning algorithms. We describe the most
prominent algorithms. Each algorithm belongs to a category of learning. We explore supervised
and unsupervised algorithms, regression and classification algorithms, and linear and non-linear
classification.
Uempty
Naïve Bayes classifiers is a powerful and simple supervised machine learning algorithm. It
assumes that the value of a particular feature is independent of the value of any other feature,
given the class variable. For example, a fruit may be considered to be an apple if it is red, round,
and about 10 cm in diameter.
Features: Color, roundness, and diameter.
A Naïve Bayes classifier considers each of these features to contribute independently to the
probability that this fruit is an apple, regardless of any possible correlations between the color,
roundness, and diameter features.
Uempty
Imagine that you have the data set that is shown in the table in this slide. The column with title “Is
Apple?” represents the label of the data. Our objective is to make a new prediction for an
unknown object. The unknown object has the following features:
• Color: Red
• Shape: Round
• Diameter: 10 cm
Note 1: Sometimes the terminology “parameters” or “variables” is used to describe the
“features”.
Note 2: “Annotated data” or “labeled data” refer to the same terminology.
Uempty
Uempty
5. Compute p(x|CY) = p(Colour = Red, Shape = round, Diameter =>10 cm | Apple = Yes).
Naïve Bayes assumes that the features of the input data (the apple parameters) are
independent.
The Naïve Bayes formula is given by this model. Our target is to compute the formula to reach
p(CK |x), where K is any class (CY or CN).
5. Compute the conditional probability of having each feature given that the class is CY: p(x|CY)
= p(Colour = Red, Shape = round, Diameter =>10 cm | Apple = Yes).
Because Naïve Bayes assumes that the features of the input data (the object features) are
independent, to get the p(x|CY) value, we calculate the conditional probability of each feature at a
time with the class CY, and then multiply all the values.
Uempty
= p(Colour = Red | Apple = Yes) X p(Shape = round | Apple = Yes) X p(Diameter => 10 cm | Apple = Yes)
= p(Color = Red | Apple = No) X p(Shape = round | Apple = No) X p(Diameter => 10 cm | Apple = No)
Uempty
Let us see how to calculate these conditional probabilities. For example, to calculate p(Colour =
Red | Apple = Yes), you are asking, “What is the probability for having a red color object given that
we know that it is an apple”.
You browse the table to see how many “is Apple?” has a “yes” label. You see that the occurrence
is five times.
Now, from the table, how many of these five occurrences are when you have a color = red? You
find that there are three occurrences for red color. Therefore, p(Colour = Red | Apple = Yes) = 3/5.
Repeat these steps for the rest of the features.
Uempty
• p(Color = Red | Apple = Yes) X p(Shape = round | Apple = Yes) X p(Diameter = > 10 cm | Apple = Yes)
• p(Color = Red | Apple = No) X p(Shape = round | Apple = No) X p(Diameter = > 10 cm | Apple = No)
Now, we have all the values that we need. As mentioned in step 5, we multiply the conditional
probabilities as follows:
p(Color = Red | Apple = Yes) X p(Shape = round | Apple = Yes) X p(Diameter = > 10 cm | Apple =
Yes)
= (3/5) x (4/5) x (2/5) = 0.192
p(Color = Red | Apple = No)p(Shape = round | Apple = No)p(Diameter = > 10 cm | Apple = No)
= (2/5) x (2/5) x (3/5) = 0.096
p(Apple = Yes) = 5/10
p(Apple = No) = 5/10
Uempty
Finally, we compare the values of p(CY |x) versus p(CN |x). By substituting the values that were
calculated in the previous steps, we discover that p(CY |x) > p(CN |x), which means that the object
is an apple.
Uempty
Linear regression
• Linear regression is a linear equation that combines a specific set of input values (X) and an
outcome (Y) that is the predicted output for that set of input values. As such, both the input
and output values are numeric.
• The target variable is a continuous value.
Examples for applications:
• Analyze the marketing effectiveness, pricing, and promotions on the sales of a product.
• Forecast sales by analyzing the monthly company’s sales for the past few years.
• Predict house prices with an increase in the sizes of houses.
• Calculate causal relationships between parameters in biological systems.
Regression algorithms are one of the key algorithms that are used in machine learning. Regression
algorithms help analysts to model relationships between input variables X and the output label Y
for the training data points. This algorithm targets supervised regression problems, that is, the
target variable is a continuous value.
In simple linear regression, we establish a relationship between the target variable and input
variables by fitting a line that is known as the regression line.
There are different applications that benefit from linear regression:
• Analyze the marketing effectiveness, pricing, and promotions on the sales of a product.
• Forecast sales by analyzing the monthly company’s sales for the past few years.
• Predict house prices with an increase in the sizes of houses.
• Calculate causal relationships between parameters in biological systems.
Uempty
Size Price
30 30,000
70 40,000
90 55,000
110 60,000
130 80,000
150 90,000
180 95,000
190 110,000
Assume that we are studying the real state market and our objective is to predict the price of a
house given its size by using previous data. The label in this case is the price column.
Uempty
After plotting the points on the graph, they seem to be forming a line.
Uempty
C. $85,000 70 40,000
90 55,000
110 60,000
130 80,000
150 90,000
180 95,000
190 110,000
You want to find the price value of a 140-meter square house. Which of the following choices is
correct?
1. $60,000
2. $95,000
3. $85,000
Uempty
To answer the question “What is the price for a 140-meter square house?”, we need to draw the
line that best fits most of the data points.
How we can find the line that best fits all the data points? We can draw many lines, so which one is
the best line?
The best line should have the minimal error value. The error refers to the aggregated distance
between data points and the assumed line. Calculate the error iteratively until you reach the most
accurate line with a minimum error value.
Uempty
After the learning process, you get the most accurate line, the bias, and the slope to draw your
line.
p0 is the bias. It is also called the intercept because it determines where the line intercepts the y
axis.
p1 is the slope because it defines the slope of the line or how x correlates with a y value before
adding the bias.
If you have the optimum value of p0 and p1 , you can draw the line that best represents the data.
Uempty
The squared error function J is represented by the difference between the predicted point and the
actual points. It is calculated as follows:
J(P) = (1/(2*m)) Σ (hp (xi ) - yi)2
Where:
• i is the number of a sample or data point within the data set samples.
• hp (xi ) is the predicted value for data point i.
• yi is the actual value for data point i.
• m is the count of data set samples or data points.
We can use an optimization technique that is called stochastic gradient descent. The algorithm
evaluates and updates the weights on every iteration to minimize the model error. The technique
works iteratively. In each iteration, the training instance is exposed to the model once. The model
makes a prediction and the corresponding error is calculated. The model is updated to reduce the
error for the next prediction. The process continues to adjust the model weights to reach the
smallest error.
Here we use the gradient descent algorithm to iteratively get the values of p0 and p1 (the
intercept and slope of the line are also called weights) by the following algorithm:
Pj := Pj – α (hp (xi ) - yi) xj i
Where:
j is the feature number.
α is the learning rate.
Uempty
With more features, you do not have a line; instead, you have a plane. In higher dimensions where
we have more than one input (X), the line is called a plane or a hyper-plane.
The equation can be generalized from simple linear regression to multiple linear regression as
follows:
Y(X)=p0+p1*X1+p2*X2+...+pn*Xn
Uempty
Logistic regression
• Supervised classification algorithm.
• Target: A dependent variable (Y) is a discrete category or a class (not a continuous variable as
in linear regression).
Example: Class1 = Cancer, Class2 = No Cancer
Uempty
Logistic function
Logistic regression is named for the function that is used at the core of the algorithm, which is the
logistic function. The logistic function is also known as the sigmoid function. It is an S-shaped
curve (as shown in the figure) for data segregation across multiple classes that can take any real
value 0 - 1.
Uempty
During the learning process, the system tries to generate a model (estimate a set of parameters
p0, p1, …) that can best predict the probability that Y will fall in class A or B given the input X. The
sigmoid function squeezes the input value between [0,1], so if the output is 0.77 it is closer to 1,
and the predicted class is 1.
Uempty
Example: Assume that the estimated values of p’s for a certain model that predicts the gender
from a person’s height are p0= -120 and p1=0.5.
Assume that you have two classes where class 0 represents female and class 1 represents male.
Y = exp(-120+0.5X)/(1+exp(-120+0.5X))
Y = 0.00004539
P(male|height=150) is 0 in this case.
Uempty
SVM is a supervised learning model that can be a linear or non-linear classifier. SVM is also called
a “large Margin Classifier” because the algorithm seeks the hyperplane with the largest margin,
that is, the largest distance to the nearest sample points.
Uempty
Assume that a data set lies in a two-dimensional space and that the hyperplane will be a
one-dimensional line.
Although many lines (in light blue) do separate all instances correctly, there is only one optimal
hyperplane (red line) that maximizes the distance to the closest points (in yellow).
Uempty
Decision tree
• A supervised learning algorithm that uses a tree structure to model decisions.
• It resembles a flow-chart or if-else cases.
• An example for applications is general business decision-making like predicting customers’
willingness to purchase a given product in a given setting, for example, online versus a
physical store.
A decision tree is a popular supervised learning algorithm that can be used for classification and
regression problems. Decision trees are a popular prediction method. Decision trees can explain
why a specific prediction was made by traversing the tree.
There are different examples for applications that can use decision tree in business. For example,
predicting customers’ willingness to purchase a given product in a given setting, for example,
online versus a physical store.
Note
Uempty
A decision tree includes three main entities: root node, decision nodes, and leaves. The figure
shows the graphical representation of these entities.
A decision tree builds the classification or regression model in the form of a tree structure. It
resembles a flowchart, and is easy to interpret because it breaks down a data set into smaller and
smaller subsets while building the associated decision tree.
Uempty
The “Play Tennis” example is one of the most popular examples to explain decision trees.
In the data set, the label is represented by “PlayTennis”. The features are the rest of the columns:
“Outlook”, “Temperature”, “Humidity”, and “Wind”. Our goal here is to predict, based on some
weather conditions, whether a player can play tennis or not.
Reference:
Choosing the Best Attribute
http://jmvidal.cse.sc.edu/talks/decisiontrees/choosingbest.html?style=White
Uempty
Back to the example, the decision tree representation on the right side of the figure shows the
following information:
• Each internal node tests an attribute.
• Each branch corresponds to an attribute value.
• Each leaf node assigns a classification.
Eventually, we want to make a classification of “if Play Tennis = {Yes, No}”.
Reference:
Choosing the Best Attribute
http://jmvidal.cse.sc.edu/talks/decisiontrees/choosingbest.html?style=White
Uempty
The algorithm works by recursively splitting the data based on the value of a feature. After each
split, the portion of the data becomes more homogeneous.
Now, the algorithm needs to decide:
1. Which feature to choose as the root node.
2. What conditions to use for splitting.
3. When to stop splitting.
Uempty
The Iterative Dichotomiser3 (ID3) algorithm works by using entropy and information gain to
construct a decision tree. Entropy is the measure of the amount of uncertainty and randomness in
a set of data for the classification task. Entropy is maximized when all points have equal
probabilities. If entropy is minimal, it means that the attribute or feature appears close to one
class and has a good discriminatory power for classification.
Entropy zero means that there is no randomness for this attribute.
Information gain is a metric that is used for ranking the attributes or features to split at given node
in the tree. It defines how much information a feature provides about a class. The feature with the
highest information gain is used for the first split.
Uempty
K-mean clustering
• Unsupervised machine learning algorithm.
• It groups a set of objects in such a way that objects in the same group (called a cluster) are
more similar to each other than those in other groups (other clusters).
K-means clustering is an unsupervised machine learning technique. The main goal of the
algorithm is to group the data observations into k clusters, where each observation belongs to the
cluster with the nearest mean.
A cluster’s center is the centroid. The figure shown plots of the partition of a data set into five
clusters, with the cluster centroids shown as crosses.
Uempty
Uempty
Assume that you have the data points that are show in the figure. Your goal is to cluster each data
point into one of two groups. Thus, the cluster size is 2. C1 and C2 represent these two clusters.
Uempty
Assume initial centroids are C1, point (1,1) and C2, point (2,1)
Uempty
To compute the centroid of a cluster, use an iterative process where each point is examined and
you determine whether it belongs to a specific cluster. Then, you compute the new centroid by
using the mean of all points.
Uempty
As you see, the new points in red are the new centroids. We apply another iteration to find a better
centroid that represents each cluster.
Uempty
Now, we examine each point again against the centroid by using Euclidian distance and calculate
the new centroids (C1 and C2).
Uempty
As you see, the new red centroids represent the centers of the two clusters. The algorithm stops
when the centroids do not change or change slightly, or if a maximum number of iterations are
defined.
Uempty
1.3. What are neural networks?
Uempty
Uempty
Neural networks
• Machine learning models that are inspired by the structure of the human brain.
• The human brain is estimated to have 100 billion neurons, and each neuron is connected to up
to 10,000 other neurons.
Uempty
Artificial neural networks communicate signals (numbers) through weights and activation
functions that activate neurons. Using a training algorithm, these networks adjust those weights
to solve a problem.
Each node applies a mathematical transformation to the data it receives; it then passes its result
to the other nodes in its path. Each connection between nodes represents a different parameter to
the model.
A neural network is useful for machine learning tasks that have too many features (millions). For
example:
• Object detection, tracking, and image and video analysis by using a Convolutional Neural
Network (CNN)
• Natural language processing tasks like speech recognition and machine translation by using a
recurrent neural network (RNN)
• Autonomous cars and robots (more complex neural networks)
Uempty
A neural network is composed of three or more layers: an input layer, one or many hidden layers,
and an output layer. Data is imported through the input layer. Then, the data is modified in the
hidden and output layers based on the weights that are applied to their nodes. The typical neural
network can consist of thousands or even millions of simple processing nodes that are densely
interconnected.
Uempty
Perceptron
• A single neuron model and originator for the neural network.
• Similar to linear classification, where each input has weight.
• One bias.
A perceptron is a single neuron model that was an originator for neural networks. It is similar to
linear regression. Each neuron has its own bias and slope (weights). For example, assume that a
neuron have two inputs (X1 and X2 ), so it requires three weights (P1, P2 and P0 ). The figure in this
slide shows a weight for each input and one for the bias.
Uempty
Backpropagation is an algorithm for training neural networks that have many layers. It works in
two phases:
• Propagation of inputs through a neural network to the final layer (called feedforward).
• The algorithm computes an error. An error value is then calculated by using the wanted output
and the actual output for each output neuron in the network. The error value is propagated
backward through the weights of the network (adjusting the weights) beginning with the
output neurons through the hidden layer and to the input layer (as a function of the
contribution of the error).
Backpropagation continues to be an important aspect of neural network learning. With faster and
cheaper computing resources, it continues to be applied to larger and denser networks.
Uempty
1.4. What is deep learning?
Uempty
What is deep
learning?
Uempty
Deep learning
• Similar to a traditional neural network, but it has many more hidden layers.
• Deep learning has emerged now because of the following reasons:
Emergence of big data, which requires data processing scaling.
Improvement in processing power and the usage of GPUs to train neural networks.
Advancement in algorithms like the rectified linear unit (ReLU).
Deep learning is a machine learning technique that uses neural networks to learn. Although deep
learning is similar to a traditional neural network, it has many more hidden layers. The more
complex the problem, the more hidden layers there are in the model.
Deep learning has emerged now because of the following reasons:
• The continuous increase in big data requires data processing scaling to analyze and use this
data correctly.
• Improvement in processing power and the usage of GPUs to train neural networks.
• Advancement in algorithms like the rectified linear unit (ReLU) instead of the Sigmoid
algorithm helps make gradient descent converge faster.
Uempty
There are various types of neural networks. Each network is more suitable for a type of machine
learning problem. Here is an overview for these networks and their applications:
• Multilayer perceptron (MLP): A class of feed-forward artificial neural networks (ANNs). It is
useful in classification problems where inputs are assigned a class. It also works in regression
problems for a real-valued quantity like a house price prediction.
• Convolutional neural network (CNN): Takes an input as an image. It is useful for image
recognition problems like facial recognition.
• Recurrent neural network (RNN): Has a temporal nature where the input may be a function in
time, such as audio files. It is also used for one-dimensional sequence data. It is suitable for
inputs like audio and languages. It can be used in applications like speech recognition and
machine translation.
• Hybrid neural network: Covers more complex neural networks, for example, autonomous cars
that require processing images and work by using radar.
Reference:
When to Use MLP, CNN, and RNN Neural Networks
https://machinelearningmastery.com/when-to-use-mlp-cnn-and-rnn-neural-networks/
Uempty
1.5. How to evaluate a machine learning model?
Uempty
How to evaluate a
machine learning
model?
Uempty
Model evaluation
• Overfitting occurs when a machine learning model can fit the training set perfectly and fails
with unseen future data.
Reason: Too many features are used or you are reusing training samples in testing.
Solution:
í Fewer features
í More data
í Cross-validation
After you have successfully trained your model, you need a methodology to follow to evaluate
your machine learning model performance. A classic mistake is to use the same sample data that
is used in training to test a model, which produces a false perfect score. This is called “overfitting”
(also referred as “high variance”). The problem with overfitting is that your model fails at
predicting future unseen data.
Another case that can cause overfitting is where you have unbalanced data. For example, assume
that you are working on a data set for churn analysis. The customers who churned are actually 2%
of your data set. Using this data set “as is” causes overfitting.
The objective of a good machine learning model is to generalize for any future data points.
Overfitting also can occur if you are using too many features. Relatively, if the number of features
is the same as or greater than the number of training samples, that can cause overfitting. One of
the solutions to overcome overfitting is to increase the number of data set samples that is used for
training compared to features. Another solution is to manually decrease the number of features,
but that might result in removing useful information. Another solution is to perform model
selection by using cross-validation.
References:
overfitting
https://en.oxforddictionaries.com/definition/overfitting
Preventing "Overfitting" of Cross-Validation Data
https://ai.stanford.edu/~ang/papers/cv-final.pdf
The Problem of Overfitting
https://www.youtube.com/watch?v=OSd30QGMl88
Uempty
Underfitting (also referred to as “high bias”) occurs when a machine learning model cannot fit the
training data or generalize to new data.
A possible reason might be that the model is using a simple estimator. For example, you might be
using a linear estimator, but what you actually need is a quadratic or higher degree polynomial
estimator to develop your model like in “Right fit” graph.
Another reason might be that you are not using enough features, so your estimator fails to capture
the structure of the data. A possible solution would be to add more features and try a different
estimator.
There are other methods that are used to help resolve the overfitting and underfitting of your
model such as regularization, but these methods are beyond the scope of this course.
References:
overfitting
https://en.oxforddictionaries.com/definition/overfitting
The Problem of Overfitting
https://www.youtube.com/watch?v=OSd30QGMl88
Uempty
It is common practice when applying a (supervised) machine learning task is to hold out part of
the available data as a test set. There are different methods to achieve that task:
• Cross-validation (CV) is a process to evaluate a machine learning model by splitting a data set
once or several times to train and test the model. The data set can be split into a training set to
train the model and a validation set to pre-test the model. Select the model that has least
error. Finally, there is a test set to evaluate the model. Thus, the data set can be split as 60% -
20% - 20% for training, validation, and testing sets.
One criticism of this process is that splitting the data set into three parts reduces the number
of samples that can be used for training the model.
• The hold-out method partitions the data set into a majority set for training and minority set for
testing. The split of the training set to test set is 80% - 20% or 70% - 30%, with no fixed rule.
• K-fold cross validation randomly partitions data into K equal sized subsamples. For each
iteration, one subsample is kept as validation set and the rest of the subsamples (K-1) are the
training set. The iterations are repeated K times, where each subsample has one chance to be
the validation set. The K results can then be averaged to produce a single model. The biggest
advantage of K-fold is that all data is changed to be used for both training and validation.
There is no strict rule for the number K, but it is commonly K=5 or K=10, which are 5-fold
cross-validation or 10-fold cross-validation. For each subsample, you maintain approximately
the same percentage of data of each target class as in the complete set, which is known as the
Stratified K-fold method.
• Leave one out CV (LOO-CV) is similar to K-fold, but in this case each one sample data point is
held out as a validation set, and the rest of data set is the training set. Comparing LOO-CV and
K-fold, K-fold is faster and requires less computation, but in terms of accuracy, LOO-CV often
has a high variance as an estimator.
Uempty
References:
A survey of cross-validation procedures for model selection
https://projecteuclid.org/download/pdfview_1/euclid.ssu/1268143839
Cross-validation: evaluating estimator performance
http://scikit-learn.org/stable/modules/cross_validation.html
Cross Validation
https://www.cs.cmu.edu/~schneide/tut5/node42.html
Uempty
Uempty
Review questions
1. True or False: In logistic regression, the target output is a continuous value.
2. True or False: Autonomous cars are one of many applications of deep learning.
3. True or False. A perceptron is a single neuron model that is the originator for neural
networks.
4. Assume that you want to develop a learning algorithm to address the following problem: You
want to examine individual customer accounts and determine whether they have been hacked
or compromised. This should be treated as a supervised __________.
a. Classification
b. Regression
Uempty
Review answers
1. True or False: In a logistic regression, the target output is a continuous value.
The answer is False.
2. True or False: Autonomous cars are one of many applications of deep learning.
The answer is True.
3. True or False. A perceptron is a single neuron model that is the originator for neural
networks.
The answer is True.
4. Assume that you want to develop a learning algorithm to address the following problem: You
want to examine individual customer accounts and determine whether they have been hacked
or compromised. This should be treated as a supervised ___________.
a. Classification
b. Regression
The answer is a.
Uempty
Uempty
Exercise • This exercise provides the foundational concepts that you need to
understand to apply four popular machine learning algorithms:
objectives K-means clustering
Naïve Bayes classifier
Linear regression
Decision tree
• After completing this exercise, you should be able to:
Determine the centroids of a data set with the K-means clustering
algorithm.
Predict the class of an object with the Naïve Bayes classifier.
Apply the linear regression algorithm to solve supervised learning
problems.
Construct a decision tree to predict outcomes.
Uempty
Overview
This unit provides an overview of key IBM Watson services, their purpose, how they work, and it
helps you get started with Watson services on IBM Cloud.
Uempty
Uempty
Uempty
2.1. IBM Watson overview
Uempty
IBM Watson
overview
Uempty
IBM Watson
• IBM Watson is the artificial intelligence (AI) offering from IBM.
• IBM Watson has the following capabilities:
Understands all forms of data.
Interacts naturally with people.
Learns and reasons at scale.
• You do not need to know the details of every associated AI subfield.
• You must have a high-level understanding of each subfield.
• You must know how to apply the correct AI technology to the problem by using AI application
programming interfaces (APIs) or a ready-to-use AI framework.
IBM Watson is an AI system that enables a new partnership between people and computers. It is
the AI offering from IBM. Watson combines five core capabilities:
• Interacts with people more naturally based on the person’s preference.
• Quickly imports key industry materials by partnering with experts to scale and elevate
expertise.
• Enables new products and services to sense, reason, and learn about users and the world
around them.
• Uses data to improve business processes and forecasting, which increases operational
effectiveness.
• Enhances exploration and discovery, which uncovers unique patterns, opportunities, and
actionable hypotheses.
IBM Watson includes AI technologies. Those technologies are complex, and to understand them
fully requires many years of study. However, to add AI capabilities to your applications, you do not
need to know the details that are associated with each AI subfield. You must have a high-level
understanding of each subfield, for example, natural language processing (NLP) and machine
learning. Then, you must know how to apply the correct AI technology to a problem by using AI
APIs or a ready-to-use AI framework.
Uempty
Watson was named after the first CEO of IBM, Mr Thomas J. Watson.
In 2011, the Watson computer system competed on Jeopardy! a US nationally televised quiz
show, against former winners Brad Rutter and Ken Jennings. Watson won the first place prize of
$1 million. Watson had access to 200 million pages of structured and unstructured content that
filled 4 TB of disk storage, including the full text of Wikipedia.
The original Watson system that won Jeopardy! was based on a QuestionAnswering (QA) system
architecture, which was developed for Watson to play the game and which is known as the
DeepQA architecture. This system was specifically developer to answer trivia question.
DeepQA was a software architecture for deep content analysis and evidence-based reasoning. It
uses advanced natural language processing (NLP), information retrieval, reasoning, and machine
learning. In summary, DeepQA generates and scores many hypotheses by using an extensible
collection of natural language processing, machine learning, and reasoning algorithms, which
gather and weigh evidence over both unstructured and structured content to determine the
answer with the best confidence. The answer with the strongest confidence is Watson’s final
answer. DeepQA was trained in the open domain Wikipedia which is very appropriate to answer
trivia questions.
The original DeepQA architecture, designed to play the Jeopardy! game, evolved trough several
iterations to the Watson services and offerings available today. And it will continue to evolve
through the years with the major advancements in AI.
Uempty
Data, information, and expertise create the foundation for working with Watson. The figure shows
examples of data and information that Watson can analyze and learn from and derive new insights
that were never discovered before.
Uempty
IBM Watson is available as a set of services on IBM Cloud, SaaS cloud offerings, and a set of
industry solutions. Besides the core offerings, a large set of resources and documentation are
available for application developers.
The focus of this unit (and this course) is on IBM Watson services on IBM Cloud only.
Uempty
2.2. IBM Watson services on IBM Cloud
Uempty
IBM Watson
services on IBM
Cloud
This section provides an overview of the Watson services and tools available on IBM Cloud.
Uempty
Data Watson Studio Machine Learning Watson Knowledge Catalog Watson OpenScale
The figure shows the Watson services on IBM Cloud at the time of writing. These services continue
to be enhanced, some will be deprecated and replaced, and new services will be introduced in the
future.
The following services are available as REST APIs and software as a solution (SaaS) tools that
developers can use to build AI solutions or add AI features to their applications. For more
information, see https://www.ibm.com/watson/products-services/.
• AI Assistant (Chatbot): Integrate diverse conversation technologies into your application by
using Watson Assistant to build a chatbot by using intents, entities, actions and dialog trees. It
uses NLP and pattern recognition techniques.
• Data: Collect, organize, and analyze your data, and then achieve trust, scale, and automation
across your full AI lifecycle:
▪ Watson Studio: A collaborative environment with AI tools that a team can use to collect
and prepare training data, and to design, train, and deploy machine learning models.
▪ Watson Machine Learning: Enables users to perform two fundamental operations of
machine learning: training and scoring.
▪ Watson Knowledge Catalog: A machine learning data catalog that enables you to access,
curate, categorize, and share data, knowledge assets, and their relationships, wherever
they are.
▪ Watson OpenScale: Operate and automate AI at scale by infusing it with trust and
transparency, explaining its outcomes, and eliminating harmful bias.
Uempty
• Knowledge: Get insights through accelerated data optimization capabilities:
▪ Discovery: Unlock hidden value in data to find answers, monitor trends, and surface
patterns.
▪ Watson Natural Language Understanding: NLP for advanced text analysis.
▪ Knowledge Studio: Teach Watson to discover meaningful insights in unstructured text.
• Speech: Converts text and speech with the ability to customize models:
▪ Speech to Text: Easily converts audio and voice into written text.
▪ Text to Speech: Converts written text into natural-sounding audio.
• Language: Analyzes text and extracts metadata from unstructured content:
▪ Language Translator: Translates text from one language to another.
▪ Natural Language Understanding: Uses deep learning to extract data and insights from text
such as entities and keywords. Includes multi-label text classification capabilities. This
feature includes extended language support and training data customizations to better
handle your text classification needs. By using NLU, you can easily expand to several NLP
use cases, and create rich and sophisticated applications for your business and customers.
• Empathy: Understands tone, personality, and emotional state:
▪ Natural Language Understanding: Extract sentiment and emotions from text. Tone analysis
is done by using a pre-built classifications model, which provides an easy way to detect
language tones in written text. It detects seven tones: sad, frustrated, satisfied, excited,
polite, impolite, and sympathetic. People show various tones, such as joy, sadness, anger,
and agreeableness, in daily communications. Such tones can impact the effectiveness of
communication in different contexts.
Reference:
IBM Watson products
https://www.ibm.com/watson/products-services/
Uempty
Watson Assistant
• Adds a natural language interface to your application to automate interactions with your users.
• Build the conversation flow and train the service by using an easy-to-use web interface.
• Integrate Watson Assistant with other Watson services to enrich the chatbot interaction
experience.
• Example applications: Virtual agents and chatbots.
Watson Assistant
IBM Watson Assistant is a cognitive bot that you can customize for your business needs and
deploy across multiple channels to bring help to your customers where and when they need it.
You can add a natural language interface to your application to automate interactions with your
users.
Example applications include virtual agents and chat bots that can integrate and communicate on
any channel or device, including mobile devices, messaging platforms, and robots.
Train the Watson Assistant service by using an easy-to-use web interface so that you can quickly
build natural conversation flows between your apps and users and deploy scalable and
cost-effective solutions.
Uempty
Watson Discovery
• Adds cognitive search and content analytics to applications to identify patterns, trends, and
insights.
• Unlocks actionable insights into unstructured data.
• Unifies structured and unstructured data.
• Uses simple query language to eliminate the need for manual filtering of results.
• Includes the Discovery API and Discovery tooling.
• Example application: Find answers to FAQs
Watson Discovery
Add a cognitive search and content analytics engine to applications to identify patterns, trends,
and actionable insights that drive better decision-making. Rapidly build cognitive, cloud-based
exploration applications that unlock actionable insights that are hidden in unstructured data.
Securely unify structured and unstructured data with pre-enriched content and use a simplified
query language to eliminate the need for manual filtering of results.
With Discovery, you can prepare your unstructured data, create a query that will pinpoint the
information you need, and then integrate those insights into your new application or existing
solution.
The Discovery services includes:
• Discovery API: The Discovery service supports a number of SDKs to simplify the development
of applications. The SDKs are available for many popular programming languages and
platforms, including Node.js, Java, and Python.
• Discovery tooling: The Discovery service includes a complete set of online tools - the
Discovery tooling - to help you quickly setup an instance of the service and populate it with
data. The Discovery service tooling has been designed to save time by eliminating the need to
use APIs to configure and populate your service.
With Discovery you can build applications that extract the correct answers to FAQs by enriching
and searching data collections.
Uempty
Uempty
Speech to Text
• Converts human voice into the corresponding text.
• Uses machine intelligence to combine information about grammar and language structure with
knowledge of the composition of the audio signal to generate an accurate transcription.
• Provides APIs that you can use to add speech transcription capabilities to your applications.
• The languages that are currently supported are: Arabic (Modern Standard), Brazilian
Portuguese, Chinese (Mandarin), Czech, Dutch, English (Australian, United Kingdom, and
United States), French (French and Canadian), German, Hindi (Indian), Italian, Japanese,
Korean, Spanish
• Example applications:
Voice control of applications, embedded devices, and vehicle accessories
Transcribing meetings and conference calls
Dictating email messages and notes
Speech to Text
The Speech to Text service converts the human voice into the corresponding text. Use this service
to convert audio and voice into text for quick understanding of content. It can be used anywhere
there is a need to bridge the gap between the spoken word and their written form, including voice
control of embedded systems, transcription of meetings and conference calls, and dictation of
email and notes. This easy-to-use service uses machine intelligence to combine information
about grammar and language structure with knowledge of the composition of the audio signal to
generate an accurate transcription.
The following languages are currently supported: Arabic (Modern Standard), Brazilian Portuguese,
Chinese (Mandarin), Czech, Dutch, English (Australian, United Kingdom, and United States),
French (French and Canadian), German, Hindi (Indian), Italian, Japanese, Korean, Spanish
(Argentinian, Castilian, Chilean, Colombian, Mexican, and Peruvian).
Note
The list of languages is constantly updated. For the most current list of languages that are
supported, see Language support at
https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-about#about-languages
Uempty
The Speech to Text service can take an audio voice file as input and convert the audio into written
text.
This service can be used in practical applications such as these:
• Transcribe calls in a contact center to identify what is being discussed, when to escalate calls,
and to understand content from multiple speakers.
• Transcribe a technical explanation provided by a subject matter expert to help to create
documentation.
• Transcribe speech from a movie and create subtitles or captions.
• Transcribe voice mail messages to obtain a written log of messages left, for example, by
clients or patients.
• Create voice control applications, for example an automated home control system that is
based on your speech. Functions can include switching the light on and off, controlling
electronic devices, or even opening the front door remotely.
Uempty
Text to Speech
• Converts written text into natural sounding audio in various languages and voices.
• The currently available languages are Arabic, Brazilian Portuguese, Chinese (Mandarin), Czech,
Dutch, English (Australian, United Kingdom, and United States dialects), French, German,
Italian, Japanese, Korean, Spanish (Castilian, Latin American, and North American dialects),
Swedish.
• Example applications: Voice-driven and screenless applications, where audio is the preferred
method of output:
Interfaces for the disabled, such as assistance tools for the vision-impaired
Reading text and email messages aloud to drivers
Video-script narration and video voice over
Reading-based educational tools
Home-automation solutions
Text to Speech
Use the Watson Text to Speech API to convert written text into natural sounding audio in various
languages and voices. The Text to Speech service processes text and natural language to
generate synthesized audio output with the appropriate cadence and intonation.
The service supports voices in the following languages: Arabic, Brazilian Portuguese, Chinese
(Mandarin), Czech, Dutch, English (Australian, United Kingdom, and United States dialects),
French, German, Italian, Japanese, Korean, Spanish (Castilian, Latin American, and North
American dialects), Swedish. The service offers at least one male or female voice, sometimes
both, for each language.
Note
This list is updated overtime. For the most current list, see Language support at
https://cloud.ibm.com/docs/text-to-speech?topic=text-to-speech-about#about-languages
The service is appropriate for voice-driven and screenless applications, where audio is the
preferred method of output:
• Interfaces for the disabled, such as assistance tools for the vision-impaired
• Reading text and email messages aloud to drivers
• Video-script narration and video voice over
• Reading-based educational tools
• Home-automation solutions
Uempty
This service can be used in practical applications such as these:
• Create audio narration from a written script for a variety of applications, such as online
tutorials for an e-learning course, audio books, and so on.
• Provide callers with information, such as company location, store hours, and account
information that is extracted from a database or organization’s documentation and converted
to audible speech.
• Develop interactive educational material for children.
• Communicate directions, hands-free.
Uempty
Language Translator
• Identifies the language of text and translates it into different languages programmatically.
• High-quality, domain-specific text translation.
• The following domains and languages are supported:
The News domain to translate English to and from French, Spanish, Portuguese, or Arabic.
The Conversational domain to translate English to and from Spanish or Portuguese.
The Patent domain to translate Spanish, Portuguese, Japanese, or Korean to English.
• Extend provided models to learn custom terms and phrases.
• Example application: Enable a help desk representative to assist international customers
through chat.
Language Translator
This service provides high-quality and domain-specific text translation from one language to
another. It is one of the few offerings that focuses on domain-specific Statistical Machine
Translation.
The following domains and languages are supported:
• The News domain to translate English to and from French, Spanish, Portuguese, or Arabic.
• The Conversational domain to translate English to and from Spanish or Portuguese.
• The Patent domain to translate Spanish, Portuguese, Japanese, or Korean to English
You can create your own custom translation model. Most of the provided translation models in
Language Translator can be extended to learn custom terms and phrases or a general style that is
derived from your translation data.
Example application: Enable a help desk representative to assist international customers through
chat.
Uempty
Watson Studio
• Collaborative environment with AI tools to collect and prepare training data, and to design,
train, and deploy machine learning models.
• It is a SaaS solution that is delivered on IBM Cloud.
• Watson Studio AI tools support popular frameworks, including: TensorFlow, Caffe, PyTorch,
and Keras.
• The architecture of Watson Studio is centered around the project.
Watson Studio
IBM Watson Studio is a collaborative environment with AI tools that a team can use to collect and
prepare training data, and to design, train, and deploy machine learning models.
It is a SaaS solution that is delivered on IBM Cloud.
Watson Studio provides a suite of tools for data scientists, application developers, and subject
matter experts (SMEs) to work collaboratively and easily with data. They can then use that data to
build, train, and deploy models at scale. These tools are preconfigured so that builders do not
have to spend time installing, setting up, and maintaining them. The built-in catalog function
enables knowledge sharing and retention. Watson Studio can infuse AI into your business.
It enables you to analyze data by using RStudio, Jupyter, and Python in a configured and
collaborative environment that includes added value, such as managed Spark and IBM Watson
Machine Learning.
The architecture of Watson Studio is centered around the project. A project is where you organize
your resources and work with data.
Uempty
You can have these types of resources in a project:
• Collaborators are the people on the team who work with the data. Data scientist tasks include
analyzing data and building models. Data engineer tasks include preparing and integrating
data.
• Data assets point to your data that is either in uploaded files or accessed through connections
to data sources.
• Operational assets are the objects you create, such as scripts and models, to run code on data.
• Tools are the software you use to derive insights from data. These tools are included with the
Watson Studio service:
▪ Data Refinery: Prepare and visualize data.
▪ Jupyter notebook editor: Code Jupyter notebooks.
▪ RStudio: Code Jupyter notebooks in R and R Shiny apps.
▪ SPSS Modeler: Automate the flow of data through a model with SPSS algorithms.
▪ Decision Optimization model builder: Optimize solving business problem scenarios.
▪ Other project tools require additional services. See the lists of supplemental and related
services.
You can think of Watson Studio AI tools in these categories:
• Natural language classification
• Machine learning
• Deep learning
Reference:
Watson Studio on Cloud Pak for Data as a Service
https://dataplatform.cloud.ibm.com/docs/content/svc-welcome/wsl.html
Uempty
IBM Watson Machine Learning is a full-service IBM Cloud offering that makes it easy for data
scientists and developers to work together to integrate predictive analytics with their
applications.
The Watson Machine Learning service enables your organization to use the models in your
end-to-end solutions without the impact of licensing, installation, and configuration that is
required by the same products when they are installed on-premises. You can use machine
learning and deep learning models in production. Use an automated and collaborative workflow to
grow intelligent business applications easily and with more confidence.
By using Watson Machine Learning, you can build sophisticated analytical models, trained with
your own data, that you can deploy for use in applications.
Machine Learning is a service on IBM Cloud with features for training and deploying machine
learning models and neural networks:
• Interfaces for building, training, and deploying models: Python client library external link,
Command line interface, REST API external link.
• Deployment infrastructure for hosting your trained models
After you create, train, and evaluate a model, you can deploy it. When you deploy a model, you
save it to the model repository that is associated with your Watson Machine Learning service.
Then, you can use your deployed model to score data and build an application.
• Hyperparameter optimization (HPO) for training complex neural networks
You can run your experiments with HPO to easily find the best quality model. Hyperparameter
Optimization is a mechanism for automatically exploring a search space of potential
hyperparameters, building a series of models and comparing the models by using metrics of
interest. To use HPO you must specify ranges of values to explore for each hyperparameter.
Uempty
• Distributed deep learning for distributing training runs across multiple servers
Deep learning models training can be significantly accelerated with distributed computing on
GPUs.
• GPUs for faster training
IBM Watson Machine Learning deep learning simplifies the process to train models in parallel
with an on-demand graphics processing units (GPU) compute cluster that you can scale to
your specific needs.
For an overview of Watson Machine Learning, see: https://youtu.be/5kMDIBpxi_k
Uempty
Knowledge Studio
• Enables developers and domain experts to collaborate and create a machine learning model
that understands the linguistic nuances, meaning, and relationships specific to an industry or
domain.
• Provides easy-to-use tools for annotating unstructured domain literature.
• The annotations are used to create a custom machine learning model that understands the
language of the domain.
• The model can be deployed directly to Watson Natural Language Understanding and Watson
Discovery.
Uempty
Watson OpenScale
• Tracks and measures outcomes from your
AI models no matter where your models
were built or are running.
• Helps ensure that AI models are free from
bias, remain fair, can be easily explained
and understood by business users, and are
auditable in business transactions.
• Detects and helps correct the drift in
accuracy when an AI model is in
production.
IBM Watson OpenScale tracks and measures outcomes from your AI models, and helps ensure
that they remain fair, explainable, and compliant no matter where your models were built or are
running. Watson OpenScale also detects and helps correct the drift in accuracy when an AI model
is in production.
Enterprises use model evaluation to automate and put into service AI lifecycle in business
applications. This approach ensures that AI models are free from bias, can be easily explained
and understood by business users, and are auditable in business transactions. Model evaluation
supports AI models built and run with the tools and model serve frameworks of your choice.
Reference:
Validating and monitoring AI models with Watson OpenScale
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/getting-started.html?context=cpd
aas&audience=wdp
Uempty
2.3. Build with Watson
Uempty
This section provides the initial steps to get started using the Watson APIs. It also lists the key
resources available to developers.
Uempty
Figure 2-21. Building AI solutions with IBM Watson services on IBM Cloud
Watson services on IBM Cloud provide a cloud-hosted marketplace where application providers
of all sizes and industries can tap into resources for developing applications that are powered by
Watson services. Developers can combine the Watson services (and other services that are
available in IBM Cloud) with additional logic to build applications with AI capabilities.
The goal of Watson services on the IBM Cloud is to provide flexible platform for building AI
applications in industry domains. The microservices architecture enables developers to envision a
broad range of potential applications by mixing and matching services.
The available resources include developer toolkits, educational materials, and access to Watson
APIs and SaaS tools. This approach makes IBM Watson technology available as a development
platform in the cloud to enable a worldwide community of software application providers to build
a new generation of applications that is infused with Watson AI capabilities.
Uempty
One key element of AI systems is the capability to learn and adapt overtime. Rather than being
explicitly programmed, AI systems learn from their interactions with their users and from their
experiences with their environment. Machine learning gives computers the ability to learn and act
without being explicitly programmed. This means that the model gets better over time by learning
from its mistakes and new experiences (being exposed to new data). When developing machine
learning models, the models are built from a fixed source, for example, open domain Wikipedia,
and they are deployed to similar or different domains, for example the Travel domain. To improve
accuracy, the new domain data must be used to train the model. This task is known as domain
adaptation.
Like humans, AI systems must be trained to understand new domains and perform new tasks. For
example, understanding medical records to identify medical conditions and associated
prescriptions requires deep knowledge of drugs and diseases. In order to be able to perform
these tasks, humans go to college, get a medical degree and, after many years of training and
study, become doctors. Likewise, AI systems must be trained to become experts in specific
domains. Training is performed by subject matter experts (SMEs) providing human supervision
and domain-specific knowledge bases representing entities and relations of interest for the new
domain. A similar process must be followed to apply Watson technology to specific domains.
Domain adaptation consists of the necessary activities to adapt an open-domain system to a
specific domain (a closed-domain).
Information extraction analytics that are provided by Watson APIs are open domain, which means
that they can recognize named entities that belong to basic types, such as company, person, and
location, but they cannot recognize more specific distinctions, such as names of banks, insurance
companies, and their products.
To become an SME in a specific industry or domain, some Watson services must be trained.
Uempty
Uempty
• Speech to Text: This service can be customized for a particular domain by creating a language
model to provide the nuances in that domain in terms of vocabularies and word
pronunciations. By training the service, you can improve the accuracy of speech recognition
for domains such as medicine, law, information technology, and others.
• Text to Speech: This service provides a customization interface so that you can create a
dictionary of words and their translations for a specific language. This dictionary of words and
their translations is referred to as a custom voice model.
• Machine Learning. This service includes features for training and deploying machine learning
models and neural networks. With Machine Learning, you can build, train, deploy, and manage
machine learning and deep learning models.
• Watson OpenScale. This service tracks and measures outcomes from your AI models, and
helps ensure they remain fair, explainable, and compliant no matter where your models were
built or are running. Watson OpenScale also detects and helps correct the drift in accuracy
when an AI model is in production.
Knowledge Studio: Knowledge Studio is used as a tool to train other services. This service is used
to train Watson with the language of your domain by using custom machine learning models that
identify entities and relationships that are unique to your industry in unstructured text. You can
deploy a Watson Studio model to a Natural Language Understanding service or a Discovery service
References:
Deploying models with Watson Machine Learning
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-overview.html?context=
cpdaas&audience=wdp
Training and deploying machine learning models in notebooks
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-notebook_local.html?au
dience
Create a Training Run
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml_dlaas_working_with_ne
w_models.html?audience=wdp
End-to-end example for running a deep learning training run
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml_dlaas_e2e_example.ht
ml?audience=wdp
Validating and monitoring AI models with Watson OpenScale
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/getting-started.html?context=cpd
aas&audience=wdp
Formatting and uploading training data in Watson OpenScale
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=openscale-formatting-uploading-t
raining-data
Uempty
To get started with Watson services on IBM Cloud, you must complete these steps before you can
use the service in your applications:
1. Set up your IBM Cloud account.
2. Find and select the Watson service that you need from the IBM Cloud catalog.
3. Create a service instance. IBM Cloud provides resources to your applications through a service
instance.
4. Get service credentials. You need the service credentials to authenticate to your service
instance from your application.
5. Start coding your application and calling the Watson APIs to infuse AI capabilities into your
app.
Uempty
Watson SDKs
• Enable developers to use Watson REST APIs in their favorite programming language.
• Developers should consider using the SDKs instead of calling the REST APIs directly.
• Watson SDKs supported by IBM:
Android SDK, Java SDK, Node.js SDK, Python SDK, Ruby SDK, Salesforce SDK, Swift SDK, .NET SDK,
OpenWhisk SDK, and Unity SDK
• Watson SDKs from the Watson community of developers:
Go SDK, PHP SDK, Ruby wrappers, Scala SDK
Uempty
Uempty
Uempty
Review questions
1. Enables applications to use natural language to automatically respond to user questions:
a. Natural Language Understanding
b. Watson Assistant
c. Watson OpenScale
d. Discovery
e. Speech to Text.
2. Provides tools that SMEs can use to annotate unstructured domain literature and uses those
annotations to create a custom machine-learning model that understands the language of the
domain.
a. Watson Studio
b. Machine Learning
c. Knowledge Studio
d. Watson Health
Uempty
Uempty
b. Watson OpenScale
c. Knowledge Studio
e. Machine learning
Uempty
Review answers
1. Enables applications to use natural language to automatically respond to user questions:
a. Natural Language Understanding
b. Watson Assistant
c. Watson OpenScale
d. Discovery
e. Speech to Text
2. Provides tools that SMEs can use to annotate unstructured domain literature and uses those
annotations to create a custom machine-learning model that understands the language of the
domain.
a. Watson Studio
b. Machine Learning
c. Knowledge Studio
d. Watson Health
Uempty
Uempty
b. Watson OpenScale
c. Knowledge Studio
e. Machine learning
Uempty
Uempty
Exercise • This exercise introduces you to Watson REST APIs. You use
Postman and optionally cURL to submit requests to and receive
objectives responses from the following Watson services:
Natural Language Understanding
Language Translator
• After completing this exercise, you should be able to:
Create Watson service instances.
Copy credentials from a service instance.
Submit API calls with the appropriate parameters.
Analyze the response that is returned from the Watson service.
Use Watson API reference documentation.
After completing this exercise, you should be able to accomplish the following tasks:
• Create Watson service instances.
• Copy credentials from a service instance.
• Submit API calls with the appropriate parameters.
• Analyze the response that is returned from the Watson service.
• Use Watson API reference documentation.
Uempty
Overview
This unit provides a high level overview of IBM Watson Studio, its components, key applications
and the value added by the IBM offering.
Uempty
Uempty
Uempty
3.1. Watson Studio overview
Uempty
Watson Studio
overview
Uempty
Watson Studio is a collaborative platform for working on data. The collaborative platform
enables the users, whether they are data scientists, data engineers, or application developers to
share resources and work together seamlessly within the platform.
Watson Studio contains some open-source components such as Python, Scala, R, and Jupyter
notebooks, and IBM added value components such as Watson Machine Learning, SPSS Modeler,
Decision Optimization, AutoAI, and more.
References
Watson Studio on Cloud Pak for Data as a Service
https://dataplatform.cloud.ibm.com/docs/content/wsj/landings/wsl.html
Uempty
Data Engineer
OUTPUT INPUT Designs how data is organized
and ensures operability.
Deliver and Understand
Deploy Model. Problem and
Domain.
Data Scientist
Communicate Import Goes deep into the data to draw
Results. Data. hidden insights for the business.
Watson Studio
Transform:
Evaluate App Developer
Transform: Clean.
. Plugs into data and models and
Shape. writes code to build apps.
IBM Cloud
ANALYSIS
Open-source tools give you a wide range of choices. The downside of having too many choices is
knowing the correct one to choose. Essentially, you want to pick the correct tool for the correct
job. Watson Studio is no exception.
Watson Studio is designed for a specific persona, but other personas can use it as it relates to
their jobs.
Look at the diagram on the slide. Starting from the top and going clockwise, you have the input,
analysis, and output phases. Within each phase are the objectives of that phase. Each objective
can overlap between various user personas.
Look at the list of personas on the right side: the data engineer, the data scientist, the business
analyst, and the app developer. Each persona has primary tools that help them do their job. For
example, the data scientist's main tool is Watson Studio.
Also, a team might include different personas. Whatever the case is, you must decide what tool is
correct for the job, regardless of the personas. The definitions of personas can vary between
different companies and evolve over time.
Uempty
In addition to the tailored interface of Watson Studio, collaboration ties the team and the
organization together by enabling them to share projects, code, and ideas. Imagine a data
engineer builds a new data source and shares that asset with the data scientist and the business
analyst. The business analyst immediately builds the reports and dashboards that they need. The
data scientist experiments with the data and builds a model that passes all the tests and can be
used with new applications. The team can immediately share that model with the application
developer, who deploys a new application by using the model. As this project progresses, the
team members update and share their statuses with the team, asking questions and sharing ideas
or requirements.
In this scenario, data and analytics development become a team effort and is no longer done in
silos. Additionally, because these assets can be published, other departments can reuse these
assets, making the entire organization more agile.
Uempty
Retail Transportation
Shopping experience End-to-end customer experience
Loss & fraud prevention Operations planning & optimization
Task & workforce optimization Predictive maintenance
Pricing & assortment optimization Route and asset optimization
Banking Media and Entertainment
Optimize offers & cross-sell Audience & fan insight
Risk management Social media insight
Fraud and crime management Content demand forecasting
Financial performance Marketing & advertising optimization
Manufacturing Telco
Inventory optimization Subscriber analytics
Predictive maintenance IOT analytics
Health, safety, & environment Proactive marketing
Production planning and scheduling Network design
Data science spans multiple industries, but you can see that data analysis that is applied to some
of these use cases is not entirely new. In fact, organizations have been doing these types of
activities for many years. The advantage that you have with Watson Studio is that you can easily
collaborate with other data scientists by using well-known tools that are widely used in the
industry.
Uempty
Note
Exercises of this course use Watson Studio on CP4DaaS (on IBM Cloud).
Uempty
References
Watson Studio on CP4DaaS
https://dataplatform.cloud.ibm.com/docs/content/getting-started/overview-ws.html
Watson Studio on CP4D
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=services-watson-studio
Comparison between Cloud Pak for Data as a Service and Cloud Pak for Data 4.0
https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/compare-cpd.html
Overview of Watson Studio Desktop
https://www.ibm.com/docs/en/wsd?topic=overview
Uempty
Watson Studio is designed for 24x7 availability, that is, continuous delivery and availability.
Features and updates are rolled out without downtime. Notebooks in Watson Studio are stored in
a three-way Cloudant cluster in multiple geographic zones. Watson Studio also provides
integration with GitHub so that you can manually download the notebooks if you want to use your
own backups.
Uempty
3.2. Watson Studio components
Uempty
Watson Studio
components
Uempty
Projects
• The architecture of Watson Studio is centered around the project.
• Integrate collaborators, data and analytic assets, tools, Gallery resources, your own data, and
so on to support finding insights for a well defined or narrow goal.
Uempty
References
Watson Studio on Cloud Pak for Data as a Service
https://dataplatform.cloud.ibm.com/docs/content/svc-welcome/wsl.html
Uempty
Creating a project
• When you create a project in Watson Studio, you can create an empty project or preload your
project with data and operational assets.
When you create a project in Watson Studio, you can create an empty project or preload your
project with data and analytical assets:
• Create an empty project: Add the data that you want to prepare, analyze, or model. Choose
tools based on how you want to work: write code, create a flow on a graphical canvas, or
automatically build models.
• Create a project from a sample or file: Get started fast by loading existing assets. Choose a
project file from your system or choose a curated sample project.
Uempty
Cloud Object Storage provides the space where non-database data for your project is stored.
For example, files, notebooks, experiments, and Data Refinery flows can be stored in COS.
An IBM Cloud Object Storage instance can be created at project creation time, or a new project
can be associated with an existing Cloud Object Storage instance.
Cloud Object Storage supports two APIs:
• The Swift API, which is available through Watson Studio.
• The S3 API, where you provide external credentials.
Information that is stored with IBM Cloud Object Storage is encrypted and resilient.
Cloud Object Storage uses buckets to organize the data. Each project has its own dedicated
bucket.
The Cloud Object Storage can be managed from the Watson Studio project interface.
Uempty
Projects include integration with IBM Cloud Object Storage for storing project assets. When a
project is created, a new Cloud Object Storage service is created to provide an unstructured cloud
data store. It is also possible to associate a project with an existing Cloud Object Storage.
To create a new project:
1. Click + New.
2. Enter a name for the project.
3. In the Define storage pane, click Add.
4. Click Refresh.
5. The Cloud Object Storage service page with the New tab selected is displayed. Click Create.
6. Click Refresh in the project page.
7. The newly created Cloud Object Storage instance is associated with the project.
8. Click Create to create the project.
Uempty
The Watson Studio project page includes tabs with specific information about the project. The
following tabs are included:
Overview. Provides basic information about the project such as:
• Assets
• Resource usage
• Project history
• Readme
Assets. Lists all the different types of assets that you can add to you project such as:
• Data assets
• Models
• Notebooks
• Dashboards
• Experiments
• Modeler flows
Uempty
Jobs. A job is a way of running assets, such as Data Refinery flows or notebooks in a project in
Watson Studio.
From the Jobs tab of your project, you can:
• See the list of the jobs in your project
• View the details of each job. You can change the schedule settings of a job and pick a different
environment definition.
• Monitor job runs
• Create job
• Delete jobs
Reference:
Working in projects
https://dataplatform.cloud.ibm.com/docs/content/wsj/manage-data/manage-projects.html.
Uempty
General. Project settings is the area to define key aspects of your project like its name and
description. Use Settings to add tools and key services, check storage, and define access tokens.
Access Control. Here you can add and manage collaborators for your project.
Environments. In this tab, you can define the hardware size and software configuration for the
runtime that is associated with Watson Studio tools. An environment definition defines the
hardware and software configuration that you can use to run tools like notebooks, model builder,
or the flow editor in Watson Studio. With environments, you have dedicated resources and flexible
options for the compute resources that are used by the tools.
Resource usage. Contains resource usage details.
Services & integrations: Shows IBM Cloud services and third-party services associated with this
project.
Uempty
Assets
• An asset is an artifact
in a project that
contains information,
or metadata, about
data or data analysis.
An asset is an artifact in a project that contains information, or metadata, about data or data
analysis.
Data assets are the types of assets that point to data, for example, a file or a data set that is
accessed through a connection to an external data source.
Analytical assets are the types of assets that run code to analyze data.
An asset might have associated files or require specific IBM Cloud services. For example, many
types of analytical assets require a service.
The information that you can view about an asset and the actions that you can perform on an asset
vary by asset type. A few actions apply to all asset types, for example, you can create, edit the
properties of, and remove or delete all types of assets. You can edit the contents of most types of
assets in projects. For data assets that contain relational data, you can shape and cleanse the
data with the Data Refinery tool. For analytical assets, you can edit the contents in the appropriate
editor tool. In catalogs, you can edit only the metadata for the asset.
A new project has no assets. By default, the Data assets type is added with all project starters. To
add other asset types to your project, click New asset +.
Reference:
Asset types and properties
https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/assets.html
Uempty
The Watson Studio Gallery is a great place to get started. In the Gallery you can find open data
sets that are ready to use, including local, state, and government data. You just download the data
set and load it into your project.
The Gallery includes sample data sets and notebooks that apply to various topics such as
transportation, science and technology, health, law and government, economy and business, and
many more. You can add the data set or notebook to your project.
When you sig n into Watson Studio, scroll down in the home page to see the content that is most
recently added to the Gallery. You can click Explore to browse the Gallery content from here.
Alternatively, you can use the menu to go directly to the Gallery area where you find data sets and
notebooks.
Uempty
Collaborating in a project
• Project collaborators share knowledge and resources.
• Admin role is required to manage collaborators (add, remove, and edit).
• Collaborators are added at the project level.
• Only collaborators in a project can access the project’s data and notebooks assets.
After you create a project, add collaborators to share knowledge and resources.
Project collaborators share knowledge and resources and help one another complete jobs. You
must have the Admin role in the project to manage collaborators.
Only the collaborators in your project can access your data, notebooks, and other assets.
Collaborators can be removed from a project or have their permissions changes.
To add collaborators to your project:
1. From your project, click the Manage>Access Control tab, and then click Add collaborators.
2. Add the collaborators who you want to have the same access level:
▪ Type email addresses into the Find users field.
3. Choose the access level for the collaborators and click Add:
▪ Viewer: View the project.
▪ Editor: Control project assets.
▪ Admin: Control project assets, collaborators, and settings.
4. Add more collaborators with the same or different access levels.
5. Click Add.
Uempty
If the added users have existing IBM Cloud accounts with Watson Studio activated, they are
added to your project immediately.
If an added user does not have an IBM Cloud account, the user receives an email invitation to
create an IBM Cloud account and activate Watson Studio. When the user activates Watson Studio,
the user can see your project and the user's status on your collaborators list changes
from Invited to Active. If necessary, you can resend or cancel an invitation.
Reference:
Project collaborators
https://dataplatform.cloud.ibm.com/docs/content/wsj/getting-started/collaborate.html
Uempty
Apache Spark is an open-source distributed cluster computing framework that is optimized for
extremely fast and large-scale data processing. Spark provides a core data processing engine.
Several libraries for SQL, machine learning, graph computation, and stream processing that is run
on Spark and can be used together in an application. To learn more about Apache Spark, see
documentation and examples at spark.apache.org.
All Watson Studio users can create Spark environments with varying hardware and software
configurations. Spark environments offer Spark kernels as a service (SparkR, PySpark, and Scala).
Each kernel gets a dedicated Spark cluster and Spark executors. Spark environments are offered
under Watson Studio and like default environments, consume capacity unit hours (CUHs) that are
tracked.
References
Predefined software specifications
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/pm_service_supported_fra
meworks.html
Uempty
Uempty
3.3. Jupyter notebooks
Uempty
Jupyter notebooks
Uempty
A Jupyter notebook is a web-based environment for interactive computing. You can run small
pieces of code that process your data, and you can immediately view the results of your
computation. Notebooks include all of the building blocks that you need to work with data:
• The data
• The code computations that process the data
• Visualizations of the results
• Text and rich media to enhance understanding
From markdown and live code to visualizations, notebooks include all of the building blocks you
need to work with data and enhance your understanding.
You can use notebooks to add formatted text around executable code to describe what is being
done and show the result, including graphics, concurrently.
Another popular environment for data science, statistical analysis, and graphic representation is
provided by the R language. Watson Studio includes RStudio for people that prefer the R
development environment.
Uempty
Parts of a notebook
• Menu bar and toolbar
• Action bar
The menu bar controls most of the operations and settings for the notebook. Simple and common
functions are supported through the menu bar.
From the action bar, you can select features that enhance notebook collaboration. From the
action bar, you can:
• Publish your notebook as a gist or to GitHub.
• Create a permanent URL so that anyone with the link can view your notebook.
• Schedule to run your notebook at a specific time.
• Add a project token so that code can access the project resources.
• View your notebook information. Change the name of your notebook by editing it in
the Name field. If your notebook runs in an environment, you can view the environment
details and runtime status.
• Save versions of your notebook.
• View and add data sources.
• Post comments to project collaborators.
• Integrate data into your notebook.
• Find resources in the Gallery, for example, useful data sets.
Uempty
Cells in a Jupyter notebook
A Jupyter notebook consists of a sequence of cells. The flow of a notebook is sequential. You
enter code into an input cell, and when you run the cell, the notebook executes the code and
prints the output of the computation to an output cell.
You can change the code in an input cell and re-run the cell as often as you like. In this way, the
notebook follows a read-evaluate-print loop paradigm. You can choose to use tags to describe
cells in a notebook.
The behavior of a cell is determined by a cell’s type. The types of cells include:
• Code cells: They are the cells where you edit and run the code. The output of the cell appears
beneath the cell. Tags can be used to describe the cell for code readability and maintainability.
Cells can be rerun as often as you like.
• Markdown cells are used to document and comment the process. You can use markdown cells
to structure your notebook by using the markdown language. Images and file attachments can
be added to the notebook by using the markdown cells.
Uempty
Creating notebooks
• Must have a project and a Spark service or environment.
• Options to create a Jupyter notebook:
Blank, from a file, from a URL
Copy sample notebook from the Gallery
• Specify a name for the notebook.
If your notebook includes Spark APIs, or you want to create machine learning models or model
flows with Spark runtimes, you need to associate the tool with a Spark service or environment.
With Spark environments, you can configure the size of the Spark driver and the size and number
of the executors.
When the project is set up, you can create the notebook by using one of these ways:
• Blank
• From a file
• From a URL
You must specify a name for your notebook. You can create a notebook by importing a Python,
Scala, or R notebook file (.ipynb) from your local workstation. You can also create a notebook from
a URL by providing the URL.
Alternatively, you can copy a sample notebook from the Gallery to help you get started.
Uempty
Uempty
Copy a sample notebook from the Gallery
Sample notebooks from the Gallery are based on real-world scenarios and contain many useful
examples of computations and visualizations that you can adapt to your analysis needs.
To copy a sample notebook:
1. Click Gallery from the Watson Studio menu, then filter for Notebooks to show only notebook
cards.
2. Find the card for the sample notebook that you want and click the card. You can view the
notebook contents to browse the steps and the code that it contains.
3. To work with a copy of the sample notebook, click the Copy icon. The New Notebook screen
opens.
4. Choose the project for the notebook.
5. Specify the runtime environment. After you create an environment definition on
the Environments page of your project, it appears in the list of runtimes that you can select
when you create the notebook.
6. Click Create Notebook. The notebook opens in edit mode.
Uempty
Uempty
5. Visualize the data. Use visualizations in your notebooks to present data visually to help
identify patterns, gain insights, and make decisions. Many of your favorite open source
visualization libraries, such as matplotlib, are pre-installed on Watson Studio. All that you have
to do is import them.
Uempty
Uempty
Review questions
1. True or False: Watson Studio is designed only for the data scientist persona.
2. True or False: Object storage provides the space where unstructured data for your project is
stored.
4. True or False: Collaboration within Watson Studio is an optional add-on component that
must be purchased.
5. True or False: Watson Studio Gallery provides access to sample notebooks and data sets
that you can use.
Uempty
Review answers
1. True or False: Watson Studio is designed only for the data scientist persona.
2. True or False: Object storage provides the space where unstructured data for your project is
stored.
4. True or False: Collaboration within Watson Studio is an optional add-on component that
must be purchased.
5. True or False: Watson Studio Gallery provides access to sample notebooks and data sets
that you can use.
1. True or false: Watson Studio is designed only for the data scientist persona.
False: The data engineer, the data scientist, the business analyst, and the app developer. Each
persona has primary tools that help them do their job. For example, the data scientist's main
tool is Watson Studio but other personas can use it as it relates to their jobs. . Also, there
might be a team of different personas. Whatever the case is, you must decide what tool is
correct for the job, regardless of the personas. The definitions of personas can vary between
different companies and evolve over time.”
2. True or False: Object storage provides the space where unstructured data for your project is
stored.
3. True or False: Collaborators can be given certain access levels.
True: “Add collaborators to your project by using their email addresses. If they have an
existing account on IBM Cloud, they are added immediately. Otherwise, they receive an invite
to create a Watson Studio account. Choose the permissions for each collaborator. The Admin
role can control project assets, collaborators, and settings. The Editor role can control project
assets. The Viewer role can view the project. Collaborators can be removed from a project or
have their permissions updated.”
4. True or False: Collaboration within Watson Studio is an optional add-on component that must
be purchased.
False: “Collaboration is a standard feature in Watson Studio.”
5. True or False: Watson Studio Gallery provides access to sample notebooks and data sets that
you can use.
True: “Watson Studio Gallery is a place where you can find and use open data sets that are
ready to use, including local, state, and government data. You download the data set and load
it into your project. If you are working within a notebook, you can add the data set to the
Uempty
project. Gallery is a great place to get started if you are exploring the data science space.
There are sample notebooks to get you started or to learn about new libraries and use cases.”
Uempty
Uempty
Exercise • This exercise introduces you to the basic tasks that you will perform
when using Watson Studio.
objectives
• After completing this exercise, you should be able to:
Create a Watson Studio project.
Manage the project.
Assign collaborators.
Load a data set into the project’s object store.
Manage Cloud Object Storage.
Analyze data by using Watson Studio.
Use scikit-learn for linear regression.
Uempty
Overview
This unit provides an overview of the Cross-Industry Standard Process for Data Mining
(CRISP-DM) and explains the process of preparing data for machine learning. It provides an
overview of the Watson Machine Learning service available on IBM Cloud and the AutoAI tool
available in Watson Studio.
Uempty
Unit objectives • Describe the Cross-Industry Standard Process for Data Mining
(CRISP-DM) process model.
• Describe the phases of data preparation.
• Describe Watson Machine Learning features and capabilities.
• Explain the value of the AutoAI tool and its use.
Uempty
Uempty
4.1. Cross-Industry Standard Process for Data
Mining
Uempty
Cross-Industry
Standard Process
for Data Mining
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
CRISP-DM is an industry-proven way to guide your data mining efforts. It is the most widely used
analytics model. It describes common approaches that are used by data mining experts.
As a methodology, it includes descriptions of the typical phases of a project, the tasks that are
involved with each phase, and an explanation of the relationships between these tasks.
As a process model, CRISP-DM provides an overview of the data mining lifecycle. In a nutshell, it
consolidates preferred practices.
References
CRISP-DM - Step-by-step data mining guide
https://www.semanticscholar.org/paper/CRISP-DM-1.0%3A-Step-by-step-data-mining-guide-C
hapman-Clinton/54bad20bbc7938991bf34f86dde0babfbd2d5a72
Uempty
CRISP-DM lifecycle
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
The lifecycle model consists of six phases with arrows indicating the most important and frequent
dependencies between phases. The sequence of the phases is not strict. In fact, most projects
move back and forth between phases as necessary.
It starts with business understanding, and then moves to data understanding, data preparation,
modelling, evaluation, and deployment.
The CRISP-DM model is flexible and can be customized easily. For example, if your organization
aims to detect money laundering, it is likely that you examine large amounts of data without a
specific modelling goal. Instead of modelling, your work focuses on data exploration and
visualization to uncover suspicious patterns in financial data.
In such a situation, the modelling, evaluation, and deployment phases might be less relevant than
the data understanding and preparation phases. However, it is still important to consider some of
the questions that are raised during these later phases for long-term planning and future data
mining goals.
Reference:
CRISP-DM Help Overview
https://www.ibm.com/docs/en/spss-modeler/18.2.0?topic=dm-crisp-help-overview
Uempty
Phases in CRISP-DM
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
4.2. Data preparation
Uempty
Data preparation
Uempty
Data preparation
• The process of preparing data for a machine learning algorithm has the following phases:
Data selection
Data preprocessing
Data transformation
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Machine learning algorithms depend highly on the quality and quantity of data. You must provide
these algorithms with the correct data. Data preparation is a large subject that can involve many
iterations, exploration, and analysis. Becoming proficient at data preparation will make you a
master at machine learning.
This section covers the basic tasks of the data preparation process: data selection, data
preprocessing, and data transformation.
References
What Is Data Processing: Cycle, Types, Methods, Steps and Examples
https://www.simplilearn.com/data-preprocessing-tutorial
How to Prepare Data For Machine Learning
https://machinelearningmastery.com/how-to-prepare-data-for-machine-learning
Uempty
Data selection
• Think about:
What data is available, what data is missing, and what data can be removed?
Is the selected sample an accurate representation of the entire population?
Is more data better?
This step is concerned with selecting a subset of all the available data with which you are working.
Consider what data is available, what data is missing, and what data can be removed.
Make some assumptions about the data that you require and record those assumptions. Ask
yourself:
• What data is available? For example, through which media, such as database tables or other
systems? Is it structured or unstructured? Make sure that you are aware of everything that you
can use.
• What data is not available, and what data do you want to get? For example, data that is not or
cannot be recorded. Can you develop or simulate this data?
• What data can be removed (because it does not address the problem)? Document which data
you excluded and why.
It is common to think that the more data we have the better result we get, but this is not
necessarily true. According to the paper "Scaling to Very Very Large Corpora for Natural Language
Disambiguation" by Microsoft Researchers Banko and Brill [2001] [1], for a problem, different
algorithms perform virtually the same and the accuracy increases when adding more data (in this
case, words). But, for large amounts of data, the improvements start to become negligible.
Uempty
References
Scaling to Very Very Large Corpora for Natural Language Disambiguation
http://www.aclweb.org/anthology/P01-1005
Phase 3 of the CRISP-DM Process Model: Data Preparation
https://www.dummies.com/programming/big-data/phase-3-of-the-crisp-dm-process-model-dat
a-preparation/
What Is Data Processing: Cycle, Types, Methods, Steps and Examples
https://www.simplilearn.com/data-preprocessing-tutorial
How to Prepare Data For Machine Learning
https://machinelearningmastery.com/how-to-prepare-data-for-machine-learning/
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Selecting the correct size of the sample is a key step in data preparation. Samples that are too
large or too small might give skewed results.
Sampling noise: Smaller samples cause sampling noise because they are trained on
non-representative data.
Sampling bias: A sample is biased if certain samples are underrepresented or overrepresented
relative to others in the population. Larger samples work well if there is no sampling bias, that is,
when the correct data is picked.
References
What Is Data Processing: Cycle, Types, Methods, Steps and Examples
https://www.simplilearn.com/data-preprocessing-tutorial
Uempty
Unrepresentative
Samples
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
A good sample is representative, meaning that each sample point represents the attributes of a
known number of population elements. The bias that results from an unrepresentative sample is
called selection bias. There are various types of bias in surveys, such as undercoverage,
non-response bias, and voluntary response bias. To explain these types, assume that you want to
conduct a survey about customers and their purchase preferences:
• Undercoverage: Undercoverage occurs when some members of the population are
inadequately represented in the sample. For example, when a minority is underrepresented in
a sample, this situation can affect the validity of the sample. In this example, assume that you
underrepresented the customers who have a low income.
• Non-response bias: Sometimes, members that are chosen for the sample are unwilling or
unable to participate in the survey. Non-response bias is the bias that results when
respondents differ in meaningful ways from non-respondents. This bias can affect the validity
of the sample. Non-response bias is a common problem with mail surveys because the
response rate is often low, making mail surveys vulnerable to non-response bias.
• Voluntary response bias: This bias occurs when sample members are
self-selected volunteers, as in voluntary samples. When this happens, the resulting sample
tends to over represent individuals who have strong opinions.
References
Survey sampling
https://en.wikipedia.org/wiki/Survey_sampling
Bias Due to Unrepresentative Samples
https://sites.google.com/site/apstatisticssurveys/bias-in-surveys/bias-due-to-unrepresentative-
samples
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
The following list summarizes the steps that are used in preprocessing data:
1. Data cleaning: Complete missing values, smooth noisy data, identify or remove outliers, and
resolve inconsistencies.
2. Data integration: Using multiple databases, other data sources, or files.
3. Data sampling: You can take a smaller representative sample of the selected data that might
be much faster for exploring and prototyping solutions before considering the whole data set.
4. Data dimensionality reduction: Reducing the dimensions of the data and producing the same
or similar analytical results. This is a kind of data compression that uses less memory or disk
space and speeds the learning algorithm. For example, assume that you have a feature for size
in centimeters and another feature for size in inches. By removing one of those redundant
features, you reduce the dimensions of your data from 3D to 2D.
5. Data formatting: The data that you selected might not be in a format that is suitable for you to
use. For example, the data might be in a relational database and you want it in a
comma-separated file.
References
Machine Learning(ML) — Data Preprocessing
https://medium.com/datadriveninvestor/machine-learning-ml-data-preprocessing-5b346766fc
48
How to Prepare Data For Machine Learning
https://machinelearningmastery.com/how-to-prepare-data-for-machine-learning/
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Data transformation (also called feature engineering) is a set of actions that covers transformation
of the processed data. Engineering features from your data can take some time, but they can
enhance the machine learning performance. There are three common data transformations:
• Scaling: The pre-processed data might contain attributes with a mixture of scales for various
quantities, such as meters, grams, and dollars. The features should have the same scale, for
example, 0 (smallest value) to 1 (largest value).
• Aggregation: There might be features that can be aggregated into a single feature, which is
more meaningful to the problem that you are trying to solve.
• Decomposition: There might be complex features where it is more useful to split into parts.
For example, a feature that represents a date and time stamp in a long format can be split out
further into only the hour of the day. Think about what your problem really needs.
References
Machine Learning(ML) — Data Preprocessing
https://medium.com/datadriveninvestor/machine-learning-ml-data-preprocessing-5b346766fc
48
How to Prepare Data For Machine Learning
https://machinelearningmastery.com/how-to-prepare-data-for-machine-learning/
Uempty
4.3. Watson Machine Learning
Uempty
Watson Machine
Learning
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Machine Learning is a service on IBM Cloud with features for training and deploying machine
learning models and neural networks. To design, train, and deploy machine learning models in
IBM Watson Studio, you must associate a Watson Machine Learning service instance and
supporting services (such as IBM Cloud Object Storage) with a project.
Machine Learning enables users to perform two fundamental operations of machine learning:
training and scoring.
• Training is the process of refining an algorithm so that it can learn from a data set. The output
of this operation is called a model. A model encompasses the learned coefficients of
mathematical expressions.
• Scoring is the operation of predicting an outcome by using a trained model. The output of the
scoring operation is another data set containing predicted values.
References
Deploying models with Watson Machine Learning
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-overview.html
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Data scientists create machine learning pipelines that use data transformations and machine
learning algorithms. They typically use Notebooks or external tools to train and evaluate their
models. Data scientists often collaborate with data engineers to explore and understand the data.
Developers build intelligent applications that use the predictions that are output by machine
learning models.
References
Deploying models with Watson Machine Learning
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/ml-overview.html
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Data scientists can use Jupyter notebooks to load and process data, create and deploy Watson
Machine Learning models.
You can use a notebook to create or use a machine learning model. You can use the notebook to
write the code and implement the machine learning API. After the model is created, trained, and
deployed you can run the deployed model in a notebook.
With SPSS Modeler flows in Watson Studio, you can quickly develop predictive models by using
business expertise and deploying them into business operations to improve decision making.
These flows are designed around the long-established SPSS Modeler client software and the
industry-standard CRISP-DM model.
You can create a machine learning flow, which is a graphical representation of a data model, or a
deep learning flow, which is a graphical representation of a neural network design, by using the
SPSS modeler (Flow Editor). Use it to prepare or shape data, train or deploy a model, or transform
data and export it back to a database table or file in IBM Cloud Object Storage.
You can also create a machine learning model with Apache Spark MLlib nodes by adding the
Modeler flow asset type to your project and then selecting SparkML as the flow type.
References
Notebooks
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/notebooks-parent.html
Creating SPSS Modeler flows
https://dataplatform.cloud.ibm.com/docs/content/wsd/spss-modeler.html
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
The AutoAI graphical tool in Watson Studio automatically analyzes your data and generates
candidate model pipelines that are customized for your predictive modeling problem. These
model pipelines are created over time as AutoAI analyzes your data set and discovers data
transformations, algorithms, and parameter settings that work best for your problem setting.
Results are displayed on a leaderboard, showing the automatically generated model pipelines
that are ranked according to your problem optimization objective.
The next topic covers the AutoAI tool in more detail.
Uempty
Exercise 4 – Section 1: Getting started with Watson Machine
Learning
Figure 4-21. Exercise 4 – Section 1: Getting started with Watson Machine Learning
Uempty
Exercise • This exercise introduces you to the basic tasks that you have to
perform while building machine learning models using the Machine
objectives Learning service and Watson Studio.
• After completing this exercise, you should be able to:
Add a machine learning model that is saved in Predictive Model Markup
Language (PMML) format to the project.
Deploy the machine learning model.
Test the machine learning model.
Uempty
4.4. AutoAI
Uempty
AutoAI
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
The AutoAI graphical tool in Watson Studio automatically analyzes your data and generates
candidate model pipelines that are customized for your predictive modeling problem. These
model pipelines are created over time as AutoAI analyzes your data set and discovers data
transformations, algorithms, and parameter settings that work best for your problem setting.
Results are displayed on a leaderboard, showing the automatically generated model pipelines
that are ranked according to your problem optimization objective.
Types of prediction problems are:
▪ Binary classification
▪ Multiclass classification
▪ Regression
▪ Time series forecast
Reference:
AutoML – IBM AutoAI
https://www.ibm.com/cloud/watson-studio/autoai
Uempty
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
AutoAI automatically runs the following tasks to build and evaluate candidate model pipelines:
Data pre-processing
AutoAI applies various algorithms, or estimators, to analyze, clean, and prepare your raw data for
machine learning. It automatically detects and categorizes features based on data type, such as
categorical or numerical. Depending on the categorization, it uses hyperparameter optimization to
determine the best combination of strategies for missing value imputation, feature encoding, and
feature scaling for your data.
Automated model selection
AutoAI uses a novel approach that enables testing and ranking candidate algorithms against small
subsets of the data, gradually increasing the size of the subset for the most promising algorithms
to arrive at the best match. This approach saves time without sacrificing performance. It enables
ranking many candidate algorithms and selecting the best match for the data.
Automated feature engineering
Feature engineering attempts to transform the raw data into the combination of features that best
represents the problem to achieve the most accurate prediction. AutoAI uses a novel approach
that explores various feature construction choices in a structured, non-exhaustive manner while
progressively maximizing model accuracy by using reinforcement learning. This process results in
an optimized sequence of transformations for the data that best match the algorithms of the
model selection step.
Uempty
Hyperparameter optimization
A hyperparameter optimization step refines the best performing model pipelines. AutoAI uses a
novel hyperparameter optimization algorithm that is optimized for costly function evaluations,
such as model training and scoring, that are typical in machine learning. This approach enables
fast convergence to a good solution despite long evaluation times of each iteration.
References
AutoAI Overview
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/autoai-overview.html
AutoAI implementation details
https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/autoai-details.html
Uempty
AutoAI terminology
• IBM implementation of AutoAI in Watson Studio adopts open-source terminology.
• Machine learning pipeline: A set of steps for creating a model (a workflow). Typical steps in a
pipeline are: ingest, clean, transform, and model with hyperparameter optimization.
• Estimators: Algorithms or models. For example: logistic regression, and random forest.
• Hyper Parameter Optimization (HPO): The process of training the models with different
parameters (specific to each algorithm).
• Model evaluation metrics: Various model evaluation metrics used by data scientists, for
example AUC-ROC and F1 Score.
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
AutoAI is a tool in Watson Studio. It requires a Watson Studio project and an instance of the
Machine Learning service.
Uempty
Exercise 4 – Section 2: Creating an AutoAI experiment from
marketing data
Figure 4-27. Exercise 4 – Section 2: Creating an AutoAI experiment from marketing data
Uempty
Exercise • In this section, you explore how to use the AutoAI tool in Watson
Studio to automate most of the phases in the AI lifecycle and
objectives generate a trained model quickly with no coding.
• After completing this exercise, you should be able to:
Explain the benefits of automating AI with AutoAI.
Create an AutoAI experiment in a Watson Studio project.
Customize an AutoAI experiment.
Monitor pipelines in an AutoAI experiment.
Compare the quality of trained models and select the best one for further
refinement.
Deploy the selected model online and score the trained model.
Uempty
Unit summary • Describe the Cross-Industry Standard Process for Data Mining
(CRISP-DM) process model.
• Describe the phases of data preparation.
• Describe Watson Machine Learning features and capabilities.
• Explain the value of the AutoAI tool and its use.
Uempty
Review questions
1. In CRISP-DM, which phase focuses on machine learning?
a. Business understanding
b. Data preparation
c. Modeling
d. Evaluation
e. Deployment
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
b. Data prediction
c. Data integration
d. Data sampling
e. Data formatting
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
b. Business analyst
c. Developers
d. Project manager
e. Tester
g. A & C
h. C & E
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
e. Hyperparameter optimization.
f. A & B
g. C & E
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
Review answers
1. In CRISP-DM, which phase focuses on machine learning?
a. Business understanding
b. Data preparation
c. Modeling
d. Evaluation
e. Deployment
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
b. Data prediction
c. Data integration
d. Data sampling
e. Data formatting
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
b. Business analyst
c. Developers
d. Project manager
e. Tester
g. A & C
h. C & E
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
e. Hyperparameter optimization
f. A & B
g. C & E
Introduction to IBM Watson Machine Learning and AutoAI © Copyright IBM Corporation 2018, 2022
Uempty
Exercise: Building and deploying a regression analysis
model with Watson Machine Learning
Figure 4-38. Exercise: Building and deploying a regression analysis model with Watson Machine Learning
Uempty
Exercise • In this exercise, you perform regression analysis by using the scikit-
learn and the watson-machine-learning-client packages. You use
objectives the digits data set, which is one of the sample data sets in scikit-
learn. Then, you use IBM Watson Machine Learning SDK to create an
online deployment on the Machine Learning service on IBM Cloud.
• After completing this exercise, you should be able to:
Load a sample data set from scikit-learn.
Explore data.
Prepare data for training and evaluation.
Create a scikit-learn pipeline.
Train and evaluate a model.
Store a model in the Watson Machine Learning (WML) repository.
Deploy and score the model in IBM Cloud.
Uempty
Overview
This unit introduces Natural Language Processing. It covers key applications of NLP, basics
concepts and terminology, tools and services and NLP challenges.
Uempty
Uempty
Uempty
5.1. Natural language processing overview
Uempty
Natural language
processing overview
Uempty
NLP stands for natural language processing. It is a subfield of computer science and AI concerned
with the processing human language by computers. It is one of the most important fields in
computer science in both industry and academia.
NLP enables machines to understand human communication to extract different information.
Examples of NLP applications include analysis of text in emails, human speech, social media, or
documents.
NLP has its origins in machine translation from the 1950s.
The first machine translation was from English to Russian and vice versa, but with poor and
inaccurate results.
Machine translation and other NLP applications advanced over the years by combining the power
of artificial intelligence (AI), computational linguistics, and computer science.
Uempty
Uempty
There are always some challenges that need to be tackled for any case. In NLP, here are the most
popular challenges:
• Domains: Higher accuracy for specific domains compared to generic domains.
• Language: English gets the most attention because it is an international language.
• Medium: Processing speech is more difficult than processing text.
To resolve some of these challenges, you must become familiar with your data and understand
the challenges of your particular use case. Think about how you will acquire the data and how to
validate its quality. Think about the deployment of your solution and how you are planning to
cover all these points.
Finally, review the state-of-the-art solutions and technologies for similar problems and how these
issues were resolved.
References:
Course hero
https://www.coursehero.com/file/p3q1s78/Language-English-gets-the-most-attention-because
-it-is-an-international-language/
Uempty
5.2. Natural language processing use cases
Uempty
Natural language
processing use
cases
Uempty
NLP technology can be used to extract information from unstructured text such as emails,
newspaper articles, and user reviews into structured text.
Entity extraction refers to extracting entities from the text such as organizations, people, and
locations. For example, the World Health Organization, IBM, Sara, John, Paris, US.
Relation extraction refers to identifying the relationship between entities, for example, “Abraham
Lincoln was a US president”; “Ginni Rometty is the CEO of IBM”.
Text summarization refers to the technique of shortening long pieces of text. Automatic text
summarization is a common use case in machine learning and natural language processing.
Structured text mostly takes the form of tables or values in a structured form.
The goal of information extraction is to parse the incoming text, identify important mentions and
their relations, and extract valuable output into structured text. Doing so can be used to automate
the process of reading articles and passages to convert this information into a structured format.
Computer systems can then manage this information and take proper actions.
Uempty
Sentiment analysis is the process of identifying emotions or opinions that are expressed in user
input.
Sentiment analysis answers various questions, such as how people feel about your product or
whether your customers are satisfied with your customer service.
It is used in marketing and retention plans, and emotional intelligence for chatbots, that is, it
enables chatbots to direct the conversation.
Machine learning algorithms brought many advances to this field and are still improving.
Uempty
Speech recognition
• Converts spoken language into text.
Example: Chatbot interactive talk; Internet of Things
(IoT) applications
Uempty
5.3. Natural language processing basic
concepts and terminology
Uempty
Natural language
processing basic
concepts and
terminology
This section introduces basic concepts and terminologies such as synonymy, polysemy,
hyponymy, and hypernymy. The taxonomy for similar concepts has applications in the education
and machine learning fields because they rely on word-sense disambiguation.
Uempty
Synonyms are words that are written differently but are similar in meaning. For example:
• Clever and smart
• Begin and start
• Beautiful and pretty
• Sad and unhappy
Antonyms are words that have meanings that are opposite to each other. For example:
• Clever and stupid
• Begin and end
• Beautiful and ugly
• Sad and happy
Usage example: In information retrieval, you might want to expand the keywords search by
retrieving the synonyms of the query words.
Uempty
Homonyms are words that have the same written form but have unrelated meanings. There are
two types of homonyms:
• Homographs
• Homophones
Homographs are words that have the same written form. For example:
• This answer is right.
• The building is on the right side of the river.
• You have the right to remain silent.
• Come here right now.
Although the word right has the same written form in the examples, you notice the difference
between the meanings in each sentence.
Homophones are words that sound similar when spoken but have different meanings and
spellings. For example:
• “left” and “lift”.
• “right” and “write”.
Uempty
Homonyms introduce challenges into NLP operations such as machine translation and speech
recognition. How do you translate right so that it has the correct meaning? How do you
differentiate two words that sound similar when you convert speech to text?
Uempty
Polysemy refers to words that have the same written form and related meaning. For example:
• You must face your fear.
• Her face is beautiful.
Hyponymy: A word is a hyponym of another word if it represents a subclass of the other word. For
example:
• Orange is a hyponym of fruit.
• Yellow is a hyponym of color.
Uempty
Hypernymy: One word is the hypernym of another word if it represents a superclass of the other
word. For example:
• Fruit is a hypernym of orange.
• Color is a hypernym of yellow.
Usage example: Comparing the semantic similarity.
Uempty
5.4. Natural language processing tools and
services
Uempty
Natural language
processing tools
and services
Uempty
There are many open source tools that you can use for NLP. For example:
• Open NLP that is based on Java. It provides many functions for text processing, such as
tokenizers, sentence segmentation, part-of-speech tagging, named entity extraction,
chunking, parsing, co-reference resolution, and more. For more information, see Apache
OpenNLP at https://opennlp.apache.org/
• Stanford Core NLP, which is written in Java. It is a suite of NLP tools that provide
part-of-speech tagging, a named entity recognizer, a co-reference resolution system,
sentiment analysis, and more. It supports many languages, such as English, German, French,
Arabic, Spanish, and Chinese. For more information, see
https://stanfordnlp.github.io/CoreNLP/.
• NLTK provides the same processes as the other NLP suites, but in the Python language. For
more information, see https://www.nltk.org/.
• WordNet is a popular lexical database that is used in research. There are many APIs and
languages that you can use to access WordNet. For example, you can make a call to retrieve a
synonym of a word. WordNet is available online and as an offline version that you can
download. For more information, see https://wordnet.princeton.edu/.
There are other libraries, such as Unstructured Information Management Architecture (UIMA).
IBM Watson uses UIMA to analyze unstructured data. The Apache Clinical Text Analysis and
Knowledge Extraction System (Apache cTAKES) is a UIMA-based system that is used to extract
information from medical records.
Uempty
References:
Apache OpenNLP
https://opennlp.apache.org/
CoreNLP
https://stanfordnlp.github.io/CoreNLP/
Uempty
Instead of using low-level libraries, you can use many cloud services that accomplish high-level
NLP tasks, for example, IBM Cloud, Microsoft Cloud (Azure), and Google Cloud.
IBM offers its AI services through IBM Cloud.
Examples of NLP services are:
• Watson Natural Language Understanding for text classification, entity identification, relation
extraction, and emotion extraction.
• Language Translator: Translates text from one language to another
• Watson Assistant: build conversational interface into an application (chatbot).
You can rapidly build a complete NLP application by using these services.
Uempty
Uempty
Review questions
1. Identifying opinions in a user input is a use case of:
a. Sentiment analysis
b. Classification
c. Chatbots
d. Translation
Uempty
4. True or False: Most Natural Language Processing (NLP) tasks work with structured data.
Uempty
Review answers
1. Email spam detection is a use case of:
a. Sentiment analysis
b. Classification
c. Chatbots
d. Translation
Uempty
4. True or False: Most Natural Language Processing (NLP) tasks work with structured data.
Uempty
Overview
This unit covers natural language processing components, the NLP pipeline, natural language
understanding, natural language generation, information retrieval, and information extraction.
Uempty
Uempty
Uempty
6.1. Natural language processing categories
Uempty
Natural language
processing
categories
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
NLU applications
• Unstructured to structured
• Question and answer system
• Sentiment analysis
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
NLU analyzes language to gain insights into the text. There are many examples of NLU
applications:
• Mapping a user’s unstructured input to a computer representation (structured data) and
relation extraction
• Question and answering system
• Sentiment analysis
The graphic in the slide shows an example of converting unstructured to structured data. The
input to the NLU system is natural language (unstructured text) and through the NLP process it is
converted to structured data (table).
References:
Natural Language Generation: An Overview
http://www.lacsc.org/papers/PaperA6.pdf
Understanding Natural Language Understanding
https://nlp.stanford.edu/~wcmac/papers/20140716-UNLU.pdf
Uempty
NLG applications
• Machine translation
• Text summarization
• Weather forecasting system
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
6.2. Language ambiguities
Uempty
Language
ambiguities
Uempty
Language ambiguities
• Lexical ambiguity: A primitive level, such as at the word level
• Verb versus noun:
“We will dance all night.”
“This is the salsa dance.”
“John will go to work.”
“His uncle left him millions in his will.”
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Building applications with NLP processes is not a trivial task. Natural language includes many
ambiguities, such as a lexical ambiguity, which is a primitive level, such as at the word level.
Two examples:
• The word dance can be a verb (“We will dance all night.”) or a noun (“This is the salsa dance.”).
• The word will can be a helping verb to indicate an action in the future (“John will go to work”)
or a noun (“His uncle left him millions in his will.”).
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
6.3. Natural language processing phases and
pipeline
Uempty
Natural language
processing phases
and pipeline
Uempty
• Checks grammar, arrangements of words, and the relationship between the words.
Syntactic Analysis • Techniques used: dependency parsing, and part of speech (POS) tagging.
• Studies the underlying meaning of a spoken or written text as it considers the social
Discourse Integration and historical contexts.
• Helps in studying the whole text.
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Syntactic Analysis
Syntactic analysis is the analysis that provides the logical meaning of a sentence or parts of that
sentence. It is the process of analyzing natural language with the rules of formal grammar.
Grammatical rules are applied to categories and groups of words, not to individual words.
Syntactic Analysis is used to check grammar, arrangements of words, and the interrelationship
between the words.
Example: “Mumbai goes to the Sara”. This sentence does not make sense, so this sentence is
rejected by a syntactic analyzer.
Syntactical parsing involves the analysis of words in the sentence for grammar. Dependency
grammar and part of speech (POS) tags are the important attributes of text syntactic.
Some of the techniques that are used in this phase are:
• Dependency Parsing
• Part of Speech (POS) tagging
Semantic Analysis
Semantic analysis retrieves the possible meanings of a sentence that is clear and semantically
correct. It is the process of retrieving meaningful insights from text.
Discourse Integration
Discourse integration refers to the context of a sentence or word. The meaning of a sentence
depends on the meaning of the sentence just before it. In addition, it also brings about the
meaning of the immediately succeeding sentence.
For example, the word “that” in the sentence “He wanted that” depends upon the prior discourse
context.
Pragmatic Analysis
Pragmatic analysis is the study of meanings in a language. In involves the process of extraction of
insights from the text. Through Pragmatic Analysis, what was described is reinterpreted by what it
was meant. It derives the various aspects of language that require real-world knowledge. It
means to abstract the meaningful use of language in situations. In this analysis, the focus is
always on what was said is reinterpreted on what is intended.
For example, the sentence “Please crack the door open” does not mean to break the door but to
open it a small amount.
Uempty
References:
Phases in Natural Language Processing
https://padhaitime.com/Natural-Language-Processing/Phases-in-NLP
Stages of Natural Language Processing
https://byteiota.com/stages-of-nlp/
The 5 Phases of Natural Language Processing
https://www.optisolbusiness.com/insight/the-5-phases-of-natural-language-processing
Natural Language Processing Step by Step Guide
https://www.analyticsvidhya.com/blog/2021/05/natural-language-processing-step-by-step-gui
de/#h2_6
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
When you work on an NLP task like machine translation, you must perform a set of processes and
activities. This set of processes is the NLP pipeline.
A pipeline is a process for designing a program in which the output of one module feeds into the
input of the next module. You use the pipeline to break down the complexity of the NLP task into a
smaller set of less complicated tasks. There are no strict rules for the activities that must be done
in the pipeline.
The following slides, explore some of these activities by using the following example:
“Yes, I received your invitation, and I will happily attend your party in London.”
This statement is understandable by a human but not a computer. We use the pipeline to walk
through each stage to analyze the statement.
Reference:
CoreNLP Pipelines
https://stanfordnlp.github.io/CoreNLP/pipelines.html
Uempty
Word tokenization
Stemming
Lemmatization
Chunking
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
NLP uses pipelines to read, decipher, and understand human languages. The slide shows the
prime processes of the NLP pipelines.
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
How to build an NLP pipeline
https://www.wikitechy.com/tutorial/nlp/how-to-build-an-nlp-pipeline
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Sentence segmentation focuses on finding the boundaries of sentences in text, that is, where the
sentence starts and ends. This is not an easy task to accomplish due to the possible ambiguity
that is caused by punctuation marks.
For example, a period might indicate the end of a sentence, but it might also indicate an
abbreviation, a decimal point, or an email address.
Assume that the two sentences here are separated by the conjunction “and”, so the result of this
stage is the following sentences:
• “Yes, I received your invitation.”
• “I will happily attend your party in London.”
Reference:
Sentence boundary disambiguation
https://en.wikipedia.org/wiki/Sentence_boundary_disambiguation
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Tokenization is a basic process that breaks a sentence into a group of words, punctuation,
numbers, and alphanumerics that are called tokens. The tokenization can be done on multiple
delimiters. Assume in the example that you use the white space as delimiter and apply
tokenization to the example:
First sentence: “Yes””,” “I” “received” “your” “invitation”
Second sentence: “I” “will” “happily” “attend” “your” “party” “in” “London”
White space is a standard delimiter but is not sufficiently useful by itself. For example,
segmenting “New York” into “New” and “York” might introduce ambiguity because they both
refer to a state, so you should preserve the space in-between.
Note
Sentence segmentation, tokenization, and other activities in the pipeline might also differ
depending on the language. For example, you cannot use the same English tokenizer with the
Japanese language.
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
In the stemming step, the prefixes and suffixes are removed to obtain the root word.
Stemming chops words without knowing the context of the word in sentences. It might create the
nonexistence meaning of a word. For Example: “Studies” => “Studi”, "troubled" => "troubl".
Stemming is preferred when the meaning of the word is not important for analysis, for example
spam detection. Lemmatization is recommended when the meaning of the word is important for
analysis, for example, Question & Answer system.
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
What is Stemming and Lemmatization in NLP?
https://www.analyticssteps.com/blogs/what-stemming-and-lemmatization-nlp
Uempty
Porter stemmer
talking → talk
ing → ø
2 discovered → discover
ed → ø
al → ø
electrical → electric
able → ø
4 doable → do
ate → ø
investigate → investing
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
An inflected form of a word has a changed spelling or ending that shows the way it is used in
sentences: "Finds" and "found" are inflected forms of "find."
Lemmatization groups different inflected forms of a word into a base word called lemma. For
example,
List of words: going, gone, went
Lemma: go
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
What is Stemming and Lemmatization in NLP?
https://www.analyticssteps.com/blogs/what-stemming-and-lemmatization-nlp
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Stop words are the words in any language that do not add much meaning to a sentence. Stop
words can safely be ignored without sacrificing the meaning of the sentence. For example, in
English, “the”, “is” and “and”, are examples of stop words. In NLP and text mining applications,
stop words removal eliminates unimportant words so that applications can focus on the important
words instead.
A list of English stop words can be found at https://www.ranks.nl/stopwords
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
Stopwords Lists
https://www.ranks.nl/stopwords
Uempty
det determiner
case case-marking
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Dependency Parsing (DP) is the process of examining the dependencies between the phrases of a
sentence to determine its grammatical structure. A sentence is divided into sections. The process
assumes that there is a direct relationship between each linguistic unit in a sentence. These
hyperlinks are called dependencies.
The example in the slide shows a diagram that explains the sentence’s dependence structure.
In a written dependency structure, the relationships between each linguistic unit, or phrase, in the
sentence are expressed by directed arcs. In the example, the root of the tree “prefer” varies the
pinnacle of the preceding sentence, as labelled in the diagram. Relations among the words are
illustrated above the sentence with directed, labeled arcs from heads to dependents. A root node
explicitly marks the root of the tree, the head of the entire structure.
A dependence tag indicates the relationship between linguistic units. For example, the word
“flight” changes the meaning of the noun “Denver.” As a result, you might identify a dependence
flight -> Denver, where flight is the pinnacle or head and Denver is the kid or dependent. It is
represented by nmod, which stands for the nominal modifier.
Uempty
The dependency tags that are used in the example are:
• nominal subject (nsubj): nominal, which is the syntactic subject and the proto-agent of a
clause.
• direct object of a verb (dobj): noun phrase, which is the (accusative) object of the verb.
• relation determiner (det): holds between a nominal head and its determiner.
• nominal modifier (nmod): The nmod relation is used for nominal dependents of another noun
or noun phrase and functionally corresponds to an attribute, or genitive complement.
• Case: The case relation is used for any case-marking element, which is treated as a separate
syntactic word (including prepositions, postpositions, and clitic case markers). Case-marking
elements are treated as dependents of the noun that they attach to or introduce.
References:
Dependency Parsing
https://www.analyticsvidhya.com/blog/2021/12/dependency-parsing-in-natural-language-proc
essing-with-examples/
Dependency Parsing
https://web.stanford.edu/~jurafsky/slp3/14.pdf
Universal Dependency Relations
https://universaldependencies.org/u/dep/
CoreNLP - Online tool to apply dependency parsing
https://corenlp.run/
Uempty
punct punctuation
det determiner
aux auxiliary
case case-marking
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
The slide shows the results of submitting the example “Yes, I got the invitation. I will happily
attend your party in London”.
The dependency tags that are used in the example are:
• nominal subject (nsubj): nominal, which is the syntactic subject and the proto-agent of a
clause.
• punctuation (punct): It is used for any piece of punctuation.
• discourse: It is used for interjections and other discourse particles and elements, which are
not clearly linked to the structure of the sentence, except in an expressive way.
• obj: The object of a verb is the second most core argument of a verb after the subject.
Typically, it is the noun phrase that denotes the entity acted upon or which undergoes a
change of state or motion (the proto-patient).
• advmod: An adverbial modifier of a word is a (non-clausal) adverb or adverbial phrase that
serves to modify a predicate or a modifier word.
• aux: An auxiliary of a clause is a function word that is associated with a verbal predicate that
expresses categories such as tense, mood, aspect, voice or evidentiality. It is often a verb
(which might have non-auxiliary uses) but many languages have nonverbal TAME markers,
which are also treated as instances of aux.
• nmod:poss It is used for a nominal modifier, which occurs before its head in the specifier
position that is used for ‘s possessives.
• Case: The case relation is used for any case-marking element, which is treated as a separate
syntactic word (including prepositions, postpositions, and clitic case markers). Case-marking
elements are treated as dependents of the noun that they attach to or introduce.
Uempty
References:
CoreNLP - Online tool to apply dependency parsing
https://corenlp.run/
Universal Dependency Relations
https://universaldependencies.org/u/dep/
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
POS tagging is the process of tagging each token with its grammatical representation, such as
noun, verb, or adjective.
POS helps the computer to understand language and grammar and derive meaning from the input
sentence.
In the example, the data set is English grammar, so according to the part of speech that are
defined, the objective is to label each token by its proper grammar value, that is, the
corresponding part of speech.
POS helps the computer to understand language and grammar and derive meaning from the input
sentence. Many human-annotated data sets are publicly available. One of the most popular data
sets is the one used by the Penn Treebank project.
References:
Part-of-speech tagging
https://en.wikipedia.org/wiki/Part-of-speech_tagging
Stanford Log-linear Part-Of-Speech Tagger
https://nlp.stanford.edu/software/tagger.shtml
Alphabetical list of part-of-speech tags used in the Penn Treebank Project:
https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Named Entity Recognition (NER) is the process of detecting the named entity such as person
name, movie name, organization name, or location.
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
How to build an NLP pipeline
https://www.wikitechy.com/tutorial/nlp/how-to-build-an-nlp-pipeline
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Chunking refers to the process of taking individual pieces of information and grouping them into
larger units. Chunking can be used to identify part of speech and short phrases present in a
sentence.
By grouping each data point into a larger whole, you can, for example, identify and group the part
of speech noun, verb, adjective, adverb, preposition, conjunction, pronoun, and interjection and
also short phrases formed by including any of these part of speech.
When you have loads of descriptions or modifications around a particular word or phrase of your
interest, you use chunking to grab the required phrase or word alone, ignoring the rest around it.
Hence, chunking paves a way to group the required phrases and exclude all the modifiers around
them, which are not necessary for analysis.
Chunking is used in NLP applications, for example, to group fruits of a specific category, such as
fruits rich in proteins, fruits rich in vitamins. Another example, chunking can also be used to group
cars with similar features. For example, cars with automatic gear in one group and cars with
manual gear into another group.
References:
Preprocessing steps in Natural Language Processing (NLP)
https://www.educative.io/answers/preprocessing-steps-in-natural-language-processing-nlp
How to build an NLP pipeline
https://www.wikitechy.com/tutorial/nlp/how-to-build-an-nlp-pipeline
What is Chunking in Natural Language processing?
https://www.analyticsvidhya.com/blog/2021/10/what-is-chunking-in-natural-language-processi
ng/
Uempty
6.4. Information retrieval
Uempty
Information
retrieval
Uempty
Information retrieval
• Information retrieval is the process of accessing and retrieving the most appropriate
information from text based on a particular query in natural language that is submitted by the
user, with the help of context-based indexing or metadata.
• An information retrieval system searches a collection of natural language documents with
the goal of retrieving exactly the set of documents that matches a user’s question.
• Information retrieval is the foundation of many search engines. .
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Information retrieval (IR) is the process of accessing and retrieving the most appropriate
information from text based on a particular query in natural language that is submitted by the
user, with the help of context-based indexing or metadata.
Google Search is the most popular example of an information retrieval application.
An information retrieval system searches a collection of natural language documents with the goal
of retrieving exactly the set of documents that matches a user’s question. They have their origin in
library systems.
These systems assist users in finding the information that they require but it does not attempt to
deduce or generate answers. They provide information about the existence and location of
documents that might contain the required information. The documents that satisfy the user’s
requirement are called relevant documents. A perfect information retrieval system retrieves only
relevant documents.
Reference:
Step by Step Guide to Master NLP – Information Retrieval
https://www.analyticsvidhya.com/blog/2021/06/part-20-step-by-step-guide-to-master-nlp-info
rmation-retrieval/
Uempty
Transforming the query in the same way as the document content is represented.
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
A user who needs information formulates a request in the form of a query in natural language.
After that, the IR system returns output by retrieving the relevant documents, about the required
information. The IR system accomplishes the goal by performing the following steps:
1. Indexing the collection of documents.
2. Transforming the query in the same way as the document content is represented.
3. Comparing the description of each document with that of the query.
4. Listing the results in order of relevancy.
References:
Step by Step Guide to Master NLP – Information Retrieval
https://www.analyticsvidhya.com/blog/2021/06/part-20-step-by-step-guide-to-master-nlp-info
rmation-retrieval/
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
6.5. Information extraction
Uempty
Information
extraction
Uempty
Information extraction
• Refers to the automatic extraction of structured information from unstructured or semi-
structured text.
• Examples of applications where information extraction is used:
Entities and relation identification
Sentiment analysis
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
As shown in this slide, “Nobel Prize” and “Wilhelm Conrad Rontgen” are identified as entities. The
relationship is identified as awarded, which indicates the relationship between Wilhelm and the
Nobel Prize.
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Sentiment analysis is the process of identifying emotions or opinions that are expressed in user
input. It is used heavily in the fields of chatbots and social media analysis. It is also used in
marketing because it captures a user’s opinion about a particular product or service so that an
organization can take corrective action to keep the user satisfied.
Examples:
• “Their service is amazing” is a positive sentiment.
• “The quality of food in this restaurant is terrible” is a negative sentiment.
• “I am going to school” is a neutral sentiment.
Uempty
Uempty
Review questions
1. The technique that is used to group together different inflected forms of a word into a base
word is called:
a. Stemming
b. Dependency Parsing (DP)
c. Chunking
d. Lemmatization
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
3. True or False: For any NLP task, you must apply every step in the NLP pipeline.
4. True or False: Sentiment analysis is an NLU application.
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Review answers
1. The technique that is used to group together different inflected forms of a word into a base
word is called:
a. Stemming
b. Dependency Parsing (DP)
c. Chunking
d. Lemmatization
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Natural language processing concepts and components © Copyright IBM Corporation 2019, 2022
Uempty
Overview
This unit explains how to evaluate the quality of your natural language processing (NLP) algorithm.
Uempty
Unit objectives • Define various metrics to measure the quality of NLP algorithms.
• Explain the difference between these metrics.
Uempty
System evaluation
• How can we measure the solution quality?
• Target: You developed a new search engine. You must define how well it works.
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
How can we measure the solution quality? In this presentation, we focus on a basic metric to
evaluate system performance in information retrieval. Assume that you developed a search
algorithm that helps you to retrieve related words from a corpus that contains 1000 documents.
From these 1000 documents, assume 200 are relevant to the word cat, and the other 800
documents are irrelevant.
Uempty
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
You test your solution by searching for the word “cat”. Your algorithm returns 250 documents,
where 150 documents are relevant (which means your algorithm missed 50 relevant documents)
and 100 documents are irrelevant (which means your algorithm correctly eliminated 700 of the
irrelevant documents).
Uempty
A confusion matrix, also known as an error matrix, is a specific table layout that enables
visualization of the performance of an algorithm.
Based on the results for this example, how many relevant documents were retrieved by the
algorithm? The answer is 150 documents. This value is the True positive (Tp).
Based on the results for this example, how many irrelevant documents were retrieved by the
algorithm? The answer is 100 documents (total 250 documents retrieved – 150 relevant
documents). This value is the False positive (Fp).
Based on the results for this example, how many relevant documents did the algorithm not
retrieve? The answer is 50 documents. This value is the False negative (Fn).
Based on the results for this example, how many irrelevant documents did the algorithm not
retrieve? The answer is 700 documents. This value is the True negative (Tn).
The objective is to improve the algorithm to decrease the Fp and Fn values.
Uempty
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
We map the confusion matrix to the graph to produce the visuals for Tp, Fp, Tn, and Fn. We add Tp
to the retrieved relevant documents area and Fp to the retrieved irrelevant area. We add Fn to the
not retrieved relevant area and Tn to the not retrieved irrelevant area.
Uempty
Accuracy = (Tp+Tn)/(Tp+Tn+Fp+Fn)
Accuracy = (150+700)/(1000)
• Useful for symmetric data sets where the values of positive and negatives are almost the
same.
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
Accuracy is as a numeric measure of how good your algorithm is. It calculates how many correct
results your solution managed to identify, which is the proportion of true results among the total
number of cases that are examined.
Accuracy is defined by the following formula, which includes the Tp, Tn, Fp, and Fn metrics:
Accuracy = (Tp+Tn)/(Tp+Tn+Fp+Fn)
By applying the values from the example, accuracy can be calculated as follows:
Accuracy = (150+700)/1000 = 0.85
Accuracy is a good measure but only when you have symmetric data sets where the number of
positive values and negatives values are almost the same. For example, if your data set is split as
90 positive samples and 10 negative samples, classifying all as positive gives a 0.90 accuracy
score.
Therefore, we must look at other metrics such as precision and recall to evaluate the quality of the
algorithm.
Uempty
Precision = Tp/(Tp+Fp)
Precision = 150/(150+100)
Precision = 150/250 = 0.60
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
Precision is a numeric measure that represents the fraction of retrieved documents that are
relevant. It is defined by the following formula:
Precision = Tp/(Tp+Fp)
Apply the formula to the example:
Precision = 150/(150+100)
150 retrieved relevant / 250 total retrieved = 0.60
Uempty
Recall = Tp/(Tp+Fn)
Recall = (150)/(150+50)
Recall = 150/200 = 0.75
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
Recall is a numeric measure that represents the fraction of relevant documents that were
retrieved. It is defined by the following formula:
Recall = Tp/(Tp+Fn)
Apply the formula to the example:
Recall =150/(150+50)
150 retrieved relevant / 200 total relevant = 0.75
Uempty
• The higher the F-score value is, the better the algorithm is.
F = 2*Precision*Recall/(Precision+Recall)
F = (2*0.60*0.75)/(0.60+0.75)
F = 0.9/1.35= 0.6667
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
The F-score (also called F-measure) is a measure that enables you to tradeoff precision against
recall by approximately averaging the precision and recall values.
The formula for F-score is:
F = (2*Precision*Recall)/(Precision +Recall)
Apply the formula to the example:
F = (2*0.60*0.75)/(0.60+0.75)
= 0.9/1.35= 0.6667
Uempty
Unit summary • Define various metrics to measure the quality of NLP algorithms.
• Understand the difference between these metrics.
Uempty
Review questions
1. True or False: To calculate the F-score, you must calculate accuracy first.
2. True or False: Accuracy is the harmonic mean of precision and recall.
3. Assume that you developed an algorithm and calculated the Precision as 0.5 and the Recall as
0.5, what is the value of F-score in this case?
a. 0.25
b. 1.00
c. 0.50
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
1. False
2. False
3. C: 0.50
Uempty
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
4. B: 2*(P*R)/(P+R)
Uempty
Review answers
1. True or False: To calculate the F-score, you must calculate accuracy first.
2. True or False: Accuracy is the harmonic mean of precision and recall.
3. Assume that you developed an algorithm and calculated the Precision as 0.5 and the Recall as
0.5. What is the value of F-score in this case?
a. 0.25
b. 1.00
c. 0.50
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
1. False
2. False
3. C: 0.50
Uempty
Natural language processing evaluation metrics © Copyright IBM Corporation 2018, 2022
4. B: 2*(P*R)/(P+R)
Uempty
Overview
This unit lists the Watson services and software that are based on natural language processing
(NLP) and explains the main capabilities of IBM Watson Natural Language Understanding and IBM
Watson Discovery.
Uempty
Uempty
Uempty
8.1. Watson NLP services
Uempty
Watson NLP
services
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Many Watson services have NLP at their core. The slide shows all the Watson NLP services on IBM
Cloud.
The remainder of this presentation focuses on two Watson NLP services:
• Natural Language Understanding
• Watson Discovery
Other presentations in this course cover Watson Assistant and Knowledge Studio in detail.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
The Natural Language Understanding and Watson Discovery services are based on natural
language processing (NLP) technology to extract information from unstructured text. These
services can be used without training by the user because they include a built-in public model.
They are pre-trained on a public training data set and ready to use immediately. However, to
improve the accuracy of the service for a given domain, Natural Language Understanding and
Discovery should also be trained.
Uempty
8.2. Watson Natural Language Understanding
Uempty
Watson Natural
Language
Understanding
Uempty
• NLU can be extended with custom models for supported feature and language combinations.
Watson Knowledge Studio can be used to create a custom model for NLU to detect custom entities and
relations that are unique to your domain.
(*) Tone analysis is done by using a pre-built classifications model.
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Watson Natural Language Understanding (NLU) includes a set of text analytics features that you
can use to extract meaning from unstructured data. NLU accepts user input and provides an
output that includes entities and relationships that are found in the text. NLU can also perform
sentiment analysis of the input text.
Input can be in the form of text, raw HTML, or a public URL. The service cleans HTML content
before analysis by default so the results can ignore most advertisements and other unwanted
content.
NLU can be extended with custom models for supported feature and language combinations.
You can create custom models by using Watson Knowledge Studio to detect custom entities and
relations in NLU that are unique to your domain.
Note
Tone analysis is done by using a pre-built classifications model. See next slide for more
information.
Uempty
Reference:
Natural Language Understanding
https://cloud.ibm.com/apidocs/natural-language-understanding#introduction
Watson Natural Language Understanding – Details
https://www.ibm.com/uk-en/cloud/watson-natural-language-understanding/details
Overview - Customizing models
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understan
ding-customizing
Uempty
{ { (cont.)
"language": "en", "usage": { {
"text": "This is example text in English.", "text_units": 1, "confidence": 0.564849,
"features": { "text_characters": 60, "class_name": "excited"
"classifications": { "features": 1 },
"model": "tone-classifications-en-v1" }, {
} "language": "en", "confidence": 0.355816,
} "classifications": [ "class_name": "satisfied"
} .........
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Tone analysis is done by using a pre-built classifications model, which provides an easy way to
detect language tones in written text. It detects seven
tones: sad, frustrated, satisfied, excited, polite, impolite, and sympathetic.
To detect tone, use the language-specific classifications model ID in your API request.
The language-specific tone model ID is formatted as tone-classifications-xx-v1, where xx is a
two-character language code.
Tone analytics is currently available for English and French languages only, as indicated in the
Language support topic at
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understan
ding-language-support.
References:
Understanding tone analytics
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understan
ding-tone_analytics#understanding-tone-analytics
Language support
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understan
ding-language-support
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
The IBM Watson Natural Language Understanding Text Analysis online demo at
https://www.ibm.com/demos/live/natural-language-understanding/self-service/home
demonstrates text analytics features that you can use to extract meaning from unstructured data
by using the NLU service. In the demo, you can choose from a domain sample to apply the
knowledge of unique entities and relations in a particular industry. Alternatively, you can analyze
your own text by using the base model. The following slides show this demo with a financial
domain sample.
Reference:
IBM Watson Natural Language Understanding Text Analysis
https://www.ibm.com/demos/live/natural-language-understanding/self-service/home
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Watson Natural Language Understanding includes out of the box capabilities to find people,
places, events, and other types of entities mentioned in your content.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
With Watson Natural Language Understanding, you can extract keywords and search for the
relevant ones.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can identify high-level concepts that are not necessarily directly
referenced in the text.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can recognize when two entities are related and identify the type
of relation.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can analyze the sentiment toward specific target phrases and
the sentiment of the document as a whole.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can analyze emotion that is conveyed by specific target phrases
or by the document as a whole.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can categorize your content by using a five-level classification
hierarchy.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding can parse sentences into subject-action-object form and
identify entities and keywords that are subjects or objects of an action.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding allows you to include a custom model from Watson Knowledge
Studio so that you can extend the entities that are mentioned in your content to fit any domain.
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Natural Language Understanding allows you to include a custom model from Watson Knowledge
Studio. This custom model includes the ability recognize when two entities are related and
identify the type of relation.
Uempty
8.3. Watson Discovery
Uempty
Watson Discovery
Uempty
Watson Discovery
• Adds cognitive search and content analytics to applications to identify patterns, trends, and
insights.
• Unlocks actionable insights in unstructured data.
• Unifies structured and unstructured data.
• Uses simple query language to eliminate the need for manual filtering of results.
• Parses documents and enables the user to search through the documents by using a natural
language query.
• Can be trained.
• Includes the Discovery API and Discovery tooling.
• Example application: Find answers to FAQs
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Watson Discovery
With Watson Discovery, you can add a cognitive search and a content analytics engine to
applications to identify patterns, trends, and actionable insights that drive better
decision-making. You can rapidly build cognitive, cloud-based exploration applications that
unlock actionable insights that are hidden in unstructured data.
You can securely unify structured and unstructured data with pre-enriched content and use a
simplified query language to eliminate the need for manual filtering of results.
With Discovery, you can prepare your unstructured data, create a query to pinpoint the
information you need, and then integrate those insights into your new application or existing
solution.
The Watson Discovery services include:
• Discovery API. The Discovery service supports various SDKs to simplify the development of
applications. The SDKs are available for many popular programming languages and platforms,
including Curl, Java, NodeJS, Python, Go, .NET, Ruby, Swift, and Unity.
• Discovery tooling. The Discovery service includes a complete set of online tools, the Discovery
tooling, to help you quickly set up an instance of the service and populate it with data. The
Discovery service tooling was designed to save time by eliminating the need to use APIs to
configure and populate your service.
With Discovery, you can build applications that extract the correct answers to FAQs by enriching
and searching data collections.
Uempty
References:
Watson Discovery on Cloud Pak for Data as a Service
https://dataplatform.cloud.ibm.com/docs/content/svc-welcome/watsondisc.html?context=cpda
as&audience=wdp
Discovery API documentation
https://cloud.ibm.com/apidocs/discovery-data?code=unity#introduction
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
IBM Watson Discovery is an AI-powered search engine that helps you to extract answers from
complex business documents.
Use Discovery to visually train AI for deep understanding of your content, including tables and
images to help you find business value that is hidden in your enterprise data. Use natural language
or structured queries to find relevant answers, surface insights, and build AI-enhanced business
processes anywhere.
Start by connecting your data to Discovery. Next, teach Discovery to understand the language and
concepts that are unique to your business and industry. Enrich your data with award-winning
Natural Language Understanding (NLU) technologies so you can identify key information and
patterns. Finally, build search solutions that find answers to queries, explore your data to uncover
patterns and insights, and leverage search results in automated workflows.
Supported file types: CSV, DOC, DOCX, GIF, HTML, JPG, JSON, PDF, PNG, PPT, PPTX, TIFF, TXT,
XLS, XLSX
References:
About Watson Discovery
https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-about
Supported file types
https://cloud.ibm.com/docs/discovery-data?topic=discovery-data-collections#supportedfiletyp
es
Uempty
Uempty
Review questions
1. True or False: Watson Natural Language Understanding parses documents and enables the
user to search through the documents by using a natural language query.
2. True or False: You can teach Discovery to understand the language and concepts that are
unique to your business and industry.
3. Watson Discovery provides one of the following capabilities:
a. Returns best matching image.
b. Identifies a variety of tones at both the sentence and document level.
c. Adds cognitive search and content analytics to applications to identify patterns, trends, and insights.
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Uempty
Review answers
1. True or False: Watson Natural Language Understanding parses documents and enables the
user to search through the documents by using a natural language query.
2. True or False: You can teach Discovery to understand the language and concepts that are
unique to your business and industry .
3. Watson Discovery provides one of the following capabilities:
a. Returns best matching image.
b. Identifies a variety of tones at both the sentence and document level.
c. Adds cognitive search and content analytics to applications to identify patterns, trends, and insights.
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Uempty
Natural language processing and IBM Watson © Copyright IBM Corporation 2019, 2020
Uempty
Exercise: Ingesting, converting, enriching, and querying
data with the IBM Watson Discovery service
Figure 8-29. Exercise: Ingesting, converting, enriching, and querying data with the IBM Watson Discovery service
Uempty
Exercise • With Watson Discovery, it takes only a few steps to prepare your
unstructured data, create a query that pinpoints the information that
objectives you need, and then integrates those insights into your new
application or existing solution.This exercise takes you through the
process of preparing and querying a collection of documents.
Uempty
Overview
This unit introduces IBM Watson Knowledge Studio, its capabilities, and features. This unit
explains the end-to-end domain adaptation process.
Uempty
Uempty
Uempty
9.1. IBM Watson Knowledge Studio overview
Uempty
IBM Watson
Knowledge Studio
overview
Uempty
Teach by Example
Empower subject matter experts without technical skills to teach Watson the language of your
industry.
Extract Value at Scale
Process documents with your custom language model to find entities and meaningful
relationships between them.
Reference:
Watson Knowledge Studio
https://www.ibm.com/demos/live/watson-knowledge-studio/self-service
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Knowledge Studio is a service on IBM Cloud that can help you create a machine learning model
that understands the linguistic nuances, meaning, and relationships that are specific to your
domain. It also can help you create a rule-based model that finds entities in documents based on
rules that you define.
• Machine learning model. Uses a statistical approach to find entities and relationships in
documents. This type of model can adapt as the amount of data grows.
• Rule-based model. Uses a declarative approach to finding entities in documents. This type of
model is more predictable and easier to comprehend and maintain. However, it does not learn
from new data. It can find only patterns that it was trained to find.
References:
Watson Knowledge Studio
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ov
erview_full
Why you should use Watson Knowledge Studio
https://www.youtube.com/watch?v=r2xYHW0iyZM&index=3&list=PLZDyxLlNKRY9yM_Deg6GhT
U1WS0-JLwyX&
Annotating documents
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-user-g
uide
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Knowledge Studio provides easy -to-use tools for annotating unstructured domain literature and
uses those annotations to create a custom machine learning model that understands the
language of the domain. The accuracy of the model improves through iterative testing, ultimately
resulting in an algorithm that can learn from the patterns that it sees and recognizes those
patterns in large collections of new documents.
You can deploy the finished machine learning model to other Watson cloud-based offerings and
cognitive solutions to find and extract mentions of relationships and entities, including entity
coreferences.
Reference:
Watson Knowledge Studio
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ov
erview_full
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
1. Based on a set of domain-specific source documents, the team creates a type system that
defines entity types and relation types for the information of interest to the application that
uses the model.
2. A group of two or more human annotators annotates a small set of source documents to label
words that represent entity types, identify relationship types where the text identifies
relationships between entity mentions, and define co-references, which identify different
mentions that refer to the same thing, that is, the same entity. Any inconsistencies in the
annotations are resolved, and one set of optimally annotated documents is built, which forms
the ground truth.
3. Knowledge Studio uses the ground truth to train a model.
4. The trained model is used to find entities, relationships, and co-references in new documents.
Reference:
Watson Knowledge Studio
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ov
erview_full
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Create a rule-based model that can recognize patterns in your documents. Use rules to capture
patterns that occur in documents and convey information about underlying entity types. Rules can
be defined to recognize person’s names, money, dates, percentage, and more.
Reference:
Watson Knowledge Studio
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ov
erview_full
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Knowledge Studio provides a rule editor that simplifies the process of finding and capturing
common patterns in your documents as rules. It uses dictionaries to speed up the annotation
process.
The rule editor provides some tools that help you define rules:
• Dictionary. Add a dictionary and assign it a class name. Any words that are found that match
entries in the dictionary are automatically annotated with the dictionary class.
• Regular expression. A regular expression is a sequence of characters that define a search
pattern. The Regex tool that is included in the rule editor recognizes expressions. For example,
your documents might have several references like the following ones:
▪ 35-year-old driver
▪ 16-year-old learner
The syntax n-year-old x is a pattern that typically represents a person. You can define a regular
expression rule to find phrases that match the n-year-old x pattern, and annotate them as
PERSON entity mentions.
References:
Rules
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-rule-an
notator
Using the rule-based model
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ru
le_publish
Uempty
Rule based • Declarative (codify a set of rules). • Requires work to develop, write, and
• Useful for basic text extraction, for define a set of rules.
example, extracting emails, URLs, and • As complexity grows, maintenance
phone numbers. becomes an issue.
• Easy to comprehend and maintain.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Machine learning models learn by examples that contain the information that we want to extract
for the specific domain. A machine learning model is useful when the information that you are
interested in does not have a certain form that can be codified into a rule, which is the case with
unstructured natural language.
Rule-based models are most useful when they are used to extract data that is known to have a
certain format, such as email addresses or phone numbers. If the information can come in many
forms, then you must define a rule or set of rules for each format. This approach is inefficient if the
information that you must extract comes in many forms and has many variations.
The table summarizes both model types and their pros and cons.
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
With Knowledge Studio, you can create, evaluate, and improve models for new domains. A model
adds annotations (metadata) to text that appears in natural language content. The annotations,
which identify mentions of entities of interest in your domain content, the relationships between
them, and how the mentions co-reference the same entity, can be used by applications to
automatically analyze and process text. Application users benefit from this level of analysis by
being able to extract meaning, discover insights, and obtain answers in a natural language
context.
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2019, 2022
To become a subject matter expert in an industry or domain, Watson services must be trained to
understand specialized terminology and the relationships between entities. Knowledge Studio
facilitates the training of some Watson offerings. Knowledge Studio simplifies the task of building
machine learning models by helping subject matter experts to train Watson based on examples
without code.
By using Knowledge Studio, you can:
• Teach by example: Empower domain subject matter experts to teach Watson the language of
your domain without requiring deep technical skills or coding.
• Engage your experts: Bring your experts together in a collaborative online environment to
teach Watson how to understand the linguistic nuances of your domain.
• Use everywhere: Apply what you taught Watson in multiple applications by using models
from Knowledge Studio in Discovery and Natural Language Understanding.
• Knowledge Studio is end-to-end: It is the only offering in the market that combines the
powerful capabilities of annotation, training, and evaluation in a single collaboration-focused
service.
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
The slide shows an example that demonstrates a custom financial model that is trained with
Watson Knowledge Studio that tracks key financial metrics values, changes, and drivers in an
automatic report.
Reference:
Custom financial model
https://www.ibm.com/demos/live/watson-knowledge-studio/self-service/home
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
The model that you create with Knowledge Studio is a software component that can be plugged
into a natural language processing (NLP) pipeline.
You can deploy the finished machine learning model to other Watson cloud-based offerings and
cognitive solutions to find and extract mentions of relations and entities, including entity
coreferences.
• Deploy a machine learning or rule-based model to use with the Watson Discovery service.
• Deploy a machine learning or rule-based model to use with the Natural Language
Understanding service.
• Bootstrap annotation by using the Natural Language Understanding service to automatically
find and annotate entities in your documents. When human annotators begin to annotate the
documents, they can see the annotations that were already made by the service and can
review and add to them. See Pre-annotating documents with Natural Language
Understanding at
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-pre
annotation#wks_preannotnlu for details.
References:
Watson services integration
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-wks_ov
erview_full#wks_watsoninteg
Pre-annotating documents with Natural Language Understanding
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-preann
otation#wks_preannotnlu
Uempty
9.2. Watson Knowledge Studio features
Uempty
Watson Knowledge
Studio features
Uempty
Creating a workspace
• Create a single workspace for each model.
• The workspace contains the artifacts and resources
that are needed to build the model.
• One workspace can contain one rule-based model
and one machine learning model.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
The first step in building a custom model is to create a workspace. For each model that you want
to build and use, create a single workspace that contains the artifacts and resources that are
needed to build the model. You can create one workspace that contains both one rule-based
model and one machine learning model. Then, you train the model to produce a custom model
that can be deployed to an external service for use. Follow these steps:
1. Give your workspace a name and provide a description about the domain to easily remember
it.
2. Choose the language of your trained documents and dictionaries.
3. Optional: If you want to change the tokenizer that is used by the application from the default
machine learning-based tokenizer, expand the Advanced Options section and select
Dictionary-based tokenizer. For more information, see the References for this slide.
4. Optional: You can add project manager role, but because you have a Lite plan subscription,
skip this step. You cannot add other users. As an administrator, you can perform all the tasks
that a project manager typically performs.
References:
Creating a workspace
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-create-
project
Watson Knowledge Studio Technical Deep Dive Demo
https://www.youtube.com/watch?v=EQcEk2TX79c
Uempty
Workspace resources
• You add the following types of resources to the workspace:
Type system
Dictionaries
Documents
• The resources are either created or uploaded for training the models.
• Each of these resources can be used differently depending on the model type.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Uempty
Type system
• Defines entities and relationships between entities that are interesting for your domain:
Mentions. Example: “Watson”, “IBM”.
Entity types. Example: “PERSON”, “ORGANIZATION”.
Relation types. Example: founderOf, employedBy.
• Controls how content can be annotated.
• Can be created from scratch or uploaded from an existing type system.
• If you create a type system from scratch, define it directly in the Knowledge Studio editor.
• To avoid visual overload for human annotation, define no more than 50 entity types and 50
relation types.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
A type system defines things that are of interest in your domain content that you want to label
with an annotation:
• Mentions. A mention is any span of text that you consider relevant in your domain data. For
example, “President Obama” or “IBM”.
• Entity types. Categorize a real-world thing. An entity mention is an example of a thing of that
type. For example, the mention President Obama can be annotated as a PERSON entity type.
The mention IBM can be annotated as an ORGANIZATION entity type.
• Relation types. Define a binary and ordered relationship between two entities. For a relation
mention to exist, the text must explicitly define the relation and bind mentions of the two
entities together and must do so within a single sentence. For example, the sentence “Mary
works for IBM” is textual evidence of the employedBy relation type.
The type system controls how content can be annotated by defining the types of entities that can
be labeled and how relationships among different entities can be labeled. The model process
manager typically works with subject matter experts for your domain to define the type system.
In Knowledge Studio, you can create a type system from scratch or upload one from an existing
type system. To start a workspace, you might want to upload a type system that was created for a
similar domain. You can then edit the type system to add or remove entity types or redefine the
relationship types.
Reference:
Establishing a type system
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-typesy
stem
Uempty
Dictionary
• A dictionary groups words and phrases that should be treated equivalently by a model.
Example:
September, Sept, Sep.
Monday, Tuesday, Wednesday (DAY_OF_WEEK).
• Dictionaries help the Knowledge Studio machine learning models to understand the language
of the domain.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Dictionaries
In machine learning, a dictionary groups words and phrases that share something . An entry in the
dictionary does not mean that all words in the entry mean the same thing, but that the words are
to be treated equivalently by a model. A dictionary is a list of words or phrases that are equivalent
for information-extraction purposes, meaning that they are interchangeable for the purposes of
identifying entity and relation mentions.
Consider this example: A dictionary entry contains the seven days of the week. To annotate a
document, a human annotator assigns the entity type DAY_OF_WEEK to mentions of Monday and
Friday in the text. Because the dictionary equates the seven days of the week, it helps ensure that
a machine learning model correctly annotates occurrences of Tuesday, Wednesday, and the other
days of the week in unseen documents at run time. In addition, equating these words also
benefits information extraction in the surrounding text. What the machine learning model learns
from training examples about the texts near Monday and Friday is applied to texts that the
machine learning model sees near other days of the week because the dictionary states that these
terms are equivalent for information-extraction purposes.
You do not need to create a dictionary that contains days of the week information. Several
general-purpose dictionaries are built in to the application. Other built-in dictionaries include
countries, place names, number words, animals, plants, diseases, measurement words (such as
ounce and meter), and salutation title words (such as Mr. and Mrs.). You cannot disable or edit
built-in dictionaries.
Reference:
Creating dictionaries
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-diction
aries
Uempty
Dictionary usage
• Adding dictionaries is optional and can be used in two ways:
Machine learning usage. Used by the machine learning model to provide words or phrases that are
equivalent for information-extraction purposes.
Pre-annotation usage. Used during pre-annotation to bootstrap the annotation effort.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Uempty
Documents
• Usage for a machine learning model:
Documents are used to train the machine learning model when they are annotated.
Examples: Journal articles or other industry-specific texts that are related to the domain for which the
model is built.
• Usage for a rule-based model:
Add or upload documents from which you can draw patterns to define as rules.
Add documents with linguistic patterns that illustrate the types of rules you want to define.
• Documents that you add for defining rules are kept separate from documents that you add for
annotation.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Documents are the main resources that are needed for custom model creation. Documents are
used for different purposes based on the model that is created.
• For a machine learning model:
▪ Documents are used to train the machine learning model when they are annotated.
▪ Examples: Journal articles or other industry-specific texts that are related to the domain
for which the model is built.
• For a rule-based model:
▪ Add or upload documents from which you can draw patterns to define as rules.
▪ Add documents with linguistic patterns that illustrate the types of rules you want to define.
Documents that you add for defining rules are kept separate from documents that you add for
annotation.
Reference:
Annotating documents
https://cloud.ibm.com/docs/watson-knowledge-studio?topic=watson-knowledge-studio-user-g
uide
Uempty
9.3. Adapting the system to a new domain
Uempty
Adapting the
system to a new
domain
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Adapting a cognitive system to a new domain, requires an iterative process with continuous
improvements to increase the performance of the system. This iterative process aims to reach a
level of incremental accuracy performing activities such as adding new functions, testing the
system, identifying opportunities to improve the performance, doing headroom analysis, and
finding possible solutions for the most frequent errors. The process requires the collaboration of
domain experts, data scientists, natural language processing (NLP) experts, and machine learning
developers.
The creation of a model is an iterative multiple-step process that involves several stages:
knowledge curation, ground truth generation, model development, model evaluation, and model
deployment.
The diagram summarizes the interactions between these five stages of model development and
the typical activities that occur at each stage.
Reference:
Building Cognitive Applications with IBM Watson Services: Volume 1 Getting Started
http://www.redbooks.ibm.com/redbooks.nsf/redbookabstracts/sg248387.html?Open
Uempty
Knowledge curation
• This stage refers to the process of selecting, collecting, preserving, and maintaining content
relevant to a specific domain.
• This stage is external to Knowledge Studio.
• Curation adds value to data: It transforms data into trusted information and knowledge.
• Knowledge curation involves the following activities:
Ensuring that the selected documents are representative of the domain content.
Ensuring that selected documents cover the entity types and relation types that are defined in your
type system.
Providing more documents for a complex type system, and fewer for a simpler one.
Limiting each document to a page or two of content. This is a preferred practice, especially in the early
stages of model development.
Ensuring that the documents include variations in vocabulary and phrasing.
In the case of skewed frequency-of-occurrence of entity types and relation types, trying to get at least
50 exemplars of each type.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Curation adds value to data by transforming data into trusted information and knowledge. This
stage, which is external to Knowledge Studio, refers to the process of selecting, collecting,
preserving, and maintaining content relevant to a specific domain. This stage is important
because the curated content is used as input in the following stage.
You must ensure that the collected content is representative of your domain content and of high
value to your application.
Ensure that the collected content covers the entity types and relation types that are defined in
your type system. Sometimes, even a representative small sample of documents in the domain of
interest is collected and the type system is modified and refined based on it.
Ensure that the data in the documents is distributed across all possible entity types, subtypes,
and roles, and the relationships between them. A goal to aim for is to have at least 50 annotations
for each entity type and 50 for each relation type in the document collection.
Strive to provide a set of documents that have a total size of about 300,000 words. Provide more
words for a complex type system, and fewer for a simpler one.
Limit each document to a page or two of content (fewer than 2,000 words, and closer to 1,000
words per document is best). In the early stages of model development, keeping each document
down to a few paragraphs is a preferred practice. A human annotator can mark mentions and
relations in a long document but attempts to mark co-references across multiple pages might
prove unwieldy.
Documents should represent the breadth of the subject matter that the application covers. In the
case of skewed frequency-of-occurrence of entity types and relation types, try to get at least 50
exemplars of each type, and more for entity types that have mentions that tend to be phrases..
Uempty
Reference:
Adding documents for annotation
https://github.com/IBM-Bluemix-Docs/watson-knowledge-studio/blob/master/documents-for-a
nnotation.md
Uempty
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
This stage refers to the use of Knowledge Studio tools and best practices to produce a collection
of vetted data that can be used to adapt a Watson solution to a particular domain. The accuracy of
this vetted data, which is called ground truth or gold standard documents, is critical because
inaccuracies in the ground truth correlate to inaccuracies in the applications that rely on it.
An essential part of teaching Watson about a new domain involves providing it with knowledge
about entities of interest in your domain content, the relationships between them, and how the
entities co-reference each other. Collecting this knowledge includes the following activities:
1. Involving domain subject matter experts to create the following resources, or to identify
existing resources that can be reused or modified for your domain:
▪ Annotation guidelines and examples to help human annotators learn how words and
passages in your domain content are to be annotated.
▪ Type systems that define the domain-specific types (objects) and features (data
classifications) that can be discovered in your domain content through text analysis. The
type system controls the types of annotations that a human annotator can add to
documents.
▪ Dictionaries of terms that are to be treated as equivalent terms in your domain content.
2. Creating a corpus of documents that are representative of your domain content.
Uempty
3. Pre-annotating documents based on the dictionaries that you add to a Knowledge Studio
workspace.
This is an optional activity to make the process of human annotation easier. Instead of starting
from scratch, it creates a base on which the human annotators can build.
After you create a machine learning model, you can use the model to pre-annotate new
documents that you add to the corpus. Pre-annotation is a process of machine-annotating a
document to the extent possible before a machine learning model is available to do so.
Pre-annotation can reduce human-annotation labor by replacing some human annotation
creation with mere verification of the correctness of machine annotation.
4. Annotating documents by human annotators. Documents are divided among human
annotators, who then use the IBM Watson Knowledge Studio ground truth editor tool to
manually add annotations to small sets of documents. Humans annotate mentions, relations,
and co-references. The annotated documents are used as training and testing data for the
machine learning model.
5. Comparing the human annotation results and resolving conflicts. Adjudication in this phase is
needed to ensure accurate and consistently annotated documents are promoted to ground
truth, where they can be used to train and test a machine learning model.
Reference:
Adding documents for annotation
https://github.com/IBM-Bluemix-Docs/watson-knowledge-studio/blob/master/documents-for-a
nnotation.md
Uempty
Model development
• This stage refers to the use of Knowledge Studio tools to create the model.
• After the ground truth is generated, the human annotation results are used to train an
algorithm for automatically adding annotations to large collections of documents, such as
collections that include millions of documents.
• Model development involves the following activities:
1. Selecting the document sets that you want to use to train the model.
> Note: Only documents that became ground truth through approval or adjudication can be used to train the machine
learning model.
2. Specifying the percentage of documents that are to be used as training data, test data, and blind
data.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
This stage refers to the use of Knowledge Studio tools to create a model. After establishing ground
truth, the human annotation results can be used to train an algorithm for automatically adding
annotations to large collections of documents, such as collections that include millions of
documents.
Model development involves the following activities:
1. Selecting the document sets that you want to use to train the model.
Note: Only documents that became ground truth through approval or adjudication can be
used to train the machine learning model.
2. Specifying the percentage of documents that are to be used as training data, test data, and
blind data.
The documents that you add to the system must be allocated to the following system-level data
sets when you create a machine learning model:
• Training set: A set of documents that was annotated through pre-annotation or by human
annotators that is used to train the model. The goal of the training set is to teach the machine
learning model about correct annotations, which includes teaching the model through text
that was not annotated.
• Test set: A set of annotated documents that is used to test the trained model. After you run a
test on the test set, perform a detailed diagnostic-purposed error analysis of the results. Close
analysis helps you find weaknesses in the current model that can be addressed.
Uempty
• Blind set: A set of annotated documents that is set aside and used to test the system
periodically after several iterations of testing and improvement have occurred. To prevent
accuracy from being tainted (for example, by making changes base only on annotations in
known documents), blind data should be data that has not previously been viewed by users
that were involved with creating the model. Reported results should come only from tests that
are run on blind data. After you run a test on the blind set, look at only the most high-level
scores, such as the overall mention and relation F1 scores. You do not want to learn too many
details about the performance, or it might influence the improvements that you choose to
make to the model.
The goal of Knowledge Studio is to enable large teams to work together to build models. As such,
it assumes that models are being produced by a team that includes a group of human annotators
and a separate person or group of people that builds and tests the model, and makes
improvements to it. Due to this assumption, the application is configured to push an equally
proportioned grouping of documents from a single document set into the test, train, and blind
sets. However, if your team is not segregated (for example, the people doing human annotation
are also reviewing model test results in detail), then you might need to change the allocation of
documents in these sets to more explicitly separate the documents that are being used in each
one.
Why do I need a blind set?
Because you use test data to assess accuracy in detail, you get to know the documents and their
features after a while. For example, you start to know which entity types, relation types, and text
types in the documents are best understood by the machine learning model, and which are not.
This information is important because it helps you focus on making the right improvements, that
is, refining the type system, supplementing the training data to fill gaps, or adding dictionaries. As
the test documents are used iteratively to improve the model, they can start to influence the
model training indirectly. For this reason, the "blind" set of documents is very important.
You can review the annotations that are made on the test set. Infer which are undertrained
entities and cycle through the steps again to provide better training material for these entities.
Uempty
Model evaluation
• This stage refers to the use of Knowledge Studio tools to refine the model and improve
performance.
• Model evaluation involves the following activities:
1. Evaluating the results that are generated by the model against a test set of ground truth documents:
> Accuracy analysis to identify the causes of annotation errors.
> Headroom analysis to assess which errors require focus and where model refinements can yield the greatest
impact.
2. Reviewing the annotations that were added by the trained model to determine whether any
adjustments must be made to the model to improve its ability to find valid entity mentions, relation
mentions, and coreferences in the documents.
3. Making adjustments repeatedly to improve performance until a satisfactory level of accuracy is
achieved.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
This stage refers to the use of Knowledge Studio tools to refine the model and improve
performance. The results that are generated by the model are evaluated against a test set of
ground truth documents.
• Accuracy analysis identifies the causes of annotation errors.
• Headroom analysis helps you assess which errors require focus and where model refinements
can yield the greatest impact.
After you determine areas in which the model is having trouble, take steps to improve its
performance.
Adjustments can be made repeatedly to improve performance until a satisfactory level of
accuracy is achieved.
Uempty
Model deployment
• This stage refers to exporting components that enable the model to run in machine learning
runtime environments and making the model accessible to other Watson applications.
• You can deploy the machine learning model for use by:
Watson Natural Language Understanding
Watson Discovery
• Model deployment involves the following activities:
1. Creating a snapshot of the current model.
2. Deploying the model to Watson Discovery or Watson Natural Language Understanding services
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
This stage refers to exporting components that enable the model to run in machine learning
runtime environments and making the model accessible to other Watson cognitive applications.
When you are satisfied with the performance of the model, you can leverage the machine learning
model that you trained with Knowledge Studio by making it available for use by:
• IBM Watson Natural Language Understanding service
• IBM Watson Discovery service
You can deploy or export a machine learning model. A dictionary or Natural Language
Understanding pre-annotator can be used only to pre-annotate documents within Knowledge
Studio.
Model deployment involves the following activities:
1. Creating a snapshot of the current model. This versions the model, which enables you to
deploy one version, while you continue to improve the current version. The option to deploy
does not appear until you create at least one version.
2. Deploying the model to Watson Discovery or Watson Natural Language Understanding
services.
Uempty
Knowledge
curation
Model Model
development evaluation
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
The following points summarize the end-to-end domain adaptation process with Watson
Knowledge Studio:
• Adapting an AI system to a new domain, requires an iterative process with continuous
improvements to increase the performance of the system. This iterative process aims to reach
a level of incremental accuracy performing activities such as adding new functionalities,
testing the system, identifying opportunities to improve the performance, doing headroom
analysis, and finding possible solutions for the most frequent errors. The process requires the
collaboration of domain experts, data scientists, natural language processing (NLP) experts,
and machine learning developers.
• The creation of a model is an iterative multiple-step process that involves several stages:
knowledge curation, ground truth generation, model development, model evaluation, and
model deployment to runtime environments.
• Some tasks are performed outside Knowledge Studio and involve human experts to perform
activities to ensure that the collected data that will be used to train the model is relevant to
the domain, of high quality, and includes the right number of representative documents.
Uempty
• Knowledge Studio provides tools and artifacts to:
▪ Guide human annotators while performing manual annotations.
▪ Pre-annotate documents to bootstrap human annotations.
▪ Evaluate annotations by multiple human annotators and generate the ground truth for your
domain.
▪ Create models.
▪ Evaluate the performance of the trained model.
▪ Deploy the model to Watson Discovery and Watson Natural Language Understanding.
• Domain adaptation is a continuous improvement process, which requires an ongoing effort to
improve the performance of the model. Domain adaptation is the primary purpose of
Knowledge Studio.
Uempty
Uempty
Review questions
1. True or False: Rule-based models are efficient for complex text extraction that has variations.
2. True or False: In Watson Knowledge Studio, machine learning models are used for complex
text extraction that has variations.
3. The following Watson service cannot be trained by using Knowledge Studio.
a. Watson Assistant
b. Watson Natural Language Understanding
c. Watson Discovery
4. True or False: A ruled based model can be used to pre-annotate documents to speed up the
human annotation process.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Uempty
5. ____ groups words and phrases that should be treated equivalently by a model.
a. Ruled-based model
b. Ground truth
c. Dictionary
d. Machine learning model
e. Type system
6. ___ is a collection of vetted data used to adapt a Watson solution to a particular domain.
a. Ruled-based model
b. Ground truth
c. Dictionary
d. Machine learning model
e. Type system
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Uempty
Review answers
1. True or False: Rule-based models are efficient for complex text extraction that has
variations.
2. True or False: In Watson Knowledge Studio, machine learning models are used for complex
text extraction that has variations.
3. The following Watson service cannot be trained by using Knowledge Studio.
a. Watson Assistant
b. Watson Natural Language Understanding
c. Watson Discovery
4. True or False: A ruled based model can be used to pre-annotate documents to speed up the
human annotation process.
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
1. False. Rule-based models are efficient for recognizing patterns in unstructured data. Machine
Uempty
6. ___ is a collection of vetted data used to adapt a Watson solution to a particular domain.
a. Ruled-based model
b. Ground truth
c. Dictionary
d. Machine learning model
e. Type system
Introduction to IBM Watson Knowledge Studio © Copyright IBM Corporation 2018, 2022
Uempty
Exercise: Creating a machine learning model with Watson
Knowledge Studio
Figure 9-35. Exercise: Creating a machine learning model with Watson Knowledge Studio
Uempty
Exercise • This exercise helps you understand the process for building a
machine learning model that you can later deploy and use with other
objectives Watson services.
• After completing this exercise, you should be able to:
Create a workspace for Knowledge Studio.
Configure the workspace resources.
Create document sets.
Pre-annotate documents.
Create tasks for human annotators.
Analyze the inter-annotator agreement and adjudicate conflicts.
Create machine learning models.
Uempty
Overview
This unit provides a high level introduction to chatbots, chatbot applications, and guidelines to
consider when designing a chatbot.
Uempty
Uempty
Uempty
10.1.Chatbots overview
Uempty
Chatbots overview
Uempty
What is a chatbot
• Software that interacts with the user in natural language.
• The application can have a chat interface.
• The conversation medium may be in text, speech, or both.
• Some example applications are customer support, sales activities, or entertainment.
A chatbot is software that interacts with the user through a chat interface by using natural
language. The conversation might be in text, speech, or both. The chatbot chats with the user to
assist with applications like customer support, sales activities, or entertainment.
Uempty
Uempty
Another example of a chatbot is one that supports customers with their inquiries or even helps
junior customer support agents with their job. IBM uses Watson technology (Watson Assistant) to
create chatbots for those purposes.
Uempty
Chatbot history
• Bots passing the Turing test.
• ELIZA and PARRY did not use speech.
• SmarterChild was the predecessor to Siri, and was created by ActiveBuddy, Inc.
Uempty
2010: Siri
Siri emerged in 2010 as a personal assistant feature of Apple iOS. Siri can search for answers on
the web, create reminders, alarms, and events, call people, and much more.
2012: Google Now
In 2012, Google Now emerged, appearing as a feature in Google search. It delivered information
to users based on predictions of what they might be interested in knowing.
2015: Amazon Alexa and Microsoft Cortana
In 2015, Amazon Alexa, the virtual assistant behind Amazon Echo, and Microsoft Cortana
emerged.
2016: Chatbots
Facebook started a messaging platform enabling developers to create chatbots that can interact
with Facebook users. Today, there are more than 33,000 chatbots on Facebook Messenger alone.
Uempty
Why now
• Rising popularity and high usage of messenger applications, such as WhatsApp, Facebook
Messenger, and Slack
• Recent breakthroughs in the AI field
• Advancements in speech recognition
• Growing popularity of cloud computing and APIs
It seems that chatbots have become popular in recent years. Why now?
There are different reasons for the increase in the prevalence of chatbot:
• Rising popularity and high usage of messenger applications, such as WhatsApp, Facebook
Messenger, and Slack.
• Recent breakthroughs in the AI field make it possible to develop intelligent chatbots that can
communicate with users in human language and learn from their interaction with users.
Chatbots can learn over time to provide more accurate and intelligent responses.
• Advancements in speech recognition make it possible to take human speech as input and
enable users to have more natural interaction with computers.
• The growing popularity of cloud computing and APIs that provide integration capabilities
make it possible for AI vendors to make AI services easily available to developers on the
cloud. Developers can integrate chatbots into various applications and ensure reliable
communication between the chatbot and the application by using APIs.
Uempty
Popular chatbots
• DoNotPay chatbot for legal advice by Joshua Browder.
• Joshua Browder was named “Robin Hood of the internet” by the BBC.
• He used the IBM Watson Assistant service to improve the chatbot’s accuracy by 30%.
The DoNotPay chatbot is a popular chatbot. It was created by a 19-year old Stanford student who
is named Joshua Browder, whom is called “Robin Hood of the internet” by the BBC.
Browder used a natural language interface to gather the data that is needed to complete the form.
He also used the IBM Watson Assistant service to improve that chatbot’s accuracy by 30%.
Uempty
Uempty
10.2.Chatbots design
Uempty
Chatbots design
Uempty
Chatbot design
• The basic goals of conversational interaction for chatbots are:
• Help users.
• Manage user expectations.
• Achieve the purpose of the solution.
• Keep the user engaged.
• Extract insights about the users.
• Reinforce the brand of the client.
• Increase sympathy and forgiveness in users.
• Make the solution look clever.
Conversational interaction in the chat between the chatbot and the user takes place by
exchanging natural language messages. Conversational interaction has an important role to play
because it must help the customer understand how the chatbot can help them while managing
expectations.
It is important to design the conversation correctly and appropriately for the type of chatbot
solution and target audience. Not all solutions need the same amount of conversational
interaction, but if you do not deliberately design the conversational interaction, you will not fully
realize the potential of the solution to address the needs of your clients. If clients do not see
enough value from the chatbot solution, they are unlikely to continue to use it.
The basic goals of conversational interaction are:
• How to help users and manage their expectations.
• Help achieve the purpose of the solution and drive value.
• Encourage the user to keep using the chatbot.
• Derive usable insights about the users.
• Reinforce the brand of the client.
• Increase sympathy and forgiveness in users.
• Make the solution look clever.
Uempty
To achieve these goals, the dialog must be carefully designed to use the appropriate language and
a suitable approach. Designing the chatbot is the part that is most removed from development.
The result of this design is the overall impression of the chatbot on the user.
Here are key factors to consider in the conversational design:
• Positioning
• Tone and personality
Uempty
To achieve your chatbot design goals, you must define different aspects about how to design your
chatbot .
The first concept to consider is positioning. Positioning determines how the solution should relate
to the user, and behave when interacting with the user. The positioning of the chatbot is a
collective term that covers these three aspects:
• Purpose
• Viewpoint
• Proactivity
Uempty
Uempty
Viewpoint:
Viewpoint is the role that the chatbot solution should adopt in relation to the end user. As a
designer, ask yourself:
• Who is the audience? (for example, students, prospect clients, users of your product, tourists,
and so on)
• Who does the chatbot speak on behalf of? (for example, an employee who speaks on behalf of
the company, as an advocate or friend to the user who speaks on behalf of the tourism
organization, a tutor or teacher who speaks on behalf of a school or university, and so on.)
The relationship that the bot will have with the user should be decided upon in light of achieving
the purpose previously determined: Does the chatbot represent a salesperson? an entertainer? a
teacher? an enforcer or regulator? a companion or friend?
Viewpoint can be determined through these questions:
• What role should the solution play in the relationship between the client and the user?
• Should the chatbot present itself as an employee who speaks on behalf of the client and is
aligned with the client interests?
• Should the chatbot present itself as an advocate or friend to the user who can access the
client’s information to help the user?
Uempty
Some examples of roles or viewpoint are:
• Assistant
• Friend
• Coach
• Motivator
• Salesperson
Another question is, who is the audience? Are they students, prospect clients, users of a product,
or others?
Uempty
Proactivity is the degree to which the solution proactively engages and guides the user instead of
reacting to the user, that is, waiting for the user to ask a question.
A chatbot can be:
• Proactive: The chatbot reaches out to the user by asking questions, offering information and
choices, and guiding the user through processes.
• Reactive: Apart from a welcome message (and perhaps one or two other statements), your
chatbot waits for the user to ask a question. It does not prompt, encourage, or suggest.
• Combination: In specific circumstances, the chatbot reaches out to the user, asking questions
and guiding the user through processes. At other times, the chatbot waits for the user to ask a
question.
Uempty
Imagine a scenario where a chatbot is acting as a customer service employee on behalf of a bank.
The following conversation represents a proactive chatbot:
• Customer: When can I receive my new credit card?
• Chatbot: An SMS will be sent to your phone after it is ready.
• Chatbot: The bank is collaborating with XYZ to provide benefits to our credit card users. Would
you be interested in knowing more?
The chatbot answers when asked, but also reaches out to the customer and offers suitable
suggestions.
Uempty
Uempty
Tone and personality: Represents the voice in which the chatbot solution speaks. Do not confuse
tone and personality with viewpoint, which is whom the chatbot speaks on behalf.
Examples:
• Informal and friendly tone: “Hi there, how can I help you?”
• More formal, still friendly: “Good morning. How may I help you today?”
• Formal, not very friendly: “This is a service that is designed to answer your questions. How
may I assist you?”
Uempty
Uempty
You should determine the kind of personality that your users like better or feel more comfortable
interacting with when designing your chatbot.
Personality is affected by the choice of words for the chatbot’s responses.
You can construct a complete character persona for your chatbot.
A common feature that is often in chatbots is humor. Humor can increase the user's
understanding and forgiveness when your chatbot cannot understand something. It might even
delight the user and increase their satisfaction with the chatbot.
Uempty
Here are two examples of tone and personality for the purpose:
• If the purpose is to engage users proactively and encourage them to act, a friendly, informal
tone will be more successful than a formal or authoritative tone.
• If the purpose is to provide information or guidance about a serious topic, a casual, chatty tone
might undermine the credibility of the information that is provided.
Uempty
Here are some examples for tone and personality for viewpoint:
• If the viewpoint is that of an employee, the tone and personality should closely reflect the
client’s ideal staff member.
• If the viewpoint is that of a partially or fully independent advocate or guide for the user, then
the tone and personality should not be that of enforcer or authority figure. Instead, it should
be more like an advisor, assistant, or coach.
Uempty
If the solution is highly proactive, either an overly formal or overly casual and chatty tone may
cause a negative reaction because the former might feel artificial and the latter is likely to become
annoying.
Consider the appropriate tone and personality for special cases. There might be special cases
where the tone response might differ from the rest of the solution. For example, if there are
responses that use offensive language:
• The chatbot can shift to an “enforcer” viewpoint and adopt a more formal tone.
• You may keep a count of the number of sensitive inputs and respond with an increasingly
strong-worded response.
• You may shut down the chat (in the case of threats and offensive language).
Uempty
Some of the issues that developers or designers face while designing chatbots include the
following ones:
1. Trying to do too much within a single chatbot, which can lead to a loss of value: You must
understand the limitations of a chatbot. It must have a narrow scope that is well-defined and
well-bounded. It is not a chitchat.
2. Users will be disappointed by incorrect or nonsensical responses: To avoid this issue,
acknowledge limitations and do not be afraid to have the chatbot say, “I don’t know”, and give
some suggestions of questions that they can ask.
3. Detect frustration, and handle it: If the users are frustrated, this issue should be addressed.
A good example response can be: “I can see that this isn’t going very well. Would you like to
talk to a real person?” Some interactions are too complex for a software solution to handle.
Detecting situations that are out of the scope of your chatbot and handing them off to a human
quickly (before you waste the user’s time) is a better approach.
Uempty
10.3.Chatbots tools and services
Uempty
Uempty
You can create chatbots by using cognitive services to help you design how your chatbot
understands user’s input and replies to the user. You can also use software to configure a chatbot
that is already trained and programmed to answer specific questions from users in areas such as
customer support.
Here are examples of some available tools and services:
• IBM Watson Assistant.
• Dialogflow: Google-owned developer of human-computer interaction technologies that are
based on natural language conversations.
• Microsoft Language Understanding Intelligent Service (LUIS).
• ChatScript: Written in C++.
• Chatfuel: A platform for creating AI chatbots for Facebook.
Uempty
References:
chatfuel
https://chatfuel.com/
ChatScript
https://en.wikipedia.org/wiki/ChatScript
Dialogflow
https://dialogflow.com/
Dialogflow
https://en.wikipedia.org/wiki/Dialogflow
Language Understanding (LUIS)
https://www.luis.ai/
Uempty
Uempty
Review questions
1. True or False: If a chatbot provides information or guidance about a serious topic, then using
a casual, chatty tone is a recommended.
2. True or False: Advancements in NLP and AI are key factors in the emergence of chatbots.
3. True or False: A chatbot that reaches out to the user by asking questions and offering
information is considered reactive by design.
4. True or False: There are two types of viewpoint: lean forward and lean backward.
5. True or False: Chatbots reaching out to the user by asking questions are considered lean
forward chatbots.
1. False.
2. True.
3. False.
4. False.
5. True
Uempty
Uempty
Review answers
1. True or False: If a chatbot provides information or guidance about a serious topic, then using
a casual, chatty tone is a recommended.
2. True or False: Advancements in NLP and AI are key factors in the emergence of chatbots.
3. True or False: A chatbot that reaches out to the user by asking questions and offering
information is considered reactive by design.
4. True or False: There are two types of viewpoint: lean forward and lean backward.
False: There are two types of proactivity: lean forward and lean backward.
5. True or False: Chatbots reaching out to the user by asking questions are considered lean
forward chatbots.
1. False.
2. True.
3. False.
4. False. There are two types of proactivity: lean forward and lean backward.
5. True.
Uempty
Uempty
Overview
This unit covers the core concepts that you need to understand to build a chatbot with IBM
Watson Assistant.
Uempty
Uempty
Uempty
11.1.Watson Assistant experiences
Uempty
Watson Assistant
experiences
Uempty
Use IBM Watson Assistant to build your own branded live chatbot, which is known as an assistant,
into any device, application, or channel.
Your chatbot, which is also known as an assistant, connects to the customer engagement
resources you already use to deliver an engaging, unified problem-solving experience to your
customers.
Watson Assistant provides two experiences to build assistants:
• New Watson Assistant experience
• Classic Watson Assistant experience
Uempty
The new experience refers to the Watson Assistant build experience that was announced on
October 7, 2021.
Watson Assistant was revamped to make it easier and faster to build, publish, and improve a
chatbot.
The new Watson Assistant has a build experience that is tailored to the people who directly
interact with customers daily, such as customer service representatives and customer-care.
The new experience is focused on using actions to build customer conversations,
Steps within the action represent back-and-forth interactions between your assistant and your
customer.
The new Watson Assistant automatically handles things that might go wrong during a
conversation, such as topic changes, vague requests, misunderstandings, and asking for a human
agent.
The new Watson Assistant navigation is more intuitive and follows the order of the steps that are
recommended to get your assistant live.
Uempty
References:
The new Watson Assistant announcement – October 7 2021
https://cloud.ibm.com/docs/assistant?topic=assistant-release-notes#assistant-oct072021
Welcome to the new Watson Assistant (documentation)
https://cloud.ibm.com/docs/watson-assistant
FAQs about the new IBM Watson Assistant experience
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-watson-assistant-faqs#f
aqs-new-experience
Comparing actions and dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-comparing-actions-dialo
g
Migrating to the new experience
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-overview
Switching between new and classic experiences
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-switch-experience
Uempty
The classic experience refers to the Watson Assistant build experience that was available before
the new experience was announced in October 2021.
No matter what the specific purpose of your chatbot is, some core fundamentals are always
involved:
• Skills
• Intents
• Entities
• Dialog
Each of these functions and their application to the Watson Assistant service are explained in
detail in the Classic Watson Assistant topic
The dialog component is optional because some chatbots are developed to answer user questions
in a question-and-answer manner that is similar to the approach that is used to answer frequently
asked questions (FAQs).
These chatbots need to understand only what the user is asking and reply with the proper answer.
Chatbots that are meant to answer FAQs do not have to engage in a conversation with the user
and therefore they do not need a dialog component.
Customers that built their assistants by using the classic experience can migrate to the new
experience or remain in the classic experience.
A dialog-based conversation is the best choice when you want greater control over the logic of the
flow.
The dialog flow uses an if-then-else style structure that might be familiar to developers, but not to
content designers or customer-care experts.
Uempty
References:
About Watson Assistant
https://cloud.ibm.com/docs/assistant?topic=assistant-index
Migrating to the new experience
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-overview
Comparing actions and dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-comparing-actions-dialo
g
Switching between new and classic experiences
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-switch-experience
FAQ
https://cloud.ibm.com/docs/assistant?topic=assistant-faqs
Uempty
11.2.New Watson Assistant
Uempty
New Watson
Assistant
Uempty
The new Watson Assistant experience is focused on using actions to build customer
conversations. It is designed to make it simple enough for anyone to build a virtual assistant.
Building, testing, publishing, and analyzing your assistant can all now be done in one simple and
intuitive interface.
New navigation provides a workflow for building, previewing, publishing, and analyzing your
assistant.
• Each assistant has a home page with a task list to help you get started.
• Build conversations with actions, which represent the tasks that you want your assistant to
help your customers with.
▪ Each action contains a series of steps that represent individual exchanges with a customer.
• When you publish, you can review and debug your work in a draft environment before you go
live to your customers.
• Use a new suite of analytics to improve your assistant.
▪ Review which actions are being completed to see what your customers want help with,
determine whether your assistant understands and addresses customer needs, and
decide how can you make your assistant better.
Switching the experience
You can easily switch back and forth between the new experience and the classic experience.
However, the new experience provides a simplified user interface, an improved deployment
process, and access to the latest features.
Uempty
References:
Welcome to the new Watson Assistant
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-welcome-new-assistant
Watson Assistant documentation
https://cloud.ibm.com/docs/watson-assistant
FAQs about the new IBM Watson Assistant experience.
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-watson-assistant-faqs#f
aqs-new-experience
Getting started with Watson Assistant
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-getting-started
Migrating to the new experience.
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-overview
Switching between new and classic experiences
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-switch-experience
Uempty
Like a human personal assistant, the assistant you build helps your customers perform tasks and
answer questions. To accomplish this, you define actions and steps for the assistant.
An action is a problem or a task that your customer wants to resolve. For example, paying a bill,
getting an invoice, getting the balance in a bank account, withdrawing money, saying hello, or
asking about the weather might all be an action in your assistant.
An action represents a discrete outcome that you want your assistant to be able to accomplish in
response to a user's request. An action comprises the interaction between a customer and the
assistant about a particular question or request. This interaction begins with the user input that
starts the action (for example, ”I want to withdraw money”). It might then include additional
exchanges as the assistant gathers more information, and it ends when the assistant carries out
the request or answers the customer's question.
A step is a back-and-forth interaction between the assistant and the customer.
Steps represent the clarification questions, final answers, or human agent handoff points in the
action.
Everything else that the step needs to function like the flow logic, response options, or storage of
the user’s response is contained within the step.
In the example that is shown in the slide, the assistant asks clarification questions before it hands
the conversation over to an agent (with the account number as context) for a cable bill. For
internet or phone bills the assistant guides the user to the online billing portal.
Uempty
An action consists of one or more steps. The steps in an action define the conversation turns that
follow the initial customer input that triggered the action. In a simple case, a step might consist of
a direct answer to a question from the customer; for example, if the customer asks “What are your
business hours?”, a one-step action might reply with “We are open Monday through Friday from 9
AM to 5 PM”.
More commonly, an action requires multiple steps to fully understand the customer's request. For
the example, If the customer says “I want to pay my cable bill” the assistant needs more
information such as “what is your account number?” Each of these follow-up questions
represents a step in the action.
Information
For step-by-step instructions on the Billing Assistant scenario that is described in this
presentation, see the tutorial “Getting Started with the New Watson Assistant: The Build Guide
Part I” at
https://www.ibm.com/blogs/watson/2021/12/getting-started-with-the-new-watson-assistant-p
art-i-the-build-guide/
References:
Getting Started with the New Watson Assistant: The Build Guide Part I
https://www.ibm.com/blogs/watson/2021/12/getting-started-with-the-new-watson-assistant-p
art-i-the-build-guide/
Getting Started with the new Watson Assistant: Plan It
https://www.ibm.com/blogs/watson/2021/11/getting-started-with-the-new-watson-assistant-p
lan-it/
Overview: Editing actions
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-build-actions-overview
Uempty
Actions benefits
• Using actions is the best choice when you want to approach the assistant with a focus on
content.
• The process of creating a conversational flow is easier. People who have expertise with
customer care can write the words that your assistant says.
• Actions provide better visibility into the customer's interaction and satisfaction with the
assistant.
• The conversation designer doesn't have to manage data collected during the conversation. By
default, your assistant collects and stores information for the duration of the current action.
• Many people can work at the same time in separate, self-contained actions. The order of
actions within a conversation doesn't matter.
Using actions is the best choice when you want to approach the assistant with a focus on content.
Actions offers the following benefits:
• The process of creating a conversational flow is easier. People who have expertise with
customer care can write the words that your assistant says. With a simplified process anyone
can build a conversation. You don't need knowledge about machine learning or programming.
• Actions provide better visibility into the customer's interaction and satisfaction with the
assistant. Because each task is discrete and has a clear beginning and ending, you can track
user progress through a task and identify snags.
• The conversation designer doesn't have to manage data collected during the conversation. By
default, your assistant collects and stores information for the duration of the current action.
You don't need to take extra steps to delete saved data or reset the conversation. But if you
want, you can store certain types of information, such as the customer's name, for the
duration of a conversation.
• Many people can work at the same time in separate, self-contained actions. The order of
actions within a conversation doesn't matter. Only the order of steps within an action matters.
And the action author can use drag and drop to reorganize the steps in the action for optimal
flow.
Reference:
Comparing actions and dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-comparing-actions-dialo
g
Uempty
Uempty
3. Give your assistant a name that describes the group of topics it covers. In this example, Billing
Assistant. Choose the language it uses to respond to your customers and click Create
assistant.
4. The Home page of your assistant is displayed.
Uempty
Actions represent the tasks or questions that your assistant can help customers with. Each action
has a beginning and an end, making up a conversation between the assistant and a customer.
When you create a new action, Watson Assistant prompts you for an example of the customer’s
input that starts the action.
1. From the navigation panel on the left click Actions to create a new action and then click
Create a new action.
2. In the “New action” window, at the prompt "What does your customer say to start this
interaction?", type an example of your customers interactions for this action. In this example,
“I want to pay my cable bill please”.
Uempty
Now it’s time to create the first step in the bill pay interaction.
1. Step 1 is already created for you.
2. Select the step to edit it and add the clarification question in the “assistant says” text box. In
this example, “What type of account are we talking here?”.
3. Then, select the type of customer response that the assistant should wait for. In this case,
Options is the best choice.
Uempty
4. Add the three options for Cable, Internet, and Phone, and apply your changes.
Finally, the first step looks as shown in the figure on the right.
Uempty
Uempty
The steps in an action define the conversation turns that follow the initial customer input that
triggered the action. In a simplest case, a step might consist of a direct answer to a question from
the customer; for example, if the customer asks. What are your business hours?, a one-step action
might reply with “We are open Monday through Friday from 9 AM to 5 PM”.
Usually, an action requires multiple steps to fully understand the customer's request.
For example, if the customer wants to pay a bill, the assistant needs to know the account number.
If the customer asks, “I want to withdraw money”, the assistant needs more information:
• Which account should the money come from?
• What is the amount to withdraw?
Each of these follow-up questions represents a step in the action.
In this example:
1. Add Step 2 below Step 1 by clicking New step.
2. In the “Assistant says” field, type the clarification question to ask for the account number,
“What’s your account number?”.
3. Select Number from the response drop-down list as the type of customer response.
Uempty
Next, you need to add some flow logic to the flow. In this example, given the way that this flow
works, an account number should be gathered only for cable bills. To handle this scenario, you
need to add a condition to your step. To do that, change the step to be taken with conditions
instead of without.
Conditions are basically requirements, which must be met for the step to be triggered. In this
case, you want to condition on the answer to step 1 being “Cable” but not Internet or Phone. To
set it up, make sure that you have the condition set to step 1 = Cable.
Uempty
Now, you need to add the last steps to provide the outcome to the user.
1. Add step 3 under step 2.
2. Enter some text related to getting the user to an agent to pay their bill. For example, “Let me
get you to an agent who can help you pay your cable bill!.”
3. Condition step 3 on “step 1 = Cable” as you did in step 2.
4. For this step, you don’t need to gather any information from the user, so you can leave the
“Define customer response” section empty.
5. Now, set up the assistant to route this conversation to a human agent. Change the And then
setting to Connect to agent (connect to a human agent), which also ends the action when it
hands off.
Uempty
Figure 11-20. Inserting the context to pass to the human agent – Step 3
In the prompt that comes up, you insert the context that you gathered for the human agent to
review. Namely, the fact that the customer wants to pay their Cable bill and the account number.
Hint
To insert the content of the variables that you collected into text, start with the “$” sign and a
quick select box appears as shown in the figure.
Insert the context that you gathered for the human agent to review.
• The customer wants to pay their Cable bill.
• The account number. Select step 2 (the account number) as the field that you want to insert
• Apply your changes.
Uempty
The slide shows the completed step 3, which derives the customer to a human agent and passes
the context that is collected from the user.
Uempty
Add a final step to wrap up the conversation. Step 4 tells the customer, “To pay your <type of bill>
bill, you can head to our online portal <link to portal>”
To insert a variable like the type of bill to be paid, click the Insert a variable button that is located
over the text box.
Uempty
To add a link to the text, highlight the text that you want to use and then click the Link button.
Enter the URL in the “Insert link” window.
The settings for the link look like the figure.
Uempty
Next, make sure that this step only runs for an Internet or Phone bill. To accomplish this goal,
create a condition on “step 1 = Internet.” Then, add another condition for “step 1 = Phone.”
Ensure that this step is triggered when Any of these conditions are met (not All of them.)
Uempty
Finally, make sure that the action ends after this step is reached. Change the “And then” setting to
End the action.
Uempty
Your steps now are completed and look like shown in the figure.
Click Try it to test a few scenarios.
Uempty
Try it out (1 of 2)
Try a few scenarios. Notice that when you state the type of bill up front, the assistant skips the
question about the type of bill and moves immediately to the next step.
Uempty
To see how your assistant would really work on one of your channels, open the preview page.
The preview page is a representation of your “draft” work in progress and has an inline preview for
you to test. You can also share your work with others on your team quickly with a sharable URL
Uempty
11.3.Classic Watson Assistant
Uempty
Classic Watson
Assistant
Uempty
Hint
Want to get started with actions, but need features that are available from a dialog? Use both.
Dialog is your primary conversation with users, but you can call an action from your dialog to
perform a discrete task. For more information see Calling actions from a dialog at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action
Uempty
References:
Comparing actions and dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-comparing-actions-dialo
g
Annotation-based method - Contextual entities
https://cloud.ibm.com/docs/assistant?topic=assistant-entities#entities-annotations-overview
Handling Watson Assistant response types
https://www.ibm.com/docs/en/voice-gateway?topic=states-handling-watson-assistant-respons
e-types
Response type image
https://www.ibm.com/docs/en/voice-gateway?topic=states-handling-watson-assistant-respons
e-types#wa_response_type_image
Understanding dialog skill digressions
https://cloud.ibm.com/docs/assistant?topic=assistant-tutorial-digressions
Webhook overview
https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-overview
Uempty
Components
Classic Watson Assistant main components:
• Assistants
• Dialog skills
• Intents
• Entities
• Dialog
Uempty
Assistant
Assistant:
• A cognitive bot that you can customize for your business needs.
• A dialog is activated from the assistant settings.
• The assistant can be deployed through multiple interfaces, such as:
Messaging channels, like Slack and Facebook Messenger.
A simple chat widget on a website or on an existing company web page.
A custom application, such as a mobile app or a robot with a voice interface.
Assistants
An assistant is a cognitive bot that you can customize for your business needs and deploy across
multiple channels to help your customers where and when they need it.
You customize the assistant by adding to it the skills that it needs to satisfy your customers' goals.
Activate a dialog skill that can understand and address questions or requests with which your
customers typically need help. You provide information about the subjects or tasks that your
users ask about and how they ask about them. Then, the service dynamically builds a machine
learning model that is tailored to understand the same and similar user requests.
You can deploy the assistant through multiple interfaces, including:
• Existing messaging channels, such as Slack and Facebook Messenger.
• You can give your users access to the assistant through a simple chat widget that you publish
to a website or add to an existing company web page.
• You can design a custom application that incorporates it by making direct calls to the
underlying APIs.
Uempty
Dialog skill
Dialog skill:
• Acts as a container for all of the artifacts and training data.
• A skill contains the following types of artifacts:
Intents
Entities
Dialog
• A skill uses the training data to build a machine learning model to recognize similar user
inputs.
When you add or change the training data, the training process is triggered to ensure that the
underlying model stays up to date.
Skill
Sometimes referred to as dialog skill.
A Dialog skill acts as a container that contains the training data and logic that enables an assistant
to help your customers.
It contains the following types of artifacts:
• Intents
• Entities
• Dialog
As you add information, the data is used to build a machine learning model that can recognize
these and similar user inputs. Each time that you add or change the training data, the training
process is triggered to ensure that the underlying model stays up-to-date as your customer needs
and the topics they want to discuss change.
Uempty
Intent
Intent:
• Represents the purpose of or goal of a user's input.
• Tends to be general, such as a question about business location or a bill payment.
• For intent creation:
Plan the intents for application. Define an intent for each type of user request that you want your
application to support.
Teach Watson Assistant about your intents. Supply many examples of user input and indicate the
intents to which they map.
• In the tool, the name of an intent is always prefixed with ’#’. For example, #payment or
#inquiry.
Intent
An intent represents the purpose of a user's input, such as a question about business locations or
a bill payment.
Plan the intents for an application: Consider what your customers might want to do and what
you want your application to be able to handle on their behalf. For example, you might want your
application to help your customers make a purchase. If so, you can add a #buy_something intent.
You define an intent for each type of user request that you want your application to support.
Teach Watson Assistant about your intents: After you decide the business requests that you
want your application to handle for your customers, you must teach Watson Assistant about them.
For each business goal (such as #buy_something), you must provide at least 10 examples of
utterances that your customers typically use to indicate their goal. For example, “I want to make a
purchase.”
Ideally, find real-world user utterance examples that you can extract from existing business
processes. The user examples should be tailored to your specific business. For example, if you are
an insurance company, your user examples might look more like this, “I want to buy a new XYZ
insurance plan.”
To train the dialog skill to recognize your intents, supply many examples of user input and indicate
to which intents they map. The examples that you provide are used by the service to build a
machine learning model that can recognize the same and similar types of utterances and map
them to the appropriate intent.
In the tool, the name of an intent is always prefixed with the # character.
Start with a few intents and test them as you iteratively expand the scope of the application.
Uempty
Intent (cont.)
Intent examples:
• “Good morning” -> #greeting.
• “Where can I find the nearest restaurant?” -> #location_info.
• “Where can I pay my electric bill?” -> #location_info.
• Remember: Intents represent what the user wants to achieve: a goal, an action, or verbs.
Intent examples:
• “Good morning” -> #greeting
• “Where can I find the nearest restaurant?” -> #location_info
• “Where can I pay my electric bill?” -> #location_info
Remember: Intents represent what the user wants to achieve: a goal, an action, or verbs.
Uempty
Entity
Entity
• Represents a term or object that is relevant to the user’s intent and that provides a specific
context for an intent.
• If intents represent verbs (the action a user wants to do), entities represent nouns (the object
of, or the context for that action).
• By recognizing the entities that are mentioned in the user's input, the service can reply with a
more targeted response or perform a required action.
• In the tool, the name of an entity is always prefixed with ’@’. For example, @street or
@contact_info.
Entity
Entities represent information in the user input that is relevant to the user's purpose.
If intents represent verbs (the action a user wants to do), entities represent nouns (the object of,
or the context for, that action). For example, when the intent is to get a weather forecast, the
relevant location and date entities are required before the application can return an accurate
forecast.
Entities represent a class of object or a data type that is relevant to a user’s purpose. By
recognizing the entities that are mentioned in the user's input, the service can reply with a more
targeted response or perform a required action.
Uempty
Entity evaluation
• The Assistant service looks for terms in the user input by using exact matching of values,
synonyms, or patterns that are defined for the entities.
• Synonym entity:
Specify a bunch of synonyms, that is, words that have exact or similar meanings.
For example, for the entity value Blue, its synonyms can be Aqua, Navy, and Cyan.
• Pattern entity:
You specify a regular expression that defines the pattern for mentions.
For example, for email patterns such as name@ibm.com, the pattern can be:
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b
The Assistant service looks for terms in the user input that match the values, synonyms, or
patterns that you define for the entity:
• Synonym entity: Synonyms are words or phrases that mean exactly or nearly the same as the
corresponding entity. You define a category of terms as an entity (color), and then one or more
values in that category (blue). For each value, you specify several synonyms (aqua, navy, and
cyan). At run time, the service recognizes terms in the user input that exactly match the values
or synonyms that you defined for the entity as mentions of that entity.
• Pattern entity: You define a category of terms as an entity (contact_info), and then define one
or more values in that category (email). For each value, you specify a regular expression that
defines the textual pattern of mentions of that value type. For an email entity value, you might
want to specify a regular expression that defines a text@text.com pattern.
This email regex example can capture all mentions of emails in their proper format.
At run time, the service looks for patterns matching your regular expression in the user input,
and identifies any matches as mentions of that entity.
Uempty
System entity: A synonym entity that is prebuilt for you by IBM. They cover commonly used
categories, such as numbers, dates, and times. You simply enable a system entity to start using it.
Uempty
Dialog
Dialog
• A dialog is a branching conversation flow that defines how your application responds when it
recognizes the defined intents and entities.
• The dialog is made up of nodes that are chained together in a tree structure (graphically).
• Each node includes conditions for the node to be active, and also an output object that defines
the response that is provided.
• Think of the node as an if-then construction: If this condition is true, then return this response.
User
Dialog
A dialog is a branching conversation flow that defines how your application responds when it
recognizes the defined intents and entities.
The dialog is made up of nodes that define steps in the conversation.
Dialog nodes are chained together in a tree structure (graphically).
Each node includes conditions for the node to be active, and also an output object that defines the
response that is provided.
Think of the node as an if-then construction: If this condition is true, then return this response.
Condition: Specifies the information that must be present in the user input for this node in the
dialog to be triggered.
Response: The utterance that the service uses to respond to the user.
Uempty
Dialog (cont.)
Dialog (cont.)
• A single node with one condition and response can handle simple user requests.
• To handle more complex tasks, you can add child nodes to ask the user for additional
information.
Dialog
A single node with one condition and response can handle simple user requests.
To handle more complex tasks, you can add child nodes to ask the user for additional information.
A child node is processed after its parent node. NODE 1 is the parent node for CHILD NODE 1 and
CHILD NODE 2.
Some useful definitions:
• A root node is a node that does not depend on other nodes. In the example, NODE 1 is a root
node.
• A child node is a node that depends on another node, its parent node. The parent node is
processed first, and based on that processing, the child node is either processed or not.
Uempty
Conditions
Conditions
• Logical expressions that are evaluated to true or false.
• A node condition determines whether that node is used in the conversation.
• Conditions usually evaluate the intents and entities that are identified in the user responses,
but they can also evaluate information that is stored in the context.
Conditions
Conditions are logical expressions that are evaluated to true or false. A node condition determines
whether that node is used in the conversation or to choose among the possible responses to the
user.
Conditions usually evaluate the intents and entities that are identified in the user responses, but
they can also evaluate information that is stored in the context.
Uempty
Responses
Responses:
• The dialog response defines how to reply to the user.
• The dialog response consists of the messages that are based on the identified intents, entities,
or context that are communicated to the user when the dialog node is activated.
• You can add variations to the response for a more natural experience.
Responses
Responses are messages that are based on the identified intents and entities that are
communicated to the user when the dialog node is activated. You can add variations of the
response for a more natural experience or add conditions to pick one response out of many in the
same dialog node.
The figure shows an example of adding different variations for greetings if the node is triggered by
a greeting intent from the user.
Uempty
Rich responses
Rich responses:
• In addition to the default response type of text, you can return other interactive response
types to enhance the user experience.
• The following response types are supported:
Image: Embeds an image into the response.
Option: Adds a list of one or more options.
Pause: Forces the application to wait for a specified number of milliseconds before continuing with
processing.
Rich responses
In addition to the default response type of text, you can return responses with multimedia or
interactive elements, such as images or clickable buttons to simplify the interaction model of your
application and enhance the user experience.
The following response types are supported:
• Image: Embeds an image into the response.
• Option: Adds a list of one or more options. When a user clicks one of the options, an
associated user input value is sent to the service. How options are rendered can differ
depending on where you deploy the dialog. For example, in one integration channel, the
options might be displayed as clickable buttons, but in another they might be displayed as a
drop-down list.
• Pause: Forces the application to wait for a specified number of milliseconds before continuing
with processing. You can choose to show an indicator that the dialog is working on typing a
response. Use this response type if you need to perform an action that might take some time.
Uempty
In a single dialog node, you can provide different responses, each one triggered by a different
condition. Use this approach to address multiple scenarios in a single node.
In this example, the service uses information that it collected earlier about the user's location to
tailor its response and provide information about the store nearest the user. The conditional
responses are based on context values.
This single node now provides the equivalent function of four separate nodes.
Uempty
Slots
Add slots to a dialog node to gather multiple pieces of information from a user within that node.
Slots collect information at the users' pace. Details that the user provides are saved, and the
service asks only for the details the use did not provide.
Example:
The user wants to reserve a table in a restaurant. The needed information is the number of guests,
the date, the time, and the name of the restaurant. When asked, the user might provide values for
multiple slots at once. For example, the input might include the information, ”There will be 6 of us
dining at 7 PM”. This one input contains two of the missing required values: the number of guests
and time of the reservation. The service recognizes and stores both of them, each one in its
corresponding slot. It then displays the prompt that is associated with the next empty slot, which
in this case asks the user, “Where would you like to eat?” to determine the restaurant slot and
stores the response. After the user replies, the service asks, “What day will this take place?” to
determine the date slot, stores it, and gives a reply.
Uempty
Dialog flow
Dialog flow
• The dialog standard flow is processed from top to bottom and left to right.
• Triggered by a successful condition.
• It ends when it reaches the last node in the branch that it is following.
User input
Match
Uempty
Dialog depiction
This diagram shows a mockup of a dialog tree that is built with the GUI dialog builder tool. It
contains two root dialog nodes. A typical dialog tree would likely have many more nodes, but this
depiction provides a glimpse of what a subset of nodes might look like.
The first root node has conditions for an intent value. It has two child nodes and each have a
condition on an entity value. The second child node defines two responses. The first response is
returned to the user if the value of the context variable matches the value that is specified in the
condition. Otherwise, the second response is returned.
This standard type of node is useful to capture questions about a certain topic and then in the root
response ask a follow-up question that is addressed by the child nodes. For example, it might
recognize a user question about discounts and ask a follow-up question about whether the user is
a member of any associations with which the company has special discount arrangements. The
child nodes provide different responses based on the user's answer to the question about
association membership.
The second root node is a node with slots. It also has conditions on an intent value. It defines a set
of slots, one for each piece of information that you want to collect from the user. Each slot asks a
question to elicit the answer from the user. It looks for a specific entity value in the user's reply to
the prompt, which it then saves in a slot context variable.
This type of node is useful for collecting details that you might need to perform a transaction on
the user's behalf. For example, if the user's intent is to book a flight, the slots can collect the origin
and destination location information, travel dates, and so on.
Uempty
You can easily switch back and forth between the new experience and the classic experience.
However, the new experience provides a simplified user interface, an improved deployment
process, and access to the latest features.
To switch between the new and classic experiences, following these steps:
1. From the Watson Assistant interface, click the Manage icon to open your account menu.
2. Select Switch to classic experience or Switch to new experience from the account menu.
You don’t lose any work if you switch to a different experience, and other users of the same
instance are not affected. However, keep in mind that any work you do in one experience is not
available in the other experience. You can switch back and forth at any time.
References:
Switching the experience
https://cloud.ibm.com/docs/watson-assistant#welcome-new-assistant-switch-experience
Switching between new and classic experiences
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-switch-experience
Uempty
11.4.Migrating to the new experience
Uempty
Uempty
If you are using a Watson Assistance instance that you created before October 2021, you might
still be using the classic Watson Assistant experience. To take advantage of the latest features,
consider switching to the new experience.
Consider the following questions to decide which experience you want to use:
• Do you want to build a new actions-based assistant?
The new experience provides a simplified user interface that was designed around actions,
and an improved deployment process. If you plan to build an actions-based assistant, use the
new experience for access to the latest features and improvements.
• Are you working on an existing assistant built in the classic Watson Assistant?
If you have a dialog-based assistant that was built by using the classic Watson Assistant, and
you are not currently planning to migrate to an actions-based assistant, you might still want to
consider migrating it to the new experience so you can take advantage of the new process for
publishing and deploying your assistant. Migrating to the new experience also makes it easy
for you to begin using actions when you are ready.
For more information about how to migrate a dialog-based assistant to the new experience,
see Activating dialog and migrating skills at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-activate-dialog
• Do you want to convert an existing dialog-based assistant to use actions?
If you have a dialog-based assistant, but you want to reimplement it to use actions instead,
start by migrating it to the new experience. You can then start to use actions alongside your
dialog, and you can replace your dialog nodes with actions at your own pace.
For more information about using a dialog with actions, see Calling actions from a dialog at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action
Uempty
References:
Migrating to the new experience
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-overview
New Watson Assistant - Deployment process overview
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-publish-overview
Activating dialog and migrating skills
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-activate-dialog
Calling actions from a dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action
Uempty
Downloading intents
You can download an intent to a CSV file, so you can then upload and reuse the examples as
example phrases in the new Watson Assistant experience.
1. Go to the Intents page.
2. Select the intent that you want to download, and then click the Download icon .
3. Specify the name and location in which to store the CSV file that is generated, and then
click Save.
4. Upload the examples from the intent as example phrases for a specific action in the new
Watson Assistant.
For more information, see Uploading phrases
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-understand-questions#u
nderstand-questions-uploading-examples
Uempty
Downloading entities
You can download a number of entities to a CSV file, so you can then upload and reuse them as
saved customer responses in the new Watson Assistant experience.
1. Go to the Entities page.
2. Select the entities that you want to download, and then click the Download icon .
3. Specify the name and location in which to store the CSV file that is generated, and then
click Save.
4. Upload the entities as saved customer responses in the new Watson Assistant. For more
information, see Uploading saved customer responses at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-info#uploadin
g-saved-customer-response
References:
Migrating intents and entities
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-migrate-intents-entities
Uploading phrases
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-understand-questions#u
nderstand-questions-uploading-examples
Uploading saved customer responses
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-collect-info#uploading-s
aved-customer-response
Uempty
Activating dialog
• To use an existing dialog skill, activate
the dialog feature in your assistant.
• To activate the dialog feature in the
new experience:
1. Create or open an assistant where you
want to use a dialog as the primary
conversation with users.
2. Open Assistant settings.
3. Click Activate dialog.
4. In the confirmation that displays,
click Activate dialog again.
To use an existing dialog skill, activate the dialog feature in your assistant. Then, you can upload
your existing skill.
Activating dialog
To activate the dialog feature in the new experience:
1. Create or open an assistant where you want to use a dialog as the primary conversation with
users.
2. Open Assistant settings.
3. Click Activate dialog.
4. In the confirmation that displays, click Activate dialog again.
References:
Activating dialog and migrating skills
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-activate-dialog
Downloading a skill
https://cloud.ibm.com/docs/assistant?topic=assistant-skill-tasks#skill-tasks-download
Uempty
Migrating skills
• Once the dialog feature is activated, you can start a new
dialog conversation from scratch. Or if you have an existing
dialog skill, you can migrate it to the new Watson Assistant.
• To migrate an existing dialog skill:
1. Use the classic experience to download your dialog skill in
JSON format.
2. In the new Watson Assistant, open the Dialog page.
3. In Options, choose Upload / Download.
4. On the Upload tab, upload the JSON file for your dialog skill.
Uempty
In the new Watson Assistant, you can use actions with your primary dialog conversation. A dialog
feature takes precedence over actions. You can use actions to supplement a dialog-based
conversation, but the dialog drives the conversation with users to match their requests.
A dialog node calls an action to perform a task and then return to the dialog. From a single dialog
node, you can make a call to either a webhook or an action, not both. Choose the approach that
best suits your needs:
• Call an action if you want to perform a discrete and self-contained task, and then return to the
dialog to be ready to address any new user requests. Data that is collected from the user
during action processing must be stored as a session variable for it to be passed to the dialog.
• Call a webhook if you want to send a request to a web service to complete a task and return a
response that can be used later by this dialog. For more information, see Extending your
assistant with webhooks.
Note
Uempty
References:
Calling actions from a dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action
Extending your assistant with webhooks
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-overview
Adding a call to an action
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action#dialog
-call-action-add
Uempty
ň Note ņņņņņņņņņņņņņņņņņ
For step-by-step instructions, see “Adding a call to an action” at https://cloud.ibm.com/docs/watson-
assistant?topic=watson-assistant-dialog-call-action#dialog-call-action-add
Ŋņņņņņņņņņņņņņņņņņņņņ
You might want to call an action from a dialog in the following scenarios:
• You want to perform an action from multiple dialog threads.
For example, you want to ask customers how satisfied they are with your service. You can
define a single action to check customer satisfaction and call it from multiple branch-ending
dialog nodes.
In this scenario, you don't need to define an intent, such as #check_satisfaction. The action is
called automatically, replacing a jump to another dialog node's response.
• You want to see how actions works.
In this scenario, you can pick an intent for the action to handle. If you plan for the action to be
called from the dialog only, you can define the user examples for the intent that triggers the
dialog node. When you define the action, you can add one customer example only, reducing
the time that you need to spend building the action.
Note
Uempty
References:
Calling actions from a dialog
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action
Extending your assistant with webhooks
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-overview
Adding a call to an action
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-dialog-call-action#dialog
-call-action-add
Uempty
11.5.Enriching the chatbot
Uempty
Enriching the
chatbot
Uempty
Persona
• Creating a persona for your bot makes the bot friendlier and engages its users.
• You can create a bot persona by adding some distinguishing characteristics to your chatbot.
• Avatar: A face for your chatbot. A simple 2D graphic image, or even a 3D figure adds a nice
touch, along with a name.
Adding a gender is not always a good idea. Generally, the chatbot should be gender-neutral, such as a
friendly android (robot) or a friendly pet like a cat or a bird.
• A voice: Makes a chatbot more interactive and adds value to its personality.
Easy to implement because of the many available text to speech services.
Although it might be clear to the user that they are talking to a chatbot, creating a persona makes
the bot friendlier and engages its users. You can create a bot persona by providing some
distinguishing characteristics to your chatbot. For example, adding the following features can help
to accomplish this goal:
• Avatar
An avatar adds a face to your chatbot. A simple 2D graphic image adds a nice touch, along with
a name. Adding a gender is not always a good idea. Generally, the chatbot should be
gender-neutral, such as a friendly android (robot) or a friendly pet like a cat or a bird.
• A voice
Adding a voice to your chatbot makes it more interactive and adds value to its personality.
Doing so requires almost no effort because most text to speech services can be added to your
existing output response text to transform it into audio.
Uempty
• Sentiment analysis can map user emotion input to a positive, negative, or neutral status. It
adds emotion to your chatbot. Your chatbot can sense the user’s positive comment and react
to it, or sense a negative input and direct the conversation appropriately.
• Tone analysis can perform more advanced interpretation of the user’s mood. For example, it
can detect whether the user is frustrated or thankful. The chatbot can then reply with a
customized answer to each mood, giving your bot emotional AI that adds to its personality and
makes it friendlier.
Uempty
Integrations page
• The page is organized into three
sections:
Essential channels. The
foundations of any assistant’s
ability to reach users. They are
web chat and phone.
Extensions. Customize your
assistant by adding Search
capabilities and connecting to
third-party APIs with the Build
custom extensions option.
Channels. Deploy your assistant to
Slack, Facebook Messenger and
SMS/WhatsApp with Twilio.
For your assistant to reach its potential as a comprehensive user solution, it needs to seamlessly
call out to and pull information from a wide variety of web apps.
Managing all the possible channels, integrations, and extensions might seem daunting task, but
Watson Assistant simplifies the process with its Integrations page. The “Integrations” page
consolidates all of your channels, extensions, and third-party connections in one spot,
streamlining your ability to manage how and where users interact with your assistant.
To open the Integrations page, click the Integrations icon in the Watson Assistant home page.
The page is organized into three sections:
• Essential channels. The foundations of any assistant’s ability to reach users. They are web
chat and phone.
• Extensions. Customize your assistant by adding Search capabilities and connecting to
third-party APIs with the Build custom extensions option.
• Channels. Deploy your assistant to Slack, Facebook Messenger and SMS/WhatsApp with
Twilio.
References:
Watson Assistant Integrations: channel your knowledge
https://medium.com/ibm-watson/watson-assistant-integrations-channel-your-knowledge-909d
fecae26
Adding integrations
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-deploy-integration-add
Uempty
Essential channels constitute the foundations of any assistant’s ability to reach users. They are
web chat and phone. They are the most common methods of deploying assistants.
• Web chat is a code snippet that you can immediately embed in your website.
When you build a custom user interface for your assistant, you spend a lot of time and effort
writing code to solve typical UI problems. For example, you must keep up with browser
support changes, manage scrolling behavior, validate input, and design the layout and styling.
The time that you spend designing and maintaining the UI can be better spent building a
quality assistant instead. When you use the web chat integration, Watson Assistant manages
the user interface, so you can focus on designing conversational exchanges that address the
unique business needs of your customers.
• Phone integration. By adding the phone integration to your assistant, you can make your
assistant available to customers over the phone. When you add the phone integration to your
assistant, you can automatically generate a working phone number that is automatically
connected to your assistant. Or, if you prefer, you can connect the assistant to your existing
infrastructure by configuring an existing Session Initiation Protocol (SIP) trunk.
When your customer makes a phone call by using the telephone number connected to your
assistant, the phone integration answers. The integration converts output from your assistant
into voice audio by using the IBM Watson Text to Speech service. The audio is sent to the
telephone network through the SIP trunk. When the customer replies, the voice input is
converted into text by using the IBM Watson Speech to Text service.
Uempty
Note
References:
Web chat overview
https://cloud.ibm.com/docs/assistant?topic=assistant-web-chat-basics
Integrating the web chat with your website
https://cloud.ibm.com/docs/assistant?topic=assistant-deploy-web-chat
Integrating with phone
https://cloud.ibm.com/docs/assistant?topic=assistant-deploy-phone
Uempty
Integrations: Extensions
• Add features or content to your assistant custom or pre-built extensions.
Requires an OpenAPI document (formerly known as Swagger), which is an open standard for
describing and documenting REST APIs.
• Search integration gives your assistant access to corporate data collections that it can mine for
answers (Plus plan).
If you need to integrate your assistant with an external service that has a REST API, you can build
a custom extension by importing an OpenAPI document (previously known as Swagger).
After you create a custom extension, you can connect it to an assistant as an integration. In your
actions, you can then define steps that interact with the external service by calling the extension.
For more information about connecting a custom extension to an assistant, see Add a custom
extension at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-add-custom-extension.
You can put your subject matter expertise to work by adding search. The search integration gives
your assistant access to corporate data collections that it can mine for answers.
When a search integration is added, your assistant can route complex customer inquiries to the
IBM Watson Discovery service. Discovery treats the user input as a search query. It finds
information that is relevant to the query from an external data source and returns it to the
assistant. With search integration, the assistant can query existing company documents or data to
see whether any useful information can be found and shared with the customer.
Note
Uempty
References:
Add a custom extension
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-add-custom-extension
OpenAPI Specification
https://swagger.io/specification/
Watson Assistant Extensions Starter Kit
https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/extensio
ns
Adding a search integration
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-search-add
Uempty
Integrations: Channels
• Deploy your assistant to third-party channels to expand your reach.
• Messaging with you assistant through messaging apps:
Facebook Messenger
Slack
SMS with Twilio
WhatsApp with Twilio
The final section of the “Integrations” page contains quick links to configure your assistant for
deployment to four of the most widely used digital messaging apps:
• Facebook Messenger
• Slack
• SMS with Twilio
• WhatsApp with Twilio
By using an existing account with these services, you can make your assistant available through
these apps in a matter of minutes.
References:
Adding integrations
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-deploy-integration-add
Watson Assistant Integrations: channel your knowledge
https://medium.com/ibm-watson/watson-assistant-integrations-channel-your-knowledge-909d
fecae26
Uempty
Speech recognition
• You can use IBM, Google, and Microsoft speech to text services to enable your chatbot to
understand user speech.
• This feature is heavily used in home automation chatbots and automation tasks in general.
For example, in Microsoft Windows you can give commands to Cortana by using your voice without
touching a key or pressing a mouse button. You can do the same with Siri on the Apple iPhone.
With advancements in speech to text technology, you can use IBM, Google, and Microsoft speech
to text services to enable your chatbot to understand user speech.
This feature is heavily used in home automation chatbots and automation tasks in general. For
example, in Microsoft Windows you can give commands to Cortana by using your voice without
touching a key or pressing a mouse button. You can do the same with Siri on the Apple iPhone.
Uempty
Uempty
Review questions
1. True or False: In Watson Assistant, Skill can contain one or more entities.
2. True or False: In Watson Assistant, @type is an example of an intent.
3. True or False: The dialog flow is from top to bottom and left to right.
4. Which of the following response types can be used in a dialog node?
a. Image
b. Text
c. Option
d. All the above
Uempty
6. A branching conversation flow that defines how your chatbot responds when it recognizes the
input from the user.
a. Intent
b. Dialog
c. Condition
d. Entity
Uempty
Uempty
11.True or False: The new Watson Assistant experience is built around Dialog.
Uempty
Review answers
1. True or False: In Watson Assistant, Skill can contain one or more entities.
2. True or False: In Watson Assistant, @type is an example of an intent.
3. True or False: The dialog flow is from top to bottom and left to right.
4. Which of the following response types can be used in a dialog node?
a. Image
b. Text
c. Option
d. All the above
Uempty
6. A branching conversation flow that defines how your chatbot responds when it recognizes the
input from the user.
a. Intent
b. Dialog
c. Condition
d. Entity
Uempty
Uempty
11.True or False: The new Watson Assistant experience is built around Dialog.
Uempty
Uempty
Exercise • This exercise introduces IBM Watson Assistant and walks you
through the process of creating a very simple chatbot with Watson
objectives Assistant.
• After completing this exercise, you should be able to:
Create a Watson Assistant service instance.
Create a Watson Assistant dialog skill.
Add intents.
Build a dialog.
Uempty
Uempty
Uempty
Exercise: Exploring the new Watson Assistant: Creating a
retail customer service chatbot
Figure 11-77. Exercise: Exploring the new Watson Assistant: Creating a retail customer service chatbot
Uempty
Exercise • This exercise introduces the new Watson Assistant capabilities and
walks you through the process of creating actions with steps,
objectives conditions, and variables for a retail customer service chatbot.
• After completing this exercise you should be able to:
• Create a Watson Assistant service instance.
• Create actions.
• Create actions with conditions.
• Create actions with variables.
Uempty
Overview
This unit provides a high-level introduction to computer vision (CV).
Uempty
Uempty
Computer vision is a branch of science that is concerned with processing images to extract,
analyze, and understand useful information from a single image or image sequence. It aims to
create an artificial (computer) system that can achieve the capabilities of a human visual system
so that the machine can “see”.
CV uses various machine learning algorithms to analyze images for scenes, objects, faces, and
other content in videos, photos, and pictures in general.
References:
The British Machine Vision Association
https://britishmachinevisionassociation.github.io/
What is computer vision?
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=computer%20vision
%20history
Uempty
Computer vision needs lots of data. It runs analyses of data over and over until it discerns
distinctions and ultimately recognize images. For example, to train a computer to recognize
automobile tires, it needs to be fed vast quantities of tire images and tire-related items to learn
the differences and recognize a tire, especially one with no defects.
Two essential technologies are used to accomplish this goal: a type of machine learning
called deep learning and a convolutional neural network (CNN).
Machine learning uses algorithmic models that enable a computer to teach itself about the
context of visual data. If enough data is fed through the model, the computer will “look” at the
data and teach itself to tell one image from another. Algorithms enable the machine to learn by
itself, rather than someone programming it to recognize an image.
A CNN helps a machine learning or deep learning model “look” by breaking down images into
pixels that are given tags or labels. It uses the labels to perform convolutions (a mathematical
operation on two functions to produce a third function) and makes predictions about what it is
“seeing.” The neural network runs convolutions and checks the accuracy of its predictions in a
series of iterations until the predictions start to come true. It is then recognizing or seeing images
in a way similar to humans.
Much like a human making out an image at a distance, a CNN first discerns hard edges and simple
shapes, then fills in information as it runs iterations of its predictions. A CNN is used to understand
single images. A recurrent neural network (RNN) is used in a similar way for video applications to
help computers understand how pictures in a series of frames are related to one another.
Uempty
References:
What is computer vision?
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=computer%20vision
%20history
Deep learning
https://www.ibm.com/cloud/watson-studio/deep-learning
What is deep learning?
https://www.ibm.com/cloud/learn/deep-learning?mhsrc=ibmsearch_a&mhq=deep%20learning
#toc-what-is-de-6i8FHi1_
What are convolutional neural networks?
https://www.ibm.com/cloud/learn/convolutional-neural-networks#toc-what-are-c-MWGVhUiG
Uempty
Different types of neural networks address specific problems or data sets. For example,
Convolutional neural networks (CNNs), are used primarily in computer vision and image
classification applications. CNNs can detect features and patterns within an image, enabling
tasks, like object detection or recognition. In 2015, a CNN bested a human in an object
recognition challenge for the first time.
Recurrent neural network (RNNs) are typically used in natural language and speech recognition
applications as they leverage sequential or times series data.
Much like a human making out an image at a distance, a CNN first discerns hard edges and simple
shapes, then fills in information as it runs iterations of its predictions. A CNN is used to understand
single images. A recurrent neural network (RNN) is used in a similar way for video applications to
help computers understand how pictures in a series of frames are related to one another.
Uempty
References:
What is computer vision?
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=computer%20vision
%20history
Deep Learning
https://www.ibm.com/cloud/learn/deep-learning?mhsrc=ibmsearch_a&mhq=deep%20learning
#toc-what-is-de-6i8FHi1_
Recurrent Neural Networks (RNNs)
https://www.ibm.com/cloud/learn/recurrent-neural-networks
Convolutional neural networks (CNNs),
https://www.ibm.com/cloud/learn/convolutional-neural-networks
Uempty
The slide shows a brief timeline that depicts the most important milestones in computer vision
research and development.
Reference:
The history of computer vision
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=computer%20vision
%20history
Uempty
Uempty
Social commerce: Use an image of a house to find similar homes that are for sale.
Social listening: Use images from your product line or your logos to track buzz about your
company on social media.
Retail: Use the photo of an item to find its price at different stores.
Education: Use pictures to find educational material on similar subjects.
Public safety: Automated license-plate reading.
Do you know of or heard of any other applications?
Reference:
Computer vision
https://www.research.ibm.com/artificial-intelligence/computer-vision/
Uempty
Image classification sees an image and can classify it (a dog, an apple, a person’s face). More
precisely, it can accurately predict that an image belongs to a certain class. For example, a social
media company might want to use it to automatically identify and separate objectionable images
that are uploaded by users.
The demo shows what you can do with a video and a simple model. Notice that instead of images,
it was built by using a video, which is just a sequence of images (frames). The current frame is
either recognized as a hotdog or not.
A CV task represents a well-defined problem in CV that can be solved to a certain extent or
accuracy by using one method or another.
Object detection and recognition deals with locating and detecting certain patterns within the
image. For example, detecting red eyes when taking photos in certain conditions. Other
applications include face detection and face recognition.
A CV task is also used in tracking objects, for example, tracking a ball during a football match,
tracking the movement of a cricket bat, or tracking a person in a video.
References:
Binary image classification demo
https://developer.ibm.com/developer/default/articles/introduction-computer-vision/images/hot
dognothotdog.gif
What is computer vision?
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=object%20detection
Introduction to computer vision
https://developer.ibm.com/articles/introduction-computer-vision/
Uempty
Object tracking is a deep learning application that follows the changes in the position of a target
object from one frame to another within an image sequence or video.
Follows or tracks an object once it is detected. This task is often run with images that are captured
in sequence or real-time video feeds. Example: Autonomous vehicles need to not only classify and
detect objects such as pedestrians, other cars, and road infrastructure, they need to track them in
motion to avoid collisions and obey traffic laws.
“Detect, track, and count cars in a video” provides an example to show you how the object
tracking code pattern is used for object detection along with object tracking to annotate a video
and count cars.
This code pattern shows you how to create and use a classifier to identify objects in motion and
then track the objects and count them as they enter designated regions of interest.
Uempty
References:
Detect, track, and count cars in a video
https://github.com/IBM/powerai-counting-cars/blob/master/README.md#detect-track-and-cou
nt-cars-in-a-video
Cars detected demo GIF
https://raw.githubusercontent.com/IBM/powerai-counting-cars/master/doc/source/images/out
put-video-as-gif.gif
Computer vision
https://en.wikipedia.org/wiki/Computer_vision
APA citation for image: Sidenbladh, H., Black, M. J., & Fleet, D. J. (2000, June). Stochastic
tracking of 3D human figures using 2D image motion. In European conference on computer vision
(pp. 702-718). Springer, Berlin, Heidelberg.
What is computer vision
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=object%20detection
Introduction to computer vision
https://developer.ibm.com/articles/introduction-computer-vision/
Uempty
Content-based image retrieval or “query-by image content” (QBIC) is the retrieval of images
from a database by using an image as a query. IBM was one of the pioneers in developing QBIC at
the IBM Almaden Research Center. "Content-based" refers to actual feature contents of the
image like colors, shapes, and textures. Other image retrieval systems rely on image metadata
such as keywords, tags, or descriptions that are associated with the image instead of image
content. Content-based image retrieval is preferred because searches that rely purely on
metadata depend on the quality of annotation.
Content-based image retrieval uses computer vision to browse, search, and retrieve images from
large data stores, based on the content of the images rather than metadata tags associated with
them. This task can incorporate automatic image annotation that replaces manual image tagging.
These tasks can be used for digital asset management systems and can increase the accuracy of
search and retrieval.
Optical character recognition (OCR): Scan papers and hand-written forms, identify the
characters in them, and transform them into digital format (strings).
References:
Content-based Multimedia Information Retrieval: State of the Art and Challenges
http://www.ugmode.com/prior_art/lew2006cbm.pdf
What is computer vision?
https://www.ibm.com/topics/computer-vision?mhsrc=ibmsearch_a&mhq=object%20detection
Digital Asset Management
https://www.ibm.com/topics/digital-asset-management
Uempty
Image restoration: Fixing and restoring images that are corrupted by noise, such as motion blur,
to their default state.
Scene reconstruction: Creation of 3D model by supplying the system with multiple 2D images
from different views. The computer constructs a 3D model based on those images.
References:
Computer vision
https://en.wikipedia.org/wiki/Computer_vision
APA image citation: Sinha, S. N., Steedly, D., Szeliski, R., Agrawala, M., & Pollefeys, M. (2008,
December). Interactive 3D architectural modeling from unordered photo collections. In ACM
Transactions on Graphics (TOG) (Vol. 27, No. 5, p. 159). ACM.
Uempty
This slide provides examples of open source tools for computer vision.
• OpenCV is an open source library that can be used to perform most computer vision tasks that
are required on several languages. It includes C++, Python, Java, and MATLAB interfaces.
• PyTorchCV is based on the PyTorch framework. It is used for various computer vision tasks. It
included a collection of pretrained models for image classification, segmentation, detection,
and pose estimation.
• scikit-image is an open source image-processing library for the Python programming
language. It includes algorithms for segmentation, geometric transformations, color space
manipulation, analysis, filtering, morphology, feature detection, and more. It is available free
of charge.
References:
pytorchcv 0.0.67
https://pypi.org/project/pytorchcv/
Scikit-image
https://scikit-image.org/
scikit-image
https://en.wikipedia.org/wiki/Scikit-image
Uempty
Several vendors, such as IBM, Microsoft, and Google provide computer vision offerings.
IBM Maximo Visual Inspection makes computer vision with deep learning more accessible to
business users. IBM Maximo Visual Inspection includes an intuitive toolset that empowers
subject matter experts to label, train, and deploy deep learning vision models, without coding or
deep learning expertise. It includes the most popular deep learning frameworks and their
dependencies, and it is built for easy and rapid deployment and increased team productivity. By
combining IBM Maximo Visual Inspection software with off the shelf mobile and edge devices,
enterprises can rapidly deploy a fully optimized and supported platform with excellent
performance.
Some of its benefits are:
• Improve uptime and reduce defects
Use deep learning to analyze processes and outputs to continually improve error and defect
detection and perform root-cause analysis.
• Enable quick action and issue resolution
AI can spot issues within milliseconds and can quickly alert the right resource to inspect,
diagnose, and rectify any issue, anywhere.
• Empower any subject matter expert
The streamlined user interface allows domain experts to easily bring data and train models.
Users with limited deep learning skills can build models for AI solutions.
For a list of use cases, see IBM Maximo Visual Inspection at
https://www.ibm.com/downloads/cas/K78GEROY
Uempty
References:
Getting started with IBM Maximo Visual Inspection
https://developer.ibm.com/series/learning-path-powerai-vision/?mhsrc=ibmsearch_a&mhq=Get
ting%20started%20with%20IBM%20Maximo%20Visual%20Inspection
IBM Maximo Visual Inspection
https://www.ibm.com/downloads/cas/K78GEROY
Uempty
IBM Cloud Annotations makes labeling images and training machine learning models easy.
To train a computer vision model you need a lot of images. Cloud Annotations supports uploading
both photos and videos.
A classification model can predict what an image is and how confident it is about its decision. An
object detection model can provide you with more information:
• Location: The coordinates and area of where the object is in the image.
• Count: The number of objects found in the image.
• Size: How large the object is relative to the image dimensions.
If an object detection model provides this extra information, why to use classification?
• Labor cost: An object detection model requires humans to draw boxes around every object to
train. A classification model requires only a simple label for each image.
• Training cost: It can take longer and require more expensive hardware to train an object
detection model.
• Inference cost: An object detection model can be much slower than real time to process an
image on low-end hardware.
Cloud Annotations is built on top of IBM Cloud Object Storage. Cloud object storage provides a
reliable place to store training data. It also opens up the potential for collaboration, letting a team
to simultaneously annotate the dataset in real-time.
Uempty
References:
Cloud Annotations
https://cloud.annotations.ai/
IBM Cloud Annotations documentation:
https://cloud.annotations.ai/docs
Uempty
Facial recognition is one of the most-used features of CV. It is often used in smartphones when
you take a photo or apply effects. Another widely used feature is tagging friends on social media.
These features use face recognition and facial identification, in which a face is recognized from
the image and identifies the person in the image. A facial recognition feature can recognize faces
in an image, as shown in the figure.
Uempty
Augmented reality (AR) is the manipulation and addition of a system-generated image (3D or 2D)
as an overlay of a user’s view. Examples include Google Glass, emoji filters in some mobile apps,
and Pokémon Go.
While in-store shopping accounts for 92 percent of retail volume, consumers are expecting the
same levels of personalization and customization that they do when they shop online; 58 percent
of consumers want in-store product information and 19 percent of consumers are already
browsing their mobile devices while in-store. CV and AR technology can bring all the benefits of
online shopping into traditional shops. By creating augmented reality mobile shopping
applications (apps), as shown in figure, in-store shoppers immediately learn about product details
and promotions through their mobile devices.
For more information on AR, watch the video “IBM augmented reality shopping app” at
https://youtu.be/EAVtHjzQnqY
Uempty
Uempty
Review questions
1. One of the following items is NOT an application of CV:
b. Real-time video stream analysis that includes targeted observations, such as facial recognition and
automated license-plate reading.
c. Use images from a manufacturing setting to make sure that products are being positioned correctly
on an assembly line.
d. Sentiment analysis by analyzing the words that are posted in social media channels.
Uempty
b. API.ai.
c. OpenCV.
d. PyTorchCV.
e. scikit-image
4. True or False: RNN can be used for video applications to help computers understand how
pictures in a series of frames are related to one another.
Uempty
Review answers
1. One of the following items is NOT an application of CV:
b. Real-time video stream analysis to include targeted observations, such as facial recognition and
automated license-plate reading.
c. Use images from a manufacturing setting to make sure that products are being positioned correctly
on an assembly line.
d. Sentiment analysis by analyzing the words that are posted in social media channels.
Uempty
3. Which of the following items are CV tools and services? (Select all that apply.)
a. Chatfuel.
b. API.ai.
c. OpenCV.
d. PyTorchCV.
e. scikit-image
f. All of the above
4. True or False: RNN can be used for video applications to help computers understand how
pictures in a series of frames are related to one another.
Uempty
Overview
This unit explains the basic steps of a typical computer vision (CV) pipeline, how CV analyzes and
processes images, and explores commonly used techniques in CV.
Uempty
Uempty
Uempty
13.1.Image representation
Uempty
Image
representation
Uempty
Image representation
• Images are stored as a 2D array of pixels on computers.
• Each pixel has a certain value that represent its intensity.
• Example of grayscale representation:
Image is black and white with shades of gray in between.
Pixel intensity is a number between 0 (black) and 255 (white).
It is important to understand how images are stored and represented on computer screens.
Images are made of grids of pixels, that is, a two-dimensional (2D) array of pixels, where each
pixel has a certain value that represents its intensity. A pixel represents a square of color on the
user’s screen. Colors can be represented in image in various ways.
If the image is grayscale, that is, black and white with shades of gray in between, the intensity is a
number in the range 0 - 255, where 0 represents black and 255 represents white. The numbers in
between these two values are different intensities of gray.
For example, in the picture in the slide, assume that you selected a small square from the image
(the part in the red square). The pixel representation for it is in black, white, and shades of gray. To
the right of the picture is the numeric values of these pixels in a 2D array.
Note
Uempty
References:
Data Representation
https://www.csfieldguide.org.nz/en/chapters/data-representation/
Colour Models
https://www.sqa.org.uk/e-learning/BitVect01CD/page_36.htm
Image reference
https://www.mathworks.com/help/examples/images/win64/SegmentGrayscaleImageUsingKMe
ansClusteringExample_01.png
Uempty
Many color models are available for colored images. The best-known model is RGB, where the
color of the pixels is represented as a mix of Red, Blue, and Green color channels. The value of the
pixel intensity is represented as three 2D arrays that represent the three color channels, where
each color value is in the range 0 – 255. The color value represents different intensities of the
colors and all the colors that you see on the screen. The number of color variations that are
available in RGB is 256 * 256 *256 = 16,777,216 possible colors.
Depending on the data structure used that image appears as
• Three 2D arrays, where each 2D array represents the values and intensities for one color. The
image is a combination of all three arrays.
• One 2D array, where each entry in the array is an object that contains three color values of
RGB.
References:
Data Representation
https://www.csfieldguide.org.nz/en/chapters/data-representation/
Colour Models
https://www.sqa.org.uk/e-learning/BitVect01CD/page_36.htm
How MATLAB Represents Pixel Colors
https://www.mathworks.com/company/newsletters/articles/how-matlab-represents-pixel-color
s.html
Uempty
13.2.Computer vision pipeline
Uempty
Computer vision
pipeline
Uempty
Feature
Image Pre-
Segmentation Extraction Classification
Acquisition Processing
& Selection
The steps and functions that are included in a CV system algorithm pipeline are highly dependent
on the application. The application might be implemented as a stand-alone part of a system and
might apply to only a certain step of the pipeline, or it can be a larger application, that is, an
end-to-end application that takes certain images and then applies all of the steps and functions in
the pipeline.
Reference:
Hardware Architecture for Real-Time Computation of Image Component Feature Descriptors on a
FPGA
https://www.researchgate.net/publication/273596152_Hardware_Architecture_for_Real-Time_
Computation_of_Image_Component_Feature_Descriptors_on_a_FPGA
Uempty
1. Image acquisition
Image acquisition is the process of acquiring images and saving them in a digital image format for
processing in the pipeline.
Images are acquired from image sensors, such as commercial cameras. Other types of
light-sensitive devices can be used to capture different types of images. Other image sensors
include radar, which uses radio waves for imaging.
Depending on the type of the device, the captured image can be 2D, 3D, or a sequence of images.
These images often use common formats, such as .jpeg, .png, and .bmp.
Images are stored as arrays of pixels according to their color model.
Reference:
System methods
https://en.wikipedia.org/wiki/Computer_vision#System_methods
Uempty
2. Pre-processing:
This stage focuses on preparing the image for the processing stage.
Examples:
• Images are resized as a form of normalization so that all images are the same size.
• Noise reduction reduces noise that represents false information in the image, as shown in the
slide.
• Contrast adjustment helps with the detection of image information. In the images of the little
girl, each image represents a different contrast adjustment.
Image source: https://www.mathworks.com/help/images/contrast-adjustment.html
Reference:
System methods
https://en.wikipedia.org/wiki/Computer_vision#System_methods
Uempty
3. Segmentation
The position of the image segmentation phase is not fixed in the CV pipeline. It might be a part of
the pre-processing phase or follow it or be part of the feature extraction and selection phase or
follow them.
Segmentation is one of the oldest problems in CV and has the following aspects:
• Partitioning an image into regions of similarity.
• Grouping pixels and features with similar characteristics together.
• Helps with selecting regions of interest within the images. These regions can contain objects
of interest that you want to capture.
• Segmenting an image into foreground and background to apply further processing on the
foreground.
Image citation: Cremers, D., Rousson, M., & Deriche, R. (2007). A review of statistical approaches
to level set segmentation: integrating color, texture, motion and shape. International journal of
computer vision, 72(2), 195-215.
Uempty
References:
Computer vision
https://en.wikipedia.org/wiki/Computer_vision
Computer Vision: Algorithms and Applications
http://www.cs.ccu.edu.tw/~damon/tmp/SzeliskiBook_20100903_draft.pdf
Segmentation of Images
http://www.cse.iitm.ac.in/~vplab/courses/CV_DIP/PDF/lect-Segmen.pdf
Uempty
Uempty
References:
Computer Vision Pipeline, Part 1: the big picture
https://freecontent.manning.com/computer-vision-pipeline-part-1-the-big-picture/
The Computer Vision Pipeline, Part 4: feature extraction
https://freecontent.manning.com/the-computer-vision-pipeline-part-4-feature-extraction/
Detection
https://en.wikipedia.org/wiki/Feature_(computer_vision)#Detectors
Edge Detection
https://www.mathworks.com/discovery/edge-detection.html
Computer vision
https://en.wikipedia.org/wiki/Computer_vision
Image reference: https://www.mathworks.com/discovery/edge-detection.html
Uempty
For feature extraction, all the features in the image that could be extracted are present. Now, start
selecting the features that are of interest. Some extracted features might be irrelevant or
redundant.
Here are some reasons to perform feature selection:
• Reduce the dimensions of the features that were extracted from the image.
• Avoid overfitting when training the model with the features.
• Create simpler models with less training time.
References:
Feature selection
https://en.wikipedia.org/wiki/Feature_selection
Application of high-dimensional feature selection: evaluation for genomic prediction in man
https://www.nature.com/articles/srep10312
Uempty
Uempty
Decision making
• Apply logic to make decisions based on detected images.
• Examples:
Security application: Grant access based on face recognition.
In a greenhouse environment, a notification is sent to the engineers to act if a plant is detected as
suffering from decay.
Decision making
After getting the output from the CV pipeline, users can apply logic that is based on the findings to
make decisions based on detected images.
For example, in security applications, the system can decide to grant access to a person if a face
that is detected is identified as the owner of a facility.
Another example is in a greenhouse environment, where a notification is sent to the engineers to
act if a plant is detected as suffering from decay.
Uempty
Uempty
Review questions
1. True or False: There is only one model to represent color in images, which is the RGB color
model.
2. True or False: In feature extraction, one of the reasons to perform feature selection is to avoid
overfitting when training the model.
3. True or False: In a CV pipeline, classification deals with extracting a measurable piece of data
in your image.
4. Which of the following items is not an example of feature extraction:
a. Shape
b. Color
c. Lines and edges
d. Noise
Uempty
Review answers
1. True or False: There is only one model to represent color in images, which is the RGB color
model.
2. True or False: In feature extraction, one of the reasons to perform feature selection is to avoid
overfitting when training the model.
3. True or False: In the CV pipeline, classification deals with extracting a measurable piece of
data in your image.
4. Which of the following items is not an example of feature extraction:
a. Shape
b. Color
c. Lines and edges
d. Noise
Uempty
Exercise: Using a basic deep neural network to solve an
image recognition problem
Figure 13-18. Exercise: Using a basic deep neural network to solve an image recognition problem
Uempty
Exercise • In this exercise, you use a simple deep neural network to solve an
image recognition problem. Here, the focus is more on the overall
objectives technique and use of a library than on perfecting the model.
• After completing this exercise, you should be able to:
Perform image recognition tasks by using deep learning.
Use Tensorflow and Keras libraries.
Prepare and preprocess an image data set.
Visualize data.
Build, compile, and train a neural network.
Make predictions and test a model.
Uempty
Overview
This unit explains the benefits of integrating multiple Watson services to build a comprehensive
intelligent solution. This unit presents examples of intelligent solutions use cases and introduces
their architecture and main integration points.
Uempty
Unit objectives • Explain the need to integrate multiple IBM Watson services to build
an intelligent solution.
• Describe the general flows for the integration of IBM Watson
Assistant with other services and applications.
• Explain the key capabilities that enable Watson Assistant
integration.
• Describe the flow to build a cognitive chatbot banking application by
integrating Watson Assistant, Watson Discovery, Watson Natural
Language Understanding, and back-end banking services.
• Describe the flow to build an intelligent procurement system by
integrating Watson Knowledge Studio and Watson Discovery.
• Describe the flow to build a movie recommender system by
integrating Watson Assistant, Watson Studio, Machine Learning, IBM
Db2 database and by using Node-RED flows.
Uempty
Uempty
14.1.Integrating IBM Watson services to build a
solution
Uempty
Integrating IBM
Watson services to
build a solution
This section describes the benefits of integrating multiple AI services and introduces typical
applications that you can create by combining multiple Watson services.
Uempty
Benefits
• A single Watson service adds artificial intelligence (AI) capabilities to the application in one
specific area.
• Integrating multiple Watson services adds more than one AI capability to the application,
which enhances the application with richer cognitive capabilities.
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Using one Watson service adds artificial intelligence (AI) capabilities to the application in one
specific area.
Integrating multiple Watson services adds more than one AI capability to the application, which
enhances the application with richer cognitive capabilities.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Watson services on IBM Cloud are a set of REST APIs. They are easy to use as a component of a
solution within an application. They must be integrated with various other parts of the solution so
that your users can interact with your instance of the Watson service.
The figure shows examples of applications that can be built by integrating multiple Watson
services:
• Sentiment, emotion, and tone analytics: This application integrates the Watson Natural
Language Understanding service with Twitter to process tweets from users and analyze
sentiment and emotion.
• Real-time transcription: This Android application performs real-time transcription and
translation by integrating IBM Watson Speech to Text, IBM Watson Text to Speech, and IBM
Watson Language Translator services.
• An application orchestrates the services integration and provides the logic of the solution.
Reference:
IBM architecture diagrams
https://www.ibm.com/cloud/architecture/architectures/edit/powerpoint
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Although IBM provides several assets to help the integration effort, such as Watson SDKs, API
references, and sample applications, other users contributed GitHub repositories too. The
possibilities for the integration of Watson services with other channels or specific external
systems are endless.
It is not possible to cover the broad range of options and possibilities for integrating Watson
services. This presentation provides an introduction to Watson services integration and an
example that is implemented in the exercise that follows the presentation.
References:
Watson SDKs
https://cloud.ibm.com/docs/watson?topic=watson-using-sdks
API reference and documentation
https://cloud.ibm.com/developer/watson/documentation
Watson Starter Kits
https://cloud.ibm.com/developer/watson/starter-kits
Uempty
14.2.Watson Assistant integration with other
services
Uempty
Watson Assistant
integration with
other services
This section introduces the integration of Watson Assistant with other Watson services and
channels.
Uempty
Application
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Although it is impossible to describe how to integrate with every possible integration point, there
is a general outline that most integrations follow. The following major components are parts of a
solution that integrates chatbots with other services and applications:
1. Front end or channel: This component can be a web page or an application window where the
users type their questions, the responses are shown, images are displayed, and so on. It might
be a messaging channel, an embedded chat widget, a mobile app, or even SMS messaging.
2. Watson Assistant: The “intelligence” behind the interaction is the Watson Assistant service.
Watson Assistant takes the inputs, understands them, and drives what takes place next. Some
examples of the output are displaying a response, detecting the intent of what is being asked,
using a multi-modal interaction like showing a map, playing a video, or something more
complex, such as reading from and writing to a database or even calling an enterprise service.
Watson Assistant can be trained on your content, but the interaction follows some structure.
Depending upon the content source or type, you might have to use some data transformation
or connectivity patterns.
3. Application layer: This is the middle layer, which varies the most across different solutions.
There is one job that this layer must accomplish: Passing information from the front end to
the chatbot (Watson Assistant), including system context, and passing it back to carry the
conversation. It is a translation layer that moves data from one side to the other and back.
4. Pre-processing: The flow gets more complex if you have additional interactions that you want
to integrate. For example, suppose that you want to add Tone analytics to build an empathetic
chatbot. This action is typically called pre-processing because it happens before calling
Watson Assistant. The application layer takes the user input, runs it through this
pre-processor layer, in this case to get the tone of the user statement, attaches the response,
in this case tone analytics’ results as context for Watson Assistant, and then pass it on to
Watson Assistant.
Uempty
5. Post-processing: This is the step where the logic that is necessary to respond to the user
query is. It happens after calling Watson Assistant but before returning a response to the
front-end layer. The Watson Discovery service is an example of a post-processing service.
Another use case for the post-processing layer is writing information to a database. For
example, a user orders a large pepperoni pizza. Your application might have to make two
callouts. The first call places the order in your point of sale (POS) system to order the pizza,
and the second call might write the order to a database. This way, the next time the user logs
in, they can say “order my usual” or something similar. Watson Assistant typically returns
some action for your application to perform and it also returns some text. Your application can
do the activities that are defined, and then show a message such as “I’ll remember that it is
your favorite, and it’s on the way. Thank you for your order.” Another approach is to directly
call external services from the Watson Assistant dialog to enrich your conversation or allow
users to complete activities by using post-processing.
Information
For detailed information on planning, preparing, runtime, and security architectures for Watson
Assistant integrations, see “Conversational chatbot reference architecture” at
https://www.ibm.com/cloud/architecture/architectures/cognitiveConversationDomain/reference
-architecture
Reference:
Integrate Watson Assistant With Just About Anything
https://medium.com/ibm-watson/integrate-watson-assistant-with-just-about-anything-695bc1
d29875
Natural Language Understanding – Tone analytics
https://cloud.ibm.com/docs/natural-language-understanding?topic=natural-language-understan
ding-tone_analytics
Conversational chatbot reference architecture
https://www.ibm.com/cloud/architecture/architectures/cognitiveConversationDomain/reference
-architecture
Uempty
Watson Assistant is designed to extend and enhance your current customer service applications
and resources. Go beyond simply giving customers and agents the answers that they need by
helping them solve real problems with chatbots advanced enough to interact with your customer
care ecosystem over the course of a natural conversation.
Seamlessly connect to existing customer support systems to fulfill customer requests and
perform tasks within the assistant itself.
Empower subject matter experts (SMEs) to build and maintain advanced conversational flows,
without developer help.
Improve the quality of the response by accessing existing organizational knowledge that was
collected over years of experience.
Integrate with tools and apps from other vendors or build your own.
Improve the customer experience by responding to customer inquiries through phone or digital
channels and routing to the right agent if necessary.
Reference:
Customer experience integrations
https://www.ibm.com/products/watson-assistant/integrations?mhsrc=ibmsearch_a&mhq=assis
tant%20integration
Uempty
The first step is to create a wrapper for the Watson Assistant service.
The wrapper is an object to which you send input and receive output from the service. When you
create the service wrapper, specify the authentication credentials from the service credentials
and version that you use.
In this Node.js example, the wrapper is an instance of AssistantV1, which is stored in the
variable assistant.
The Watson SDKs for other languages provide equivalent mechanisms for instantiating a service
wrapper.
Reference:
Watson Assistant API documentation
https://cloud.ibm.com/apidocs/assistant-v1?code=node
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
State information for your conversation is maintained by using the context. The context is an
object that is passed between your application and the Watson Assistant service. It is the
responsibility of your application to maintain the context from one turn of the conversation to the
next. The context includes a unique identifier for each conversation with a user, and a counter that
is incremented with each turn of the conversation.
In addition to maintaining your place in the conversation, the context can also be used to store
any other data that you want to pass between your application and the Watson Assistant service.
This information can include persisting the data that you want to maintain throughout the
conversation (such as a customer's name or account number), or any other data that you want to
track (such as the status of option settings).
The context contains variables that are meant to be persistent. To pass information from one call
to the next, the application developer must pass the previous API call's response context with
each subsequent API call. For example, the dialog can collect the user's name and then refer to
the user by name in subsequent nodes.
Reference:
Watson Assistant API documentation
https://cloud.ibm.com/apidocs/assistant-v1?code=node
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
A context variable is a variable that you define in a node or in the application, and optionally
specify a default value for it.
You can pass information from the application to the dialog by setting a context variable and
passing the context variable to the dialog.
For example, your application can set a $time_of_day context variable, and pass it to the dialog,
which can use the information to tailor the greeting it shows to the user.
In this example, the dialog knows that the application sets the variable to one of these
values: morning, afternoon, or evening. It can check for each value, and depending on which value
is present, return the appropriate greeting. If the variable is not passed or has a value that does
not match one of the expected values, then a more generic greeting is displayed to the user.
The dialog can also add context variables to pass information from one node to another or to
update the values of context variables. As the dialog asks for and gets information from the user, it
can track the information and reference it later in the conversation. For example, in one node you
might ask users for their name, and in a later node address them by name.
References:
Create natural conversations between your apps and users
https://www.ibm.com/cloud/garage/architectures/cognitiveConversationDomain
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
In general, any integration between the application and Watson Assistant is done by using intents,
entities, and context objects:
• Watson Assistant dialog detects the intents and entities in the user’s response.
• Watson Assistant dialog passes the intents, entities, and context objects to the application in
JSON format.
• The application performs specific tasks according to the intents, entities, and context values
that are sent to the application.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
A webhook is a mechanism that allows you to call out to an external program based on events in
your program. You can use webhooks to make calls from your assistant to an external service or
application during a conversation.
Watson Assistant supports the following types of webhooks:
Skills level webhooks. The following type of webhook can be set up for use from a dialog skill:
• Dialog
When used in a dialog skill, a webhook is triggered when the assistant processes a node that
has a webhook that is enabled. The webhook collects data that you specify or that you collect
from the user during the conversation and save in context variables. It sends the data as part
of an HTTP POST request to the URL that you specify as part of your webhook definition. The
URL that receives the webhook is the listener. It performs a predefined action by using the
information that you pass to it as specified in the webhook definition, and can optionally return
a response.
Uempty
Assistant-level webhooks. The following types of webhooks can be set up for an assistant:
• Premessage
Add a premessage webhook to your assistant if you want the webhook to be triggered before
each incoming message is processed by your assistant.
A premessage webhook calls an external service or application every time a customer submits
input. The external service can process the message before it is processed by your assistant.
For example, you can use a premessage webhook to:
Translate the customer's input to the language that is used by your assistant.
Check for and remove any personally identifiable information, such as an email address or
social security number that a customer might submit.
• Postmessage
A postmessage webhook calls an external service or application every time a response is
rendered by the assistant. The external service can process the assistant output before it is
sent to the channel.
For example, you can use a postmessage to extract custom responses from an external
content repository. For example, you can define actions with custom IDs in the responses
instead of text. The postmessage webhook can pass these IDs to an external database to
retrieve stored text responses.
• Logs
You can log activity by calling an external service or application every time a customer submits
input to the assistant.
This feature is available only to Enterprise plan users.
References:
Extending your assistant with webhooks
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-overview
Webhook overview
https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-overview
Making a programmatic call from dialog
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks
Making a call before processing a message
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-pre
Making a call after processing a message
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-post
Logging activity with a webhook
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-log
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
External applications or services might be called for several reasons to achieve richer interactions
in the chatbot’s dialogs. The typical way of achieving such integration is to create
an orchestration application. This orchestration application is the glue logic between Watson
Assistant and an external service. This approach is described in this presentation and the exercise
that follows.
References:
Making a programmatic call from dialog
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks
Extending your assistant with webhooks
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-webhook-overview
Webhook overview
https://cloud.ibm.com/docs/assistant?topic=assistant-webhook-overview
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
To make a programmatic call, define a webhook that sends a POST request callout to an external
application that performs a programmatic function. You can then invoke the webhook from one or
more dialog nodes.
To set up a webhook from the Dialog > Webhooks page, specify the request URL for an external
API you want to be able to invoke from dialog nodes.
When used in a dialog skill, a webhook is triggered when the assistant processes a node that has a
webhook that is enabled. The webhook collects data that you specify or that you collect from the
user during the conversation and save in context variables. It sends the data as part of an HTTP
POST request to the URL that you specify as part of your webhook definition. The URL that
receives the webhook is the listener. It performs a predefined action by using the information that
you pass to it as specified in the webhook definition and can optionally returns a response.
References:
Making a programmatic call from dialog
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks#dialog-webhooks-dialo
g-node-callout
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Another approach for integration is for a Watson Assistant dialog node to call the external service
directly. This approach enables your client application to call the external service or use IBM
Cloud Functions.
IBM Cloud Functions are based on Apache OpenWhisk. It is a Function-as-a-Service (FaaS)
platform that runs functions in response to incoming events or direct invocations.
References:
Getting started with IBM Cloud Functions
https://cloud.ibm.com/docs/openwhisk
FaaS (Function-as-a-Service)
https://www.ibm.com/cloud/learn/faas
Cloud Functions concepts
https://cloud.ibm.com/functions/learn/concepts
Calling an IBM Cloud Functions web action
https://cloud.ibm.com/docs/assistant?topic=assistant-dialog-webhooks#dialog-webhooks-cf-w
eb-action
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
The figure shows the general outline for integration introduced earlier in this presentation but in
this case, the architecture includes IBM Cloud Functions as the orchestration component. In this
case, Watson Assistant calls the external service directly by using Cloud Functions.
Uempty
Integrating the new Watson Assistant with other services by
using extensions
• To integrate your assistant with an external service that has a REST API, you can build a
custom extension by importing an OpenAPI document.
• After you create a custom extension, you can connect it to an assistant as an integration.
• In the actions, you can then define steps that interact with the external service by calling the
extension
• The Watson Assistant extension starter kit repo on GitHub provides files that you can use to
quickly build a working extension.
Each starter kit includes a tested OpenAPI definition that you can use to create an extension that
accesses a third-party API, along with a downloadable JSON file that you can import to create an
assistant that accesses the extension..
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Figure 14-20. Integrating the new Watson Assistant with other services by using extensions
Overview
OpenAPI (formerly known as Swagger) is an open standard for describing and documenting REST
APIs. An OpenAPI document defines the resources and operations that are supported by an API,
including request parameters and response data, along with details such as server URLs and
authentication methods.
An OpenAPI document describes a REST API in terms of paths and operations. A path identifies a
particular resource that can be accessed by using the API (for example, a hotel reservation or a
customer record), while an operation defines a particular action that can be performed on that
resource (such as creating, retrieving, updating, or deleting it). The OpenAPI document specifies
the details for each operation, including the HTTP method that is used, request parameters, the
data included in the request body, and the structure of the response body.
For more information about the OpenAPI specification, see OpenAPI Specification.
When you create a custom extension, you import an OpenAPI document that describes the REST
API of an external service. Watson Assistant parses the OpenAPI document to identify the
operations that are supported by the external service, along with information about the input
parameters and response for each operation and supported authentication methods.
After this processing is completed, the custom extension becomes available as a new integration
that you can connect to the assistant in the draft or live environment. Your assistant can then use
the extension to send requests to the external service based on conversations with your
customers. Values that are included in the response from the service are then mapped to action
variables, which can be accessed by subsequent action steps.
For more information about connecting a custom extension to an assistant, see Adding an
extension to your assistant at
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-add-custom-extension
Uempty
References:
OpenAPI Specification
https://swagger.io/specification/
Watson Assistant Extensions Starter Kit
https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/extensio
ns#watson-assistant-extensions-starter-kit
Building a custom extension
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-build-custom-extension
Adding an extension to your assistant
https://cloud.ibm.com/docs/watson-assistant?topic=watson-assistant-add-custom-extension
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
After you successfully import the OpenAPI document for the service that you plan to integrate
Watson Assistant with, it appears under Integrations > Extension.
In the example in the slide, the custom extension is called Weather details.
Click Add + to review the configuration and decide which variables of the responses you are going
to include. Now you are ready to use the extension from the steps in the Action.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
After you add the custom extension, you can use it to call the REST APIs that are defined in the
extension’s OpenAPI document. In this example, the custom extension is called “Weather
details”. It contains multiple operations (REST APIs) but the example shows only the
configuration for the “Location” API. The location API takes an input parameter called “woeid”
(Where-On-Earth-ID) and returns a location's 5-day weather forecast.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
After you call the REST API in an Action step, you create another step to use the response of this
API. The response variables are in the body object. In this example, the variables are body.time,
body.title, body.sun_set, body.sun-rise, body.latt_long.
You use these variables to form a reply as shown in the chat screen in the slide.
Reference:
MetaWeather Custom Extension
https://github.com/watson-developer-cloud/assistant-toolkit/tree/master/integrations/extensio
ns/starter-kits/metaweather
Uempty
14.3.Building a cognitive chatbot banking app:
Integrating Watson Assistant, Watson
Discovery, Natural Language
Understanding, and back-end banking
services
Uempty
Building a cognitive
chatbot banking app:
Integrating Watson
Assistant, Watson
Discovery, Natural
Language
Understanding, and
back-end banking
services
Cognitive banking chatbot application example
Figure 14-24. Building a cognitive chatbot banking app: Integrating Watson Assistant, Watson Discovery, Natural
Language Understanding, and back-end banking services
This section describes the integration flow that is implemented by the cognitive banking chatbot
application. This flow is a practical example of integrating multiple Watson services, an
application that orchestrates the services integration, and back-end banking systems.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
The cognitive banking chatbot provides an example of integration of multiple Watson services.
The Watson Assistant dialog is enhanced by adding capabilities that are provided by other Watson
APIs:
• Natural Language Understanding to identify entities
• Discovery to retrieve answers from a collection of FAQ documents
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
14.4.Building an intelligent procurement system
by integrating Knowledge Studio and
Watson Discovery
Uempty
Building an intelligent
procurement system
by integrating
Knowledge Studio
and Watson Discovery
Figure 14-27. Building an intelligent procurement system by integrating Knowledge Studio and Watson Discovery
This section describes the flow to build an intelligent procurement system by integrating Watson
Knowledge Studio and Watson Discovery.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Currently, customers perform analyses of various market reports on their own or hire experts to
make procurement decisions. These experts analyze reports that are captured from data sources,
a process that can be time-consuming and prone to human error, which potentially might cause a
chain effect of issues that can impact production. This code pattern explains how to create a
complete end-to-end solution for a procurement use case. With this intelligent procurement
system, which is based on Watson Knowledge Studio (WKS) and Watson Discovery, a customer
can receive expert analysis more quickly and accurately.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
14.5.Building a movie recommender solution
with Watson Assistant, Watson Studio,
Machine Learning, Db2, and Node-RED
Uempty
Building a movie
recommender
solution with
Watson Assistant,
Watson Studio,
Machine Learning,
Db2, and Node-RED
Figure 14-30. Building a movie recommender solution with Watson Assistant, Watson Studio, Machine Learning, Db2,
and Node-RED
This section describes the flow to build a movie recommender system by integrating Watson
Assistant, Watson Studio, Machine Learning, IBM Db2 database and by using Node-RED flows.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Today, recommender systems are widely used in various industries such as video streaming
services, online shopping, and content creation and sharing. Thanks to the development of deep
learning and artificial intelligence (AI), recommender systems can use the large amount of data
that is generated by users' everyday selections and make high-quality recommendations.
If your organization has user purchase history and ratings data, you can use that data to
recommend new products to users. The user is more likely to buy the products you recommend
based on this data.
You can build and deploy a working system that uses IBM Cloud Pak for Data.
This presentation and Exercise 12. “Building a chatbot and movie recommender solution with
Watson services and Node-RED” guide you to build a movie recommender system with a simple
virtual assistant user interface. Train, deploy, and integrate a model by using IBM Watson Studio,
a Db2 database, IBM Watson Assistant, and Node-RED.
The learning objectives of this use case are:
• Train and deploy a neural collaborative filtering model for movie recommendations by using
Watson Studio
• Build a virtual assistant as the user interface by using Watson Assistant.
• Integrate the deployed model, Db2 database, and the virtual assistant by using Node-RED.
Reference:
Build a low-code chatbot and movie recommender solution using Watson Services and Node-RED
https://developer.ibm.com/tutorials/build-a-low-code-chatbot-and-movie-recommender-solutio
n-using-watson-services-and-node-red/
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Remember, a webhook is a mechanism that allows you to call out to an external program, in this
case it is the Node-RED flow. It consists of a POST request that has the user_id as a body.
After the Node-RED flow runs and interfaces with all the other solution components, it provides
the response to Watson Assistant. Then, the assistant shows the recommendation to the user.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
One of the following two methods can be used to implement this integration in Node-RED: You
can use the Node-RED Db2 node to connect to the Db2 service instance.
• You can use the Node-RED http nodes to connect to the Db2 REST API interface.
The second method is more portable, and it can work in all types of Node-RED deployments, but it
is a bit more complex to implement. The Db2 REST API interface is used in this course.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
The movie recommender model is deployed and running on your Machine Learning service. The
Machine Learning service exposes the prediction REST API. Node-RED prepares the body of the
request with the list of the random movie's IDs and the current user ID, then it sends the request.
The model predicts the user’s ratings to this list and replies to Node-RED.
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Watson Studio builds, trains, and evaluates the model performance through the Jupyter
notebook. After the model shows acceptable performance, it is redeployed to the Machine
Learning service by using Watson Studio.
Overtime more user rating data is collected. Then, the model is retrained with the newly collected
data by using Watson Studio and it is deployed to Machine Learning Service. This approach
improves the accuracy of the predictions for user’s ratings.
Uempty
Unit summary • Explain the need to integrate multiple IBM Watson services to build
an intelligent solution.
• Describe the general flows for the integration of IBM Watson
Assistant with other services and applications.
• Explain the key capabilities that enable Watson Assistant
integration.
• Describe the flow to build a cognitive chatbot banking application by
integrating Watson Assistant, Watson Discovery, Watson Natural
Language Understanding, and back-end banking services.
• Describe the flow to build an intelligent procurement system by
integrating Watson Knowledge Studio and Watson Discovery.
• Describe the flow to build a movie recommender system by
integrating Watson Assistant, Watson Studio, Machine Learning, IBM
Db2 database and by using Node-RED flows.
Uempty
Review questions
1. True or False: It is better to integrate just one Watson service to add cognition to the
application.
2. True or False:
Integrating a custom model created for a particular domain by using Knowledge Studio with
Discovery service enables organizations to get expert analysis of their document collections.
3. To integrate your assistant with an external service that has a REST API, you can build a
custom extension by importing ____
a. OpenAPI document.
b. SOAP XML document.
c. Service XML definition.
d. Any JSON object.
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
Review answers
1. True or False: It is better to integrate just one Watson service to add cognition to the
application.
2. True or False: Integrating a custom model created for a particular domain by using Knowledge
Studio with Discovery service enables organizations to get expert analysis of their document
collections.
3. To integrate your assistant with an external service that has a REST API, you can build a
custom extension by importing ____
a. OpenAPI document.
b. SOAP XML document.
c. Service XML definition.
d. Any JSON object.
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
5. True or False: The intents, entities, output, and context objects in the response data that is
returned by the Watson Assistant's message API are set manually by the user.
Designing and building an intelligent solution © Copyright IBM Corporation 2018, 2022
Uempty
Exercise: Building a chatbot and movie recommender
solution with Watson services and Node-RED
Figure 14-42. Exercise: Building a chatbot and movie recommender solution with Watson services and Node-RED
Uempty
Uempty
Overview
Artificial intelligence is a major factor in people’s lives. It influences who gets a loan, how
companies hire and compensate employees, how customers are treated, even where
infrastructure and aid are allocated. Companies around the world are realizing that building trust
in AI is key to widespread adoption of the technology.
This unit explains AI ethics and trusted AI. It describes the principles that major AI vendors are
applying when they develop, implement, and deploy AI technologies.
This unit provides an overview of Watson OpenScale and explains how fairness is configured and
monitored by Watson OpenScale. This unit also describes how Watson OpenScale explains
decisions that are made by ML models.
Uempty
Uempty
Uempty
15.1.Introduction to AI ethics
Uempty
Introduction to AI
ethics
Uempty
• Artificial intelligence is a major factor in people’s lives. It influences who gets a loan, how
companies hire and compensate employees, how customers are treated, even where
infrastructure and aid are allocated.
• Companies around the world are realizing that building trust in AI is key to widespread
adoption of the technology. They know that trust in AI and being able to explain decisions
made through AI algorithms are crucial to the success of their business from a brand
perspective. According to the Global AI Adoption Index 2021, 86% of global IT professionals
agree that consumers are more likely to choose the services of a company that offers
transparency and an ethical framework on how its data and AI models are built, managed, and
used.
References:
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
What is AI Ethics?
https://www.youtube.com/watch?v=aGwYtUzMQUk
Global Data from IBM Points to AI Growth as Businesses Strive for Resilience
https://newsroom.ibm.com/IBMs-Global-AI-Adoption-Index-2021
Uempty
Data and insights belong to their Clients own the data even when it is on
IBM’s servers or has been processed
creator through IBM AI. Data and insights belong to
the client.
Technology must be transparent and AI systems must work in ways that make
sense to the people that use them. It must
explainable be clear who trains the AI systems, what
data is used in training and most
importantly, what goes into the algorithms’
recommendations.
Getting started with AI ethics © Copyright IBM Corporation 2018, 2022
IBM chooses three Principles for Trust and Transparency. With them, IBM seeks to earn the trust
of its clients and society by being trustworthy. Trust is not only based on creating products that
can be understood, but also on maintaining appropriate relationships with data owners and other
people subject to AI, such as workers.
The purpose of AI is to augment human intelligence
AI is sometimes perceived as an adversary of human labor, automating tasks that are taken away
from people. By instead considering AI as a tool to help people fulfill their tasks, a more
harmonious relationship with AI is possible.
Data and insights belong to their creator
With this principle, IBM keeps data ownership where it belongs, with the people and organizations
from whom the data originated. Clients own the data even when it is on IBM’s servers or it is
processed through IBM AI. This data ownership principle has important ramifications for privacy,
security, government access, and cross-border data flow.
New technology, including AI systems, must be transparent and explainable
IBM seeks to maintain assurance that AI systems are working in ways that make sense to the
people that use them. The company should be clear about when AI is being used and what data is
involved in that AI (while maintaining client data ownerships and all that they entail). It should
address bias proactively, and generally seek to make AI understandable.
Uempty
References:
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
IBM’s Principles for Trust and Transparency
https://www.ibm.com/blogs/policy/trust-principles/
Uempty
IBM’s pillars of trust help to implement the Principles of Trust and Transparency. Each pillar is a
well-established research subfield with dedicated communities. IBM Research published dozens
of papers in these fields and created open-source toolkits to bridge the gap between scientists
and practitioners to enable them to build trustworthy AI models. The pillars act as mid-level
principles that focus the larger picture of building AI trustworthiness into more precise
applications and ensure that operationalization is thorough and complete, all the way to the level
of code.
References:
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
IBM’s Principles for Trust and Transparency
https://www.ibm.com/blogs/policy/trust-principles/
Uempty
Explainability
• AI-powered decisions should be
accompanied by the reasons and
explanations for the decisions.
• Focuses on the question of why an AI model
made a particular decision.
• Example: Explain why the AI application
decided to deny a loan.
While transparency offers a view into the AI technology and algorithms in use, simple and
straightforward explanations are needed for how AI is used.
People are entitled to understand how AI arrived at a conclusion, especially when those
conclusions impact decisions about their employability, their credit worthiness, or their potential.
Provided explanations need to be easy to understand.
References:
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Uempty
Fairness
• The reduction of human bias and the
equitable treatment of individuals and of
groups of individuals.
• Focuses on the issue of treating different
groups equally.
• Monitoring and safeguards are critical to
prevent bias from creeping into the solution.
• Example: Ensure that different genders
have similar loan approval rates in a training
data set or in the recommendations of an AI
model.
Fairness looks at the issue of treating different groups equally. For example, ensure that different
genders have similar loan approval rates in a training data set or in the recommendations of an AI
model.
References:
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Uempty
Robustness
• AI solution must be robust enough to handle
exceptional conditions effectively and to
minimize security risk.
• Robust systems can cope with attacks
without causing serious harm.
• AI must be able to withstand attacks and
maintain its integrity while under attack.
• Example: In evasion attacks, the adversary
crafts small changes to the original input to
an AI model to influence its behavior. This
approach can happen by making
imperceptible changes to the pixels of an
image of a cat, which might cause this image
to be misclassified as an ambulance.
AI systems must be resistant to attacks. Robust systems can cope with attacks without causing
serious harm. Particularly with AI, these systems can cope with adversarial attacks that are
directed in ways that target the weakness specific to AI systems.
References:
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Adversarial Robustness 360 Toolbox v1.0: A Milestone in AI Security
https://www.ibm.com/blogs/research/2019/09/adversarial-robustness-360-toolbox-v1-0/
Uempty
Transparency
• AI systems must be transparent.
• People need to be able to understand and
evaluate how the systems work and know
their strengths and weaknesses.
• Allows the AI technology to be easily
inspected. Transparency means that the
algorithms that are used in AI solutions are
not hidden or unable to be looked at more
closely.
• Example: AI applications allow developers
to collect and document facts about their
models to be fully transparent.
AI systems must be transparent to create trustworthy AI: people need to be able to understand
and evaluate how the systems work and know their strengths and weaknesses. Transparency
requires disclosure of relevant aspects of the systems.
References:
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Uempty
Privacy
• People deserve to have their sensitive data
protected.
• Only necessary data should be collected,
and consumers should have clear access to
controls over how their data is being used.
• Data belongs to the humans that create it,
and AI must ensure privacy with the highest
integrity.
• AI must ensure privacy at every turn, not
only of raw data, but of the insights gained
from that data.
• Example: AI applications notify people how
and when their data is being used, and what
it is being used for and by whom.
People deserve to have their sensitive data protected, which includes notifying people how and
when their data is being used, and what it is being used for and by whom. Only necessary data
should be collected, and consumers should have clear access to controls over how their data is
being used.
References:
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Uempty
Trustworthy AI is a term that is used to describe AI that is lawful, ethically adherent, and
technically robust. It is based on the idea that AI reaches its full potential when trust can be
established in each stage of its lifecycle, from design to development, deployment, and use. See
“What is Trustworthy AI” at
https://www.onespan.com/blog/trustworthy-ai-why-we-need-it-and-how-achieve-it#:~:text=Tr
ustworthy%20AI%20is%20a%20term,to%20development%2C%20deployment%20and%20us
e
In 2020, IBM donated a set of AI toolkits to the Linux Foundation, including AI Explainability 360,
AI Fairness 360, the Adversarial Robustness 360 toolbox. IBM also open-sourced AI FactSheets
360 and Uncertainty Quantification 360 toolkits. These toolkits facilitate collaboration among
researchers, practitioners, and the multidiscipline trustworthy AI community.
The AI Explainability 360 toolkit supports IBM’s commitment to explainability, the first pillar of
trust. This extensible open-source toolkit can help you comprehend how machine learning
models predict labels by various means throughout the AI application lifecycle.
This toolkit has eight algorithms for making machine learning (ML) models more transparent and
comprehensible. It includes a demo to help understand how various users require different
explanations. Making such models comprehensible is vital to also making them trustworthy. After
all, if models work most of the time, but occasionally fail inexplicably, people are unlikely to place
their trust in the model, especially if those failures create a risk of harm.
Uempty
References:
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
The AI 360 Toolkit: AI models explained
https://developer.ibm.com/articles/the-ai-360-toolkit-ai-models-explained/?mhsrc=ibmsearch_
a&mhq=Trustworthy%20AI
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
AI Explainability 360
https://aix360.mybluemix.net/
AI Explainability 360 – Demo
https://aix360.mybluemix.net/consumer
Uempty
The AI Fairness 360 toolkit supports the fairness pillar. The toolkit includes more than 70 fairness
metrics and 10 bias mitigation algorithms for enhancing fairness in ML. This toolkit contains
metrics for assessing whether individuals and groups are treated fairly in the implementation of
AI.
References:
The AI 360 Toolkit: AI models explained
https://developer.ibm.com/articles/the-ai-360-toolkit-ai-models-explained/?mhsrc=ibmsearch_
a&mhq=Trustworthy%20AI
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
AI fairness 360
https://aif360.mybluemix.net/
AI Fairness 360 – Demo
https://aif360.mybluemix.net/data
Uempty
The Adversarial Robustness 360 toolbox supports IBM’s commitment to robustness, its third
pillar of trust. The tools available allow ML developers to defend against adversarial attacks, such
as poisoning, inference, extraction, and evasion. The toolbox includes a demo to create and
replicate attacks and defense methods for ML models. Developers can evaluate how their models
will do when subjected to such attacks to adjust the models and make them more robust.
References:
The AI 360 Toolkit: AI models explained
https://developer.ibm.com/articles/the-ai-360-toolkit-ai-models-explained/?mhsrc=ibmsearch_
a&mhq=Trustworthy%20AI
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
Your AI model might be telling you this is not a cat
https://art-demo.mybluemix.net/
Uempty
AI FactSheets 360 tool supports the transparency pillar. Factsheets are collections of facts about
an AI model. The tool has several examples of FactSheets and a methodology for creating them.
The information that is collected by these sheets is useful for understanding the model and
enabling its governance. Facts include the purpose of the model, characteristics of the data set
and various relevant aspects of the creation or deployment of the model or service.
References:
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
AI FactSheets 360
https://aifs360.mybluemix.net/
Uempty
The Uncertainty Quantification 360 toolkit, which includes a demo, supports several of IBM’s
pillars of trust, especially robustness and explainability. By developing a better understanding of
the reliability of AI judgments in particular situations, uncertainty quantification reveals the
importance of intellectual humility and helps to prevent overconfidence in AI systems by clearly
indicating their capabilities and limitations.
References:
The AI 360 Toolkit: AI models explained
https://developer.ibm.com/articles/the-ai-360-toolkit-ai-models-explained/?mhsrc=ibmsearch_
a&mhq=Trustworthy%20AI
Foundations of trustworthy AI: governed data and AI, AI ethics and an open diverse ecosystem
https://www.ibm.com/blogs/watson/2021/05/trustworthy-ai-foundations/
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
AI Ethics
https://www.ibm.com/artificial-intelligence/ethics
Uncertainty Quantification 360
http://uq360.mybluemix.net/
Demo: House Price Prediction Model
http://uq360.mybluemix.net/demo/2/choose
Uempty
IBM Cloud Pak for Data is a consolidated set of proprietary tools for use in the entire data
analytics lifecycles. It allows all users from an enterprise, for example business users, data
scientists, and ML operations to collaborate on the same toolset to collect, organize, and analyze
data. AI insights require the right data, automated modeling tools, and governance to ensure
transparency and trust. Automated data orchestration, model building, deploying, and
governance can reduce risks and help drive accuracy, accountability, and responsible AI.
IBM Cloud Pak for Data includes tools that provide the following capabilities:
Build trust in data
Access the right data, just in time, regardless of where it is stored. Use data fabric across a hybrid
cloud landscape.
Build trust in models??
Shorten the time to model production, ensure lifecycle managing, monitoring, and retraining by
using automation.
Build trust in processes?
Drive consistent, transparent, and repeatable AI governance, managing risk and compliance
across the AI lifecycle.
References:
MLOps and Trustworthy AI?
https://www.ibm.com/products/cloud-pak-for-data/scale-trustworthy-ai
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Uempty
Uempty
Step 3. Build and train model
Use the following tools to train models by using privacy-preserving, interpretable techniques, and
more.
• TensorFlow Model Remediation at
https://www.tensorflow.org/responsible_ai/model_remediation
• TensorFlow Privacy at https://www.tensorflow.org/responsible_ai/privacy/guide
• TensorFlow Federated at https://www.tensorflow.org/federated
• TensorFlow Constrained Optimization (TFCO) at
https://github.com/google-research/tensorflow_constrained_optimization/blob/master/REA
DME.md
• TensorFlow Lattice (TFL) at https://www.tensorflow.org/lattice/overview
Step 4. Evaluate model
Debug, evaluate, and visualize model performance using the following tools:
• Fairness Indicators at https://www.tensorflow.org/responsible_ai/fairness_indicators/guide
• TensorFlow Model Analysis at https://www.tensorflow.org/tfx/model_analysis/install
• What-If Tool at https://pair-code.github.io/what-if-tool/
• Language Interpretability Tool (LIT) at https://pair-code.github.io/lit/
• Explainable AI at https://cloud.google.com/explainable-ai
• TensorFlow Privacy Tests at
https://blog.tensorflow.org/2020/06/introducing-new-privacy-testing-library.html
• TensorBoard at https://www.tensorflow.org/tensorboard/get_started
Step 5. Deploy and monitor
Use the following tools to track and communicate about model context and details.
• Model Card Toolkit at https://www.tensorflow.org/responsible_ai/model_card_toolkit/guide
• ML Metadata at https://www.tensorflow.org/tfx/guide/mlmd
• Model Cards at https://modelcards.withgoogle.com/about
Reference:
Responsible AI tools and resources for TensorFlow
https://www.tensorflow.org/responsible_ai
Uempty
Reliability
Fairness Inclusiveness
& Safety
Privacy
Accountability Transparency
& Security
• Responsible AI
Approach to assessing, developing, and deploying AI systems in a safe, trustworthy, and ethical
manner.
Aims at making sure that Microsoft principles are applied when designing, developing, and deploying
technology and it is inclusive and accessible for all people.
Detect bias, make the systems fair, detect errors and blind spots in the technologies, be always vigilant
in areas where technology can impose on privacy and human rights.
Responsibility is at the core.
Getting started with AI ethics © Copyright IBM Corporation 2018, 2022
Uempty
Accountability
Who is liable for AI-driven decisions? Example: An innocent person is convicted of a crime based
on evidence form facial recognition, who’s responsible?
Transparency
Users must trust a complex system. Example: An AI-based financial tool makes investment
recommendations, what are they based on?
Reference:
Responsible AI
https://www.microsoft.com/en-us/ai/responsible-ai?activetab=pivot1%3aprimaryr6
Uempty
Dashboard Description
Responsible AI dashboard A single pane of glass brings together several mature Responsible
AI tools from the toolbox for a holistic responsible assessment and
debugging of models and to make informed business decisions.
With this dashboard, you can identify model errors, diagnose why
those errors are happening, and mitigate them.
Fairness dashboard Helps to understand model’s fairness issues by using various group-
fairness metrics across sensitive features and cohorts.
Error Analysis dashboard Helps to identify model errors and discover cohorts of data for
which the model underperforms.
Interpretability dashboard Helps to understand model predictions.
• HAX Toolkit
Tools for creating fluid and responsible human-AI experiences.
Responsible AI Toolbox is a suite of tools provides a collection of model and data exploration and
assessment user interfaces that enable a better understanding of AI systems. These interfaces
empower developers and stakeholders of AI systems to develop and monitor AI more responsibly
and take better data-driven actions.
The Toolbox consists of four dashboards:
Responsible AI dashboard, a single pane of glass bringing together several mature Responsible
AI tools from the toolbox for a holistic responsible assessment and debugging of models and
making informed business decisions. With this dashboard, you can identify model errors, diagnose
why those errors are happening, and mitigate them. Moreover, the causal decision-making
capabilities provide actionable insights to your stakeholders and customers.
Fairness dashboard, for understanding model’s fairness issues by using various group-fairness
metrics across sensitive features and cohorts. This dashboard is powered by Fairlearn.
Error Analysis dashboard, for identifying model errors and discovering cohorts of data for which
the model underperforms.
Interpretability dashboard, for understanding model predictions. This dashboard is powered by
InterpretML.
The Human-AI eXperience (HAX) Toolkit is a set of practical tools for creating human-AI
experiences with people in mind from the beginning. Each tool is designed to help AI creators,
including UX, AI, project management, and engineering teams, take this human-centered
approach in their day-to-day work.
Uempty
References:
Responsible AI Resources
https://www.microsoft.com/en-us/ai/responsible-ai-resources
Responsible AI Toolbox
https://github.com/microsoft/responsible-ai-toolbox
Responsible AI dashboard
https://github.com/microsoft/responsible-ai-toolbox#introducing-responsible-ai-dashboard
Fairness dashboard
https://github.com/microsoft/responsible-ai-widgets/blob/main/docs/fairness-dashboard-READ
ME.md
Error Analysis dashboard
https://github.com/microsoft/responsible-ai-widgets/blob/main/docs/erroranalysis-dashboard-
README.md
HAX Toolkit
https://www.microsoft.com/en-us/haxtoolkit/
Uempty
15.2.Intoduction to Watson OpenScale
Uempty
Intoduction to
Watson OpenScale
Uempty
Watson OpenScale tracks and measures outcomes from your AI models, and helps ensure they
remain fair, explainable, and compliant wherever your models were built or are running. Watson
OpenScale also detects and helps correct the drift in accuracy when an AI model is in production.
Enterprises use model evaluation to automate and put into service AI lifecycle in business
applications. This approach ensures that AI models are free from bias, can be easily explained
and understood by business users, and are auditable in business transactions. Model evaluation
supports AI models built and run with the tools and model frameworks of your choice.
References:
Manage model risk
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=SSQNUZ_4.0/wsj/model/icp4d-ri
sk-wos-only.html
Frequently asked questions for Watson OpenScale
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=openscale-faqs#faq-whatsa
Validating and monitoring AI models with Watson OpenScale
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/getting-started.html
Responsible Use of Technology: The IBM Case Study
https://www.weforum.org/whitepapers/responsible-use-of-technology-the-ibm-case-study
Uempty
Uempty
Monitors
• Monitors evaluate your deployments against specified metrics. Configure alerts that indicate
when a threshold is crossed for a given metric.
• Watson OpenScale evaluates your deployments based on three default monitors:
Quality describes the model’s ability to provide correct outcomes based on labeled test data called
Feedback data.
Fairness describes how evenly the model delivers favorable outcomes between groups. The Fairness
monitor looks for biased outcomes in your model.
Drift warns you of a drop in accuracy or data consistency.
ň Note ņņņņņņņņņņņņņņņņņ
You can also create Custom monitors for your deployment.
Ŋņņņņņņņņņņņņņņņņņņņņ
Monitors evaluate your deployments against specified metrics. Configure alerts that indicate
when a threshold is crossed for a given metric. Watson OpenScale evaluates your deployments
based on three default monitors:
Quality describes the model’s ability to provide correct outcomes based on labeled test data
called Feedback data.
Fairness describes how evenly the model delivers favorable outcomes between groups. The
Fairness monitor looks for biased outcomes in your model.
Drift warns you of a drop in accuracy or data consistency.
Note
Reference:
Monitors
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/getting-started.html
Uempty
Uempty
References:
Supported machine learning engines, frameworks, and models
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-ovr.html?context
=cpdaas&audience=wdp
IBM Watson Machine Learning
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-wml-cloud.html?
context=cpdaas&audience=wdp#frmwrks-wml
Azure ML Studio frameworks
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-azure-ml-studio.
html?context=cpdaas&audience=wdp#frmwrks-azure
Azure ML Service frameworks
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-azure-ml-
service.html?context=cpdaas&audience=wdp
AWS SageMaker
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-aws-sagemaker.
html?context=cpdaas&audience=wdp#frmwrks-aws-sage
Custom ML frameworks
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-frameworks-custom.html?co
ntext=cpdaas&audience=wdp#frmwrks-custom
Uempty
15.3.Monitoring fairness in ML models with
OpenScale
Uempty
Monitoring fairness
in ML models with
OpenScale
Uempty
Uempty
The fairness monitor evaluates your model for biases to ensure fair outcomes among different
groups.
Before you configure the fairness monitor, you must understand the following key concepts:
Features
The features are the model attributes that are evaluated to detect bias. For example, you can
configure the fairness monitor to evaluate features such as Sex or Age for bias. Only features that
are of categorical, numeric (integer), float, or double fairness data type are supported.
Reference and monitored groups
The values of the features are specified as either a reference or monitored group. The monitored
group represents the values that are most at risk for biased outcomes. For example, for the Sex
feature, you can set Female and Non-binary as the monitored groups. For a numeric feature, such
as Age, you can set [18-25] as the monitored group. All other values for the feature are then
considered as the reference group, for example, Sex=Male or Age=[26,100].
Fairness alert threshold
The fairness alert threshold specifies an acceptable difference between the percentage of
favorable outcomes for the monitored group and the percentage of favorable outcomes for the
reference group. For example, if the percentage of favorable outcomes for a group in your model
is 70% and the fairness threshold is set to 80%, then the fairness monitor detects bias in your
model.
Uempty
Reference:
Configuring the fairness monitor
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=monitoring-configuring-fairness-
monitor
Uempty
Uempty
Reference:
Configuring the fairness monitor
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=monitoring-configuring-fairness-
monitor
Uempty
For step instructions see, “Configuring the fairness monitor” > “Steps” at
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=monitoring-configuring-fairness-
monitor
References:
Fairness metrics overview
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-fairness-ovr.html?context=cp
daas&audience=wdp
Configuring the fairness monitor
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-monitor-fairness.html?contex
t=cpdaas&audience=wdp
Uempty
The output of the model is categorized as either favorable or unfavorable. For example, if the
model is recommending whether a person gets a loan or not, then the Favorable outcome might
be Loan Granted or Loan Partially Granted. The unfavorable outcome might be Loan Denied.
When you configure the IBM Watson OpenScale fairness monitor, you can generate a set of
metrics to evaluate the fairness of your model. You can use the fairness metrics to determine
whether your model produces biased outcomes.
References:
Favorable and unfavorable outcomes
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-monitor-fairness.html?contex
t=cpdaas&audience=wdp
Fairness metrics overview
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=openscale-fairness-metrics-overv
iew
Uempty
Uempty
How it works
The Watson OpenScale algorithm computes bias on an hourly basis by using the last N records
that are present in the payload logging table and the value of N is specified when you configure the
fairness monitor. The algorithm perturbs these last N records to generate additional data.
The perturbation changes the values of the feature from the reference group to the monitored
group, or vice-versa. The perturbed data is then sent to the model to evaluate its behavior. The
algorithm looks at the last N records in the payload table and the behavior of the model on the
perturbed data, to decide whether the model is acting in a biased manner.
A model is biased if the percentage of favorable outcomes for the monitored group is less than the
percentage of favorable outcomes for the reference group, by some threshold value. This
threshold value is specified when you configure the fairness monitor.
Fairness values can be more than 100%. This calculation means that the monitored group
received more favorable outcomes than the reference group. In addition, if no new scoring
requests are sent, then the fairness value remains constant.
Uempty
References:
Fairness metrics overview
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=openscale-fairness-metrics-overv
iew
Viewing data for a deployment
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=insights-viewing-data-deploymen
t
Fairness metrics overview
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-fairness-ovr.html?context=cp
daas&audience=wdp
Configuring the fairness monitor
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-monitor-fairness.html?contex
t=cpdaas&audience=wdp
Uempty
The chart shows and example of a biased model where the percentage of favorable outcomes
(60%) for the monitored group (Female) is less than the percentage of favorable outcomes
(81%) for the reference group (Male), by fairness alert threshold (80%) value.
Uempty
num_positives: the number of individuals in the group who received a positive outcome.
num_instances: the total number of individuals in the group.
privileged=False label: the monitored group.
privileged=True label: the reference group.
• The calculation produces a percentage that specifies how often the rate that the monitored group
receives the favorable outcome is the same rate that the reference group receives the favorable
outcome.
• Example: if a model assigns the “no risk” prediction (favorable outcome) to 80% of monitored applicants
(Female) and to 100% of reference applicants (Male), that model has a disparate impact of 80%
Getting started with AI ethics © Copyright IBM Corporation 2018, 2022
Disparate impact compares the percentage of favorable outcomes for a monitored group to the
percentage of favorable outcomes for a reference group.
In Watson OpenScale, disparate impact is specified as the fairness scores for different groups.
When you view the details of a model deployment, the Fairness section of the model summary
that is displayed, provides the fairness scores for different groups that are described as metrics.
The fairness scores are calculated with the disparate impact formula.
The num_positives value represents the number of individuals in the group who received a
positive outcome, and the num_instances value represents the total number of individuals in the
group. The privileged=False label specifies unprivileged groups and the privileged=True label
specifies privileged groups. In Watson OpenScale, the positive outcomes are designated as the
favorable outcomes, and the negative outcomes are designated as the unfavorable outcomes. The
privileged group is designated as the reference group, and the unprivileged group is designated as
the monitored group.
The calculation produces a percentage that specifies how often the rate that the unprivileged
(monitored) group receives the positive outcome is the same rate that the privileged (reference)
group receives the positive outcome. For example, if a credit risk model assigns the “no risk”
prediction to 80% of unprivileged applicants and to 100% of privileged applicants, that model has
a disparate impact of 80%.
Reference:
Disparate impact
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-disparate-impact.html?conte
xt=cpdaas&audience=wdp
Uempty
From the Watson OpenScale dashboard, the Fairness tile shows the fairness timeline view.
A chart displays aggregated evaluations as data points within the Time frame and Date range
metric that you specify. The timestamp of each datapoint that displays when you hover on the
chart does not match the timestamp of the latest evaluation due to the default aggregation
behavior. The latest evaluation for the time frame that you select is displayed during the
associated date range. When you view a batch deployment, the chart can also display the
following metrics:
• The evaluation interval is set to 1 week by default. You can set the evaluation interval to 1
month or 1 year with the Watson OpenScale Python SDK.
• The interval that is specified with the Time frame metric is set to the evaluation interval that
you configure for the monitors.
Because the algorithm checks are run only every hour or every three hours, there are also links
provided to check fairness, drift, and quality on-demand.
From the Schedule pane, you can click the Evaluate fairness now, Evaluate quality now, or
Evaluate drift now links to make an immediate check of your data.
Uempty
References:
Fairness metrics overview
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-fairness-ovr.html?context=cp
daas&audience=wdp
Configuring the fairness monitor
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-monitor-fairness.html?contex
t=cpdaas&audience=wdp
Viewing data for a deployment
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=insights-viewing-data-deploymen
t
OpenScale Python SDK
https://ibm-watson-openscale-client.mybluemix.net/
Uempty
15.4.Explaining decisions made by ML models
with OpenScale
Uempty
Explaining decisions
made by ML models
with OpenScale
Uempty
For each deployment, you can see explainability data for specific transactions. Depending on the
type of model, it can include different types of analysis, such as LIME, contrastive explanations, or
the ability to test what if scenarios.
Watson OpenScale can generate the following types of explanations to help you understand the
behavior of your model:
LIME
Local Interpretable Model-Agnostic Explanations (LIME) is a Python library that Watson
OpenScale uses to analyze the input and output values of a model to create
human-understandable interpretations of the model. LIME reveals which features are most
important for a specific data point. The 5000 perturbations that are typically done for analysis are
close to the data point. In an ideal setting, the features with high importance in LIME are the
features that are most important for that specific data point. For proper processing of LIME
explanations, Watson OpenScale does not support column names with equals sign (=) in the data
set.
Contrastive explanations
Contrastive explanations reveal how much values need to change to either change the prediction
or still have the same prediction. The factors that need the maximum change are considered more
important, so the features with the highest importance in contrastive explanations are the
features where the model is least sensitive. For contrastive explanations, Watson OpenScale
displays the maximum changes for the same outcome and the minimum changes for a changed
outcome. These categories are also known as pertinent positive and pertinent negative values.
These values help explain the behavior of the model in the vicinity of the data point for which an
explanation is generated.
Uempty
References:
Explaining transactions
https://www.ibm.com/docs/en/cloud-paks/cp-data/4.0?topic=insights-explaining-transactions
Explaining unstructured text models
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-insight-explain.html?context
=cpdaas&audience=wdp#ie-unstruct
Uempty
You can view explanations by transaction ID from the Explain a transaction tab in the
OpenScale navigator.
Select a model in the Deployed model list.
The Recent transactions list displays all of the transactions that are processed by your model. The
list contains columns that provide details about the outcome of each transaction.
Click the Explain button in the Actions column.
The Transaction details page provides an analysis of the factors that influenced the outcome of
the transaction.
References:
Viewing explanations by transaction ID
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-insight-explain.html?context
=cpdaas&audience=wdp#ie-unstruct
Explaining transactions
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-insight-explain.html?context
=cpdaas&audience=wdp
Uempty
Transaction details
• Provides an analysis of the factors that influenced the outcome of the transaction.
The Transaction details page provides an analysis of the factors that influenced the outcome of
the transaction.
For a transaction, each feature in the model is assigned a percentage of relative weight, which
indicates how strongly the feature influenced the model’s predicted outcome. A negative relative
weight percentage indicates that the feature influenced the model toward a different predicted
outcome.
References:
Explaining transactions
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-insight-explain.html?context
=cpdaas&audience=wdp
Uempty
Run analysis
• Shows how different values can change the outcome of the transaction.
If you want to know what feature values will result in a different outcome, Watson OpenScale can
analyze the model and provide a suggestion. From the Inspect tab, click Run analysis. This
analysis takes a few minutes.
References:
Explaining transactions
https://dataplatform.cloud.ibm.com/docs/content/wsj/model/wos-insight-explain.html?context
=cpdaas&audience=wdp
Uempty
Uempty
Uempty
Uempty
Uempty
Review questions
1. True or False: With Watson OpenScale you can explain the predictions of image classification
models and unstructured text models
2. “People need to be able to understand and evaluate how the systems work and know their
strengths and weaknesses”. Which pillar represents this sentence?
a. Fairness.
b. Explainability.
c. Transparency.
d. Robustness.
3. True or False: The reference group represents the values of the features that are most at risk
for biased outcomes
Uempty
5. An AI application notifies users how and when their data will be used, what it is it used for and
by whom. Which pillar does the application supports?
a. Fairness.
b. Explainability.
c. Transparency.
d. Privacy.
Uempty
Review answers
1. True or False: With Watson OpenScale you can explain the predictions of image classification
models and unstructured text models
2. “People need to be able to understand and evaluate how the systems work and know their
strengths and weaknesses”. Which pillar represents this sentence?
a. Fairness.
b. Explainability.
c. Transparency.
d. Robustness.
3. True or False: The reference group represents the values of the features that are most at risk
for biased outcomes
Uempty
5. An AI application notifies users how and when their data will be used, what it is it used for and
by whom. Which pillar does the application supports?
a. Fairness.
b. Explainability.
c. Transparency.
d. Privacy.
Uempty
Exercise: Monitoring fairness in a credit risk prediction
model
Uempty
Exercise • In this exercise, you learn how you can use IBM Watson OpenScale
to monitor your artificial intelligence (AI) models for fairness.
objectives
• After completing this exercise, you will be able to:
Create a Watson OpenScale service.
Explore the fairness monitor for a machine learning model.
Use the explainability feature to understand the causes of bias.
Configure a debiased version of a machine learning model.
Uempty
Exercise: Monitoring weather conditions bias in a model that
predicts telecommunications call drops
Figure 15-52. Exercise: Monitoring weather conditions bias in a model that predicts telecommunications call drops
Uempty
backpg