2. Learning Objectives
✦Discuss the meaning, scope and stages of artificial intelligence
✦Discover the applications of artificial intelligence
✦Analyse the impact of artificial intelligence on the society
3. Meaning of Artificial Intelligence
• Is the intelligence
exhibited by machines
• Is based on the premise
that intelligence is not
“real” or “human”
• Mimics cognitive functions
exhibited by humans
4. Three Stages of AI
Artificial Narrow
Intelligence
Artificial General
Intelligence
Artificial Super
Intelligence
2015 2025 2050
ANI
ANI AGI
AGI ASI
ASI
We are
HERE
5. Artificial Narrow Intelligence (ANI)
Are limited to one or
two functional areas
Are not self-aware or
self-conscious
Appear to be making
decisions; but it is the
statistics/mathematics
in action
8. Examples of AGI
• Multipurpose systems
• Systems with human-level intelligence, reasoning, thinking
and decision-making
• Systems that synthesize diverse information and decide
actions
10. Examples of ASI
Super intelligent AI agents Systems that are masters at
every skill, subject, or
discipline and are faster
than the smartest humans.
11. Three Stages of AI: At a glance
Artificial Narrow
Intelligence
Artificial General
Intelligence
Artificial Super
Intelligence
2015 2025 2050
A
NI
A
NI
A
GI
A
GI
A
SI
A
SI
User-driven big data systems
for machine learning
Machine Intelligence
Advanced networks trained to
build ad-hoc systems and
improve themselves using
data
Machine Consciousness
Systems characterised by
cognitive self learning
13. Applications of Artificial Intelligence
Artificial Intelligence
Machine
Learning (ML)
Vision
Hearing
Natural Language
Processing (NLP)
Robotics
Expert
Systems
Deep Learning
(DL)
Image and
Pattern
Recognition
Voice and Speech
Recognition
Natural Language
Understanding (NLU)
Natural Language
Generation (NLG)
Neural Networks
Facial
Recognition
14. Applications of Artificial Intelligence
Image Recognition
Product Analytics
A/B Testing
Speech Recognition
Language Translation
Sentiment Analysis
15. Impact of AI on Society
Enhance Throughput and Efficiency
Frees Up Humans
Adds Jobs and Strengthens the Economy
Enhances Lifestyle
16. Enhances Throughput and Efficiency
- Anand Sampat , DATMO
“Artificial Intelligence is a huge benefit to the society as it enhances the
efficiency and throughput , while creating new opportunities for revenue
generation, cost saving and job creation.”
17. Enhances Throughput and Efficiency
Self Driving Cars
• Are a combination of cameras, sensors.
radars and artificial intelligence technology
• Are capable of sensing the surrounding
environment and navigating without human
intervention
18. Frees up Humans
- Chalmers Brown , DueCompany
“Machines allow humans to do the most interpersonal and creative
aspects of work”
19. Frees up Humans
Enhance our Lifestyle
• Supplement the more routine work allowing
humans to focus on more important tasks
• Mundane tasks will be replaced with smart
systems to automate those tasks
Create Efficient
Business
Smart Email Systems
20. Frees up Humans
Image processing, recognition and artificial
intelligence will monitor areas and alert guards
if there are events that require human
intervention
Monitoring Spaces
21. Adds Jobs and Strengthens Economy
- Matthew Lieberman , PWC
“The unparalleled combination of human and machine will become the
normal in the workforce of the future”
22. Adds Jobs and Strengthens Economy
• Headlines like “Robots and AI will destroy
jobs” are more of a fiction than fact
• There will be a gradual, positive evolution in
the job market
• People will work better with the help of AI.
23. Enhances Lifestyle
- Naresh Soni , Tsunami
“Smart homes will reduce the energy usage and provide better security
for humans. Marketing will be more targeted and healthcare will become
more effective with smart devices”
24. Enhances Lifestyle
• Healthcare generates tons of data that can be used with
Artificial intelligence to diagnose diseases
• Real time insight to health conditions and can trigger emergency
responses to health care providers
• With AI we can diagnose faster and more accurately; develop
new drugs and research; reduce medical errors; predict drug
reactions; lowering cost of healthcare
25. Supervised Learning for Telemedicine
- Harold Quintus-Bosz , Cooper Perkins
“Artificial Intelligence has the potential to extend knowledge and
understanding to a broader population. Image based AI diagnoses of
medical conditions could allow for a more comprehensive deployment
of telemedicine”
26. Supervised Learning for Telemedicine
• Diagnoses diabetic retinopathy like highly trained ophthalmologist.
• Diagnoses, monitors and treats diabetic retinopathy remotely via
telemedicine
• Better diagnose with less human effort
• Portable fundus camera deployed to screening site
• Images securely transferred to the cloud for processing
• AI analyses images and provides a report for further human action
27. Solves Complex Social Problems
• Is a global database for litter
• Is a crowdsourced litter clean up app
• Identifies litter type, distribution and
location
• Finds more sustainable solutions
One piece of litter at a time
28. Improves Demand-Side Management
- Greg Sarich , Clrearesult
“From an energy standpoint, artificial intelligence can be used to
analyse and research historical data to determine how to most efficiently
distribute energy loads from a grid perspective ”
29. Improves Demand-Side Management
Machines become smarter over time
Computers are not susceptible to human errors
Energy Efficiency
Demand-Side Management
Demand Response
30. Improves Demand-Side Management
Smart home embedded
systems learns home
user power
consumption and
provides suggestion and
controls to reduce
power consumption
IoT enabled systems for
building power
management optimises
power consumption and
helps in reducing cost
Solar rooftops connected
to their platform to gather
natural energy and
monitor usage to reduce
overall production cost of
energy
31. Benefits multiple industries
- Mark Butler , Qualys
“AI risks are real if we don’t understand the quality of the incoming data
and set AI rules that are making granular trade-off decisions at
increasing computing speeds ”
33. Benefits multiple industries
• Biometric technology used to identify
human faces
• Used in security systems
• Commercial identification and marketing
tool
34. Extends and Expands Creativity
- Ganesh Padmanabhan , Cognitive Scale
“AI intelligence is the biggest opportunity of our lifetime to extend and
expand human creativity and ingenuity”
35. Extends and Expands Creativity
• Uses AI to transform how a person
would look in the future (older) and
past (younger) and other facial
features.
• AI detects features of the face and
then creates a possible look when
ageing is applied from historical data
of millions of images.
36. Extends and Expands Creativity
• Google Photos uses AI to propose
lighting changes that enhance a
photograph taken on a mobile device
or loaded to their service
• Create automated video clips from
photos and video stored on their
services
37. Impact of AI on
Multiple Industries and Use Cases
38. Key Takeaways
✦Artificial intelligence is the intelligence exhibited by machines and the capability of
machines to imitate human behavior.
✦The three stages of AI include Artificial Narrow Intelligence, Artificial General Intelligence
and Artificial Super Intelligence.
✦Various applications of AI include image recognition, speech recognition, natural
language processing, translation, product analytics, A/B testing and sentiment analysis.
✦AI contributes to the society by enhancing throughput and efficiency, adding jobs,
strengthening the economy, increasing human efficiency, enhancing the lifestyle, solving
complex social problems and benefiting multiple industries.
40. Learning Objectives
✦Discuss the meaning of machine learning and its relationship with AI
✦Describe the relationship between machine learning and statistical analysis
✦Explain the process of machine learning
✦List and compare the types of machine learning
✦Analyse different algorithms of machine learning
✦Explore the meaning of deep learning and artificial neural networks
41. “Machine learning can be defined as an approach to achieve artificial
intelligence through systems or software models that can learn from
experience to find patterns in a set of data.”
Definition of Machine Learning
42. Meaning of Machine Learning
An application of artificial
intelligence
An ability to automatically learn and
improve from experience
Recognizes data patterns and
creates rules rather than traditional
programming
Begins with observations or data,
such as direct experience, or
instructions to look for data patterns
43. Relationship between AI, ML and DL
Artificial Intelligence
1950’s 1960’s 1970’s 1980’s 1990’s 2000’s 2010’s
44. Relationship between AI, ML and DL
Artificial Intelligence
Machine Learning
1950’s 1960’s 1970’s 1980’s 1990’s 2000’s 2010’s
45. Relationship between AI, ML and DL
Artificial Intelligence
Machine Learning
Deep Learning
1950’s 1960’s 1970’s 1980’s 1990’s 2000’s 2010’s
46. AI Examples
Google uses artificial intelligence and machine
learning in almost all of its applications
49. Statistical Analysis
Collects and scrutinises the data sample to
identify trends
Statistical model is a formalisation of
relationships between variables in the form of
mathematical equations
51. Difference between ML
and Statistical Analysis
Machine Learning Statistical Analysis
• Is a subset of artificial intelligence in
the field of computer science
• Is associated with high-dimensional
data
• Takes away the deterministic function f
out of the equation:
Input (X) —-> Output (Y)
• Belongs to the field of mathematics
• Deals with finding a relationship
between variables to predict an
outcome
• Deals with low dimensional data
• Tries to estimate the function f:
Dependent Variable (Y) =
f(Independent Variable) + Error Function
58. Machine Learning Process
Training
+
Input Data
Machine Learning Algorithm
Algorithm studies the data
patterns
Works out a logic
Learned Model
Used with test data sets
Expected
Output
Labeled Training Data
59. Machine Learning Process
Testing
Test Data
Input Data
Learned Model
Classifies test data based on the
patterns learned from training
data
Uses patterns from the
test data and logic from
learned model to predict
and derive the outcome
Predictions
Output
Generates output based on
logic derived from training
data
61. Supervised Learning
• Is provided with training data along with the expected
output or rules to categorize this data also known as
labels
• Uses the set of input and outputs to predict the output for
future unseen inputs
Labelled Training Data
+
Input Data
Expected
Output
Machine Learning Algorithm
The ML Program
Learned Model
Used with test data sets
62. Supervised Learning Example
Step one: Train the model
1. Provide images of apples along with the
expected response to the model
Step two: Test the model
1. The model learns from labelled data
2. Provide images to the model again
without expected output
3. The output of the model is “These are
apples”
“These are apples”
LEARNED MODEL
Known Response
“These are apples”
New Response
LEARNED MODEL
63. Unsupervised Learning
Labeled Training Data
Input Data
Machine Learning Algorithm Learned Model
The ML Algorithm
• Learns from an unlabeled dataset
• Uses input data to train the model
• Is expected to find patterns and anomalies
64. Unsupervised Learning Example:
Image Identification
Step one: Input Unlabelled Data
1. Provide images of different kinds of fruit
without expected output
Step two: Test the model
1. The model identifies patterns like shape,
colour, and size
2. It groups the fruits based on these
features,attributes or qualities
LEARNED MODEL
Known Data
LEARNED MODEL
Known Data
65. Semi-Supervised Learning
• Is a hybrid approach
• Is a combination of supervised and unsupervised learning
• Uses a combination of labeled and unlabelled data
Semi-Supervised Learning
66. Semi-Supervised Learning Example
Step one: Input unlabelled data
1. Collect and group labelled and
unlabelled data for training
Step two: Test the model
1. Feed all the training data into the model
Training Data
Labelled Data
Unlabelled Data
Training Data
LEARNED MODEL
67. Reinforcement Learning
The Learning System
• Observes the environment and learns the ideal behaviour
• Selects and takes certain actions and receives rewards in
return
• Receives feedback in a loop
• Learns the strategy or policy that maximises rewards
68. Reinforcement Learning Example :
Robot
Tries to manipulate the environment
Walks and tries to go from one state to another
Receives a reward for accomplishing a sub module of
the task
69. Reinforcement Learning Example :
Robot
Identifies a device from one box and puts it in a
container
Learns by mean of a rewards based learning system,
which incentivises the right action
70. Machine Learning Algorithms
The choice of algorithm depends on the data type in the
use case
Regression Classification
Clustering /
Dimensionality Reduction
Continuous
Target
Discrete
Target
Labelled Data
Unlabelled Data
Association Analysis
Polynomial
Linear
Trees
SVM
KNN
Trees
Logistics
K-means
SVD PCA
Apriori
FP-Growth
71. Type of Supervised Learning
Regression Classification
Continuous
Target
Discrete
Target
Labelled Data
Polynomial
Linear
Trees
SVM
KNN
Trees
Logistics
Classification
Regression
77. Decision Trees
✦Is a graphical representation of all possible
solutions to a decision
✦Uses predictive models to achieve results
✦Is drawn upside down with its root at the top
✦Splits into branches based on a condition or
internal node
✦Doesn’t split the end of the branch, if it is the
decision / leaf
78. Decision Tree
Predicts continuous values like price of
a house
Referred to as CART
(Classification and Regression Tree)
Represents a single input variable (x)
and a split point on that variable
79. Naive Bayes
• Is a simple but surprisingly powerful algorithm for
predictive modelling
• Comprises two types of probabilities:
• The probability of each class
• The conditional probability of each class based on the
value of x
• Can be used to make predictions for new data
• Can easily estimate probabilities as bell curve for real-
valued data
• Is called naive because it assumes that each input
variable is independent
80. Naive Bayes Example : Spam
How does an email client classify between valid and spam emails?
82. Naive Bayes Classification
Prior Probability
• Is based on previous experience
• Of green: number of green objects / total number of objects
• Of red: number of red objects / total number of objects
83. Naive Bayes Classification
Prior Probabilities for Class Membership
• Prior probability for green : 40/60
• Prior probability for red: 20/60
87. Naive Bayes Classification
Calculation of prior probability
The final classification is produced by
combining both source of information,
the prior and the likelihood, to forma
posterior probability using Bayes’ rule.
90. K-Means Clustering : Examples
Behavioural
segmentation
Inventory
categorisation
Sorting
sensor
measurements
Detecting
bots or
anomalies
Segment by purchase
history
Segment by activities
on application, website
or platform
Define personas
based on interests
Create profiles based
on activity monitoring
Group inventory by sales
activity
Group inventory by
manufacturing metrics
Detect activity types in
motion sensors
Group Images
Separate audio
Identify groups in health
monitoring
Separate valid activity
groups from bots
Group valid activity to clean
up outlier detection
91. K-Means for Unsupervised Learning
K-Means involves two steps
Step 1: Cluster Assignment Step2 : Move Centroid Step
92. K-Means for Unsupervised Learning
• Travels through data points, depending on which
cluster is closer
• Assigns it to red, blue, or green cluster
Step One
93. K-Means for Unsupervised Learning
Calculates average of all points in cluster and moves
centroid to the average location
Step Two
95. Introduction to Deep Learning
“ Deep learning is a specialized form of machine learning that uses supervised,
unsupervised, or semi-supervised learning to learn from data representations. It is
similar to the structure and function of the human nervous system, where a complex
network of interconnected computation units work in a coordinated fashion to
process complex information. ”
96. Deep Learning
A subset of machine learning
Refers to deep artificial neural
network
Set new records in accuracy
Arranged in layers and learn
patterns of the patterns
97. Neural Network of Human Brain
Biological Neuron
Approximately 86 billion
interconnected neutrons
Input
Signals
Output
Signal
98. Neural Network of Human Brain
Biological Neuron
Process and transmit chemical and
electrical signals
Input
Signals
Output
Signal
99. Neural Network of Human Brain
Biological Neuron
Takes input and pass along the output
Input
Signals
Output
Signal
100. Neural Network of Human Brain
Biological Neuron
Responds to certain stimuli and passes
output to another
Input
Signals
Output
Signal
101. Neural Network of Human Brain
• Learns to identify objects from photos
• Uses neurons to understand and interpret
that the animal is a cat
102. Neural Network of Human Brain
• Each of these neuron may have different
weightage (governed by how important the
feature is) to the overall image
• If all these neurons fire in the same
direction our brain tells us that we saw a
cat
103. Neural Network of Human Brain
The more data you feed, the better
their recognition capability
104. Artificial Neural Network : Definition
“ Artificial Neural Network is a computing system made up of a number of simple,
highly interconnected processing elements which process information by the
dynamic state response to external inputs. ”
105. Artificial Neural Network
A mathematical function conceived as a
model of biological neurons
Modelled loosely after the human brain
Designed to recognise patterns
Interpret sensory data through machine
perception labelling or clustering
106. Features of Artificial Neuron
Cluster and classify the raw input
Group unlabelled dataset based on the
similarities in the inputs
Classify labelled dataset based on
expected results
Extract features fed to other algorithms
107. Definition of Perceptron
“ Perceptron is a neural network unit (an artificial neuron) that does certain
computations to detect features or business intelligence in the input data. ”
108. Meaning of Multilayer Perceptron
A single neuron model
A precursor to larger neural networks
Investigates how simple models of
biological brains can solve difficult
computational tasks
Develop robust algorithms and data
structures that can model difficult problems
109. Structure of Multilayer Perceptron
Model of a simple neuron Model of a simple network
Layer One network can have multiple layers
Network topology Hidden layers
Not directly exposed to the input
Single neuron in the hidden layer that directly outputs the
value
Output layer
110. Online and Batch Learning
Needs to be trained on your dataset
The weights in the network are
updated from the errors calculated for
each training example.
The errors can be saved up across all
of the training examples, and the
network can be updated at the end.
Can be used to make predictions
Online
Learning
Batch
Learning
111. Types of Deep Neural Networks
Multi-layer
fully-connected neural sets
Layers with more than one
hidden layer between input and
output layers
Neural networks that are used
for image processing and
classification
112. Uses of CNN
CNN is trained and used in the following ways
CNN
Applications
Automatic Video Classification Systems
Self-Driving
Cars
Image
Search
Voice
Recognition
Natural
Language
Processing
113. Future Prediction of AI
Google develops artificial intelligence
algorithm that predicts your death with
95% accuracy.
Singularity is predicted to be achieved by
2045 when computers will have the same
level of intelligence as that of humans.
Forbes estimates that 85% of customer
interactions will be managed by AI by 2020
The world’s leading car manufacturers
predict driverless cars will be on the
streets by 2020-2030
Doomsday AI machines could lead to
nuclear war, think tank paper warns.
115. Key Takeaways
✦The two subsets of Artificial Intelligence are machine learning and deep learning.
✦Machine learning algorithms learn form data whereas statistical model is a formalisation of relationship
between variables.
✦Supervised learning, unsupervised learning and semi-supervised learning are the the three types of machine
learning.
✦Reinforcement learning is an area in machine learning that is used when the training data has a feedback loop.
✦A decision tree is a tree-like graph that uses branching methods to demonstrate every possible outcome of a
decision.
✦Naive bayes’ is a classification technique, which assumes that the presence of a particular feature in a class is
unrelated to the presence of any other feature.
116. Key Takeaways
✦K-means clustering is a type of unsupervised learning, which is used to solve
clustering problems.
✦Neural networks are a set of algorithms, modelled loosely after the human brain,
which is designed to recognise patterns.
119. The Machine Learning Workflow
The job of the data scientist
The processes a data scientist follows to provide
feedback to decision makers
The machine learning process in business
environment
120. Goals of Machine Learning Workflow
• Identify actionable steps with a
given set of variables
• Derive meaningful conclusions for
complicated issues
• Derive answers to business
challenges
Goals
121. Yes
No
Yes
Yes
7 steps of Machine Learning
1
Get More
Data
2
Ask a
Sharp
Question
3
Add the
Data to
Table
4
Check for
Quality
5
Transform
Features
6
Answer
the
Question
7
Use the
Answer
122. Step 1 : Get More Data
Data can be collected in different formats
Investigate a business challenge
Quality of the model depends upon quality and
quantity of the data gathered
124. Step 2 : Ask a Sharp Question
Need for a
sharp
question
It focuses on a single topic
It helps you to get clear
answers to the questions.
It focuses on the exact need
and requirement
It is direct and specific
125. Step 2 : Ask a Sharp Question
(Vague vs Sharp)
Vague questions
1. Which route is fast ?
2. How to make more profit?
3. Will the users use more of the new features?
4. Which data can tell you about your business?
Sharp questions
1. Which route will get you to work faster?
2. How much sales needed to achieve 30% profit?
3. How many times will a user use the new product
features?
4. Which of the transaction is fraudulent?
126. Step 2 : Ask a Sharp Question
Example
✦Study different tables of data in the database and analyze your company’s
monthly sales performance
✦Understand how the company is doing in terms of market share
✦Analyze the historical data and predict the stock price for a future date
127. Step 3 : Add Data to the Table
Data analyst arranges data in database tables in a
systematic manner.
01
Systematic arrangement of data helps in detailed
analysis
02
Data is stored in the table in the form of columns and
rows.
03
Table columns represent data of a single type and rows
represent records pertaining to one entity.
04
Aggregate, distribute, compute of measure to derive
data analysis.
05
128. Data Analysis in Machine Learning
The process of deriving
new findings from
historical data
Focuses on aggregating
table data to find answers
to business problems
Performed by data
analysts to build machine
learning algorithms
129. Example : Add Data to the Table
• The stock price column shows the stock value across different
dates
• Each table row represents observations across given attributes
130. Example : Data Analysis
Aggregate and distribute the data as shown here:
131. Example : Aggregate
• You can aggregate the data in the table to derive answers
• This process is called data analysis and involves counting total
observations in a table or combining data from multiple tables
132. Example : Distribute, Compute, Measure
• An example of performing aggregate, distribute, compute and measure operations on
data in tables
• Each feature and their observations are distributed across the table and then
combined
133. Example : Estimate
• The market share column shows the estimated stock price values of the company that are
derived from the previous steps
134. Step 4 : Check for Quality
Determine if the data is acceptable
for further investigation
Ensure the data in a column is in a
consistent format
136. Check for Quality : Example
• There is inconsistencies in the data format in the Birth year column of the table
• Dates in the column need to be converted to a consistent format to make it readable for the
ML algorithm
137. Check for Quality : Example
• Denote the Birth year column numbers as numbers, without any special characters
• Checking data quality is a critical step
138. Step 5 : Transform Features
•Enables you to make sense out of the data, especially
when there are multiple features
•Help overcome challenges where some features may
not give useful information for the model, where as
some features may be combined to derive meaningful
information
Feature Engineering
139. Tricks of Feature Engineering
• Scale Invariant Feature Transform (SIFT): Images
• Term Frequency-Inverse Document Frequency (TF-IDF): Text
Data Specific
•Econometric, technological, agricultural and sociological
data engineering
Domain Specific
•Images, text and audio data engineering
Deep Learning
140. Transform Features : Example
• There are 3 columns and 65670 rows
• Features 0 and 1 have similar values
• The numbers are meaningless and scattered
141. Transform Features : Example
• Values of feature column 0 is multiplied with every observation in feature
column 1
• These values are plotted in image 2
142. Transform Features : Example
• By plotting the values obtained by subtracting feature 0 from feature 1, a
curve is formed
• This curve is a normal or gaussian distribution or bell-shaped curve
143. Step 6 : Answer the question
Helps to analyse if the obtained answers are clear
How much or how many?
Which category?
Which group?
Questions
Does this look strange?
Which action?
144. Answer the Question: Type 1
What will be the temperature this Friday?
01
How much or how many?
How many people will like your post?
02
What will be your product sales next month?
03
145. Answer the Question: Type 2
Is this an image of a dog?
01
Which category?
What is the topic of this news article?
02
Which hotel in your area offers free Wi-Fi?
03
146. Answer the Question: Type 3
Which group of shoppers purchase similar
products?
01
Which group?
Which group of viewers like horror movies?
02
How best can you divide this book into ten
topics?
03
147. Answer the Question: Type 4
Is this internet message typical?
01
Does this look strange?
Is this heart beat reading abnormal?
02
Do these transactions look unusual as
opposed to customers usual transactions?
03
148. Answer the Question: Type 5
Should you vacuum again or not?
01
Which action?
Should you beat the red light?
02
Should you raise or lower the temperature?
03
149. Step 7 : Use the Answer
Making up a decision
01
There are plenty of ways to use the answer
derived form the previous step.
Proposing the price of an item
02
Publishing the results obtained as part of a
research paper
03
Constructing a dashboard on a visualisation
tool
04
Making changes to product features
05
150. Key Takeaway
✦Machine learning workflow involves seven steps.
✦The first step of machine learning workflow is used to collect data to answer different business questions.
✦To get the desired response, always ask sharp questions and avoid vague ones.
✦Arrange raw data in tables for better data analysis.
✦To ensure data consistency data scientists must check for the quality of data.
✦The transform feature is used to increase the efficiency of the machine learning model.
✦The answer received by the model helps in solving business challenges.
✦Learn from the answer received by the model and implement it as a solution to the problem.
155. Need for Performance Metrics
✦How do you rank machine learning algorithm?
✦How can you pick one algorithm over the other?
✦How do you measure and compare these algorithms?
156. Need for Performance Metrics
✦ Performance metric is the answer to these questions.
✦It helps measure and compare algorithms.
157. - Stephen Few
“Numbers have an important story to tell.
They rely on you to give them a voice.”
Performance Metrics
158. - Stephen Few
“Numbers have an important story to tell.
They rely on you to give them a voice.”
Performance Metrics
Assess Machine Learning Algorithms
Machine learning models are evaluated against your selected
performance metrics
Help evaluate efficiency and accuracy of machine learning models
159. Key Methods of Performance Metrics
Classification Problem
Confusion Matrix Accuracy
Precision Recall
Specificity F1 Score
160. Meaning of Confusion Matrix
TP FP
FN TN
Actual
Positives(1) Negatives(0)
Positives(1)
Negatives(0)
Predicted
One of the most intuitive and easiest metrics used to
find correctness and accuracy
Not a performance measure
Almost all performance metrics are based on
confusion matrix
161. Confusion Matrix : Example
Cancer Prediction System
There are different approaches that can
hep the center predict cancer
Okay
Let me introduce you to one of the easiest
matrices that can help you predict whether a
person has cancer, the confusion matrix.
162. Confusion Matrix :
Classification Problem
How to predict if a person has cancer?
Give a label / class to the target variables:
When a person is diagnosed with cancer
When a person does not have cancer
1
0
163. Confusion Matrix :
Classification Problem
Sets of classes are given in both dimensions
TP FP
FN TN
Actual
Positives(1) Negatives(0)
Positives(1)
Negatives(0)
Predicted
165. True Positive
True Positive
TP
TP
TN
TN
FN
FN
FP
FP
True Positives are the cases where the actual
class of the data point is 1 (true) and the predicted
value is also 1 (true).
The case where a person has cancer and the
model classifies the case as cancer positive comes
under true positive.
166. True Negative
True Negative
TP
TP
TN
TN
FN
FN
FP
FP
True Negatives are the cases when the actual
class of the data point is 0 (false) and the
predicted is also 0 (false). It is negative because
the class predicted was negative.
The case where a person does not have cancer
and the model classifies the case as cancer
negative comes under true negative.
167. False Positive
TP
TP
TN
TN
FN
FN
FP
FP
False positives are the cases when the actual class
of the data point is 0 (false) and the predicted is 1
(true). It is false because the model has predicted
incorrectly.
The case where a person does not have cancer
and the model classifies the case as cancer
positive comes under false positive.
False Positive
168. False Negative
False Negative
TP
TP
TN
TN
FN
FN
FP
FP
• False negatives are the cases when the actual
class of the data point is 1 (true) and the
predicted is 0 (false).
• It is false because the model has predicted
incorrectly.
• It is negative because the class predicted was
negative.
The case where a person has cancer and the
model classifies the case as cancer negative
comes under false negatives.
169. Minimize False Cases
What should be
minimised?
✦A model is best identified by its accuracy
✦No rules are defined to identify false cases
✦It depends on business requirements and context of the
problem.
170. Minimize False Negative : Example
Out of 100
people
Actual cancer
patients = 5
Bad Model
Predicts everyone as non-
cancerous
Accuracy = 95%
When a person who does not have cancer
is classified as cancerous
Missing a cancer patient will be a huge
mistake
171. Minimize False Positive : Example
The model needs to classify an email as spam or
ham (term used for genuine email).
Assign a label / class to the target variables:
Email is spam
Email is not spam
1
0
172. Minimize False Positive : Example
Incoming mail Model
In case of false positive
Important email as
spam
!
Business stands a chance to
miss an important
communication
An important email marked as
spam is more business critical
than diverting a spam email to
inbox.
Classifies
Incoming mail Model
175. Accuracy : Example
When the target variable
classes in the data are nearly
balanced
When do we use
accuracy?
176. Accuracy : Example
The machine learning model
will have approximately 97%
accuracy in any new
predictions.
177. Accuracy : Example
5 out of 100 people have cancer
When do you
NOT use
accuracy?
It’s a bad model and predicts every case as
noncancerous
It classifies 95 noncancerous patients correctly and
5 cancerous patients as noncancerous
Accuracy of the model is 95%
When the target variable classes in the data are a
majority of one class
178. Precision
• Refers to the closeness of two or more
measurements
• Aims at deriving correct proportion of
positive identifications
180. Precision : Example
Its a bad model and predicts every case as cancer
When do we use
precision?
Everyone has been predicted as having cancer
Precision of the model is 5%
5 out of 100 people have cancer
181. Recall or Sensitivity
Recall or sensitivity measures the
proportion of actual positives and that are
correctly identified.
183. Recall or Sensitivity : Example
Predicts every case as cancer
When do we use
recall?
Recall is 100%
Precision of the model is 5%
5 out of 100 people have cancer
184. Recall as a Measure
When do we use
precision and
when do we use
recall?
Precision is about being
precise, whereas recall is
about capturing all the cases.
185. Recall as a Measure
When do we use
precision and
when do we use
recall?
If the model captures one
correct cancer positive case, it
is 100% precise.
186. Recall as a Measure
When do we use
precision and
when do we use
recall?
If the model captures ever
case as cancer positive, you
have100% recall.
187. Recall as a Measure
When do we use
precision and
when do we use
recall?
To focus on minimising false
negatives you would want
100% recall with a good
precision score.
188. Recall as a Measure
When do we use
precision and
when do we use
recall?
To focus on minimising false
positives you should aim for
100% precision.
189. Specificity
• Measures = proportion of actual
negatives that are correctly identified
• Tries to identify probability of a negative
test result when input with a negative
example
191. Specificity : Example
Predicts every case as cancer
So specificity is
the exact
opposite of
recall
Specificity is 0%
5 out of 100 people have cancer
192. F1 Score
Do you have to carry both precision and
recall in your pockets every time you
make a model to solve a classification
problem?
No to avoid taking both precision and
recall, its best to get a single score
(F1 score) that can represent both
precision (P) and recall (R).
193. F1 Score : Calculation
3 97
0 0
Actual
Fraud Not Fraud
Fraud
Not Fraud
Predicted
F1 Score =
2 * Precision * Recall
Precision + Recall
194. F1 Score : Example
97 out of 100 credit card transactions are legit and 3
are fraud
When do you
use F1 score?
Predicts everything as fraud
Fraud detection
195. F1 Score : Example
Precision =
3
100
= 3%
Recall =
100
3
= 100%
Arithmetic Mean =
3+100
2
= 51.5%
196. Harmonic Mean
• Harmonic mean is an average used when x
and y are equal
• Value of the mean is smaller when x and y
are different
With reference to the fraud detection
example, F1 Score can be calculated as
F1 Score =
2 * Precision * Recall
Precision + Recall
=
2 * 3 * 100
100 + 3
= 5%
197. Key Takeaways
✦Confusion matrix is used to find correctness and accusation of machine learning models. It is also used
for classification problems where the output can be one of two or more types of classes.
✦Accuracy is the number of correct prediction made by the model over all kinds of predictions.
✦Precisision refers to the closeness of two or more measurements to each other
✦Recall measures the proportion of actual positives that are identified correctly.
✦Specificity measures the proportion of actual negatives that are identified correctly.
✦F1 Score gives a single score that represents both precision (P) and recall (R).
✦Harmonic mean is used when the sample data contains extreme value because it is more balanced than
arithmetic mean.
202. Relationship between
Data Science, ML and AI
Data
Science
Machine
Learning
Artificial
Intelligence
Data
Insight
Action
Features
Prediction
Transformation
Deep
Learning
Analytics
Human
decision
Automated
decision
206. Why Python ?
✦Simple language to learn - syntax wise - general purpose programming language
✦Hassle free and fast for prototyping to production
✦Supports all modern programming constructs: OOP, Web, Microservices etc.
✦Continuously and actively updated - 72,000++ libraries
✦Supports the largest number of libraries for machine learning and data science
✦FREE and portable open source platform
207. Getting started
✦Installing Anaconda - all in one tool for data science, machine learning, artificial
intelligence and visualisation.
✦ www.anaconda.com
✦Download -> Anaconda Distribution (open source)
✦Anaconda Enterprise - Enterprise features to manage organisation wide output of
DS/ML/AI projects
208. Jupyter Notebook
✦Open-source web application (included as part of Anaconda)
✦Create and share documents that contain live code, equations, visualizations and
narrative text.
✦Describe data cleaning and transformation, numerical simulation, statistical
modeling, data visualization, machine learning, and much more.