0% found this document useful (0 votes)
110 views85 pages

Day 4 Session 1 PDF

The document provides an introduction to machine learning and its applications over 6 days. It discusses key concepts like artificial intelligence, machine learning algorithms including KNN, Naive Bayes, decision trees, regression, neural networks and SVM. It explains how machines learn through data storage, abstraction, generalization and evaluation. Common machine learning techniques like supervised learning, unsupervised learning and reinforcement learning are also introduced.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
110 views85 pages

Day 4 Session 1 PDF

The document provides an introduction to machine learning and its applications over 6 days. It discusses key concepts like artificial intelligence, machine learning algorithms including KNN, Naive Bayes, decision trees, regression, neural networks and SVM. It explains how machines learn through data storage, abstraction, generalization and evaluation. Common machine learning techniques like supervised learning, unsupervised learning and reinforcement learning are also introduced.

Uploaded by

Manoj Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 85

AICTE Sponsored 6 Days STTP on:

DATA ANALYTICS AND MACHINE LEARNING.


3 – 8 August 2020

Introduction to
Machine Learning and
its Applications.
Gloriya Mathew
Asst. Professor
Amal Jyothi College of Engineering
Kanjirappally.
Contents
 Artificial Intelligence:
 Machine Learning:
 Definition.
 How Machines Learn ?
 Common Machine Learning Algorithms(Models).
 KNN
 Naïve Bayes
Decision Trees
Regression Model
Neural Networks
Support Vector Machine(SVM)
 Evaluating Model Performance.
 Improving Model performance.
 Tools Used in Machine Learning.
 Applications.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Artificial Intelligence ???

 Ability of machines in conducting Intelligent Tasks.

 Intelligent Programs:
 Programs conducting specific Intelligent Tasks.
Artificial Intelligence (cntd.)

Eg:- ``Sophia``
 A social humanoid robot
 Developed by Hanson
Robotics.
 First public appearance in
Texas, US.
 Able to display more than
50 facial expressions.
 Participated in many high-
profile interviews.
Robot – ‘Sophia’ Interview
 First robot to receive
citizenship of any country.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Artificial Intelligence - Examples.
 Robotics.
 Smartphones
 Smart Cars and Drones.
 Social Media.
 Music and Media Streaming Services(youtube).
 Video Games
 Online Ads Network.
 Navigation and Travel(Google Maps).
 Banking and Finance sector.(Fraud Detection)
 Smart Home Devices.
Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Artificial Intelligence (cntd.)
Machine Learning.
 It is the Science of Teaching Machines How to Learn by
Themselves.
 Focuses on the development of computer programs that can
change when exposed to new data.
 Machine learning is about Predicting the future, based on the
past.
 Algorithms or techniques that enable computer (machine) to
“learn” from data.
 As intelligence requires knowledge, it is necessary for the
computers to acquire knowledge.
 Related with many areas such as:
• Data Mining
• Statistics etc…

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Machine Learning (cntd.)

TP: programmer creates ML: the algorithm


the program. one has to automatically
manually formulate or formulates the rules
code rules. from the data.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Machine Learning (cntd.)
How Machines Learn ?
 Tom M. Mitchell states that:
 “A machine learns whenever it is able to utilize its
‘an experience’ such that its performance
improves on similar experiences in the future”.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn?

Conditions
necessary for
Human brains are computers to
naturally capable of learn must be
learning from birth. made Explicit.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn?
 Regardless of whether the learner is a Human or
Machine, the basic learning process is similar.
 It can be divided into 4 - Interrelated Components:
 Data storage
 Abstraction
 Generalization
 Evaluation Learning
Process
Same

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.)

1. Data Storage:
 Utilizes observation, memory, and recall to provide a factual
basis for further reasoning.
 All learning must begin with data.
 Humans  brain
 Computers uses  hard disk drives, flash memory, and
random access memory (RAM) in combination with a
Central Processing Unit (CPU).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.)

2. Abstraction:
 Involves the translation of stored data into broader
representations and concepts.
 Basis of Knowledge Representation.
 During this process, the computer summarizes stored
raw data using a model;
Model  An explicit description of the patterns
within the data.
Mathematical Equations.
Relational Diagrams.( trees, graphs...)
Logical if/else rules.
Groupings of data known as clusters.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.) :
Abstraction(cntd.)
Training (Model Training)
 The process of fitting a model to a dataset is known as training.
 When the model has been trained, the data is transformed into
an abstract form that summarizes the original information.
 Eg: Discovery of gravity.

i.e, by becoming the


‘g’ term in a model
that explains
observations of falling
objects.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.) :

3. Generalization:
 Uses abstracted data to create knowledge and inferences
that drive action in new contexts.
 It involves Reduction of data set into a manageable number
of important findings.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.) :

4. Evaluation:
 To Evaluate/Measure the performance of the model &
 Use this information to inform additional training if needed.
 The model is evaluated using a new Test Dataset.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
How Machines Learn ? (cntd.) :

Steps in the Learning Process:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Machine Learning in Practice.
5-step process:
1. Data Collection:
2. Data Exploration and Preparation:
 Checking the Quality of data & Prepare data for learning process.
3. Model Training:
 Selection of an appropriate algorithm, and the algorithm will represent
the data in the form of a model.
4. Model Evaluation:
 Evaluating the accuracy of the model using the test data set.
5. Model Improvement:
 If better performance is needed , use advanced strategies to improve the
performance of the model.
 Switch to different model.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Types of Machine Learning Algorithms:
1. Supervised Learning.
2. Unsupervised Learning.
3. Reinforcement Learning.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Supervised Learning:
 Supervised learning is where you have Input Variables (X) and an Output
Variable (Y) and you use an algorithm to learn the mapping function from the
input to the output.
Y = f(X)
 In supervised learning, we use known or labeled data for the Training
Dataset. Since, Data Label is known; So, the learning is, therefore,
Supervised; i.e., Directed into Successful Execution.

o Eg:-
o K-nearest neighbors
o Naive Bayes.
o Decision trees
o Random forest
o Regression,..
Eg:- To Predict whether
“An e-mail message is spam/NOT.”

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Unsupervised Learning.
• Have Input Data (X) and No corresponding Output Variables.
Goal:
• To “model the underlying structure or distribution in the data”
in order to learn more about the Data.

•Eg:-
•Clustering.
• Pattern Discovery.
•Association Rules Mining

Eg:- “If user buys Bread then machine


should automatically give him a
suggestion to buy Jam. ”

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Reinforcement Learning.
 Reinforcement Learning is said to be the hope of true artificial
intelligence.
 Learning from Mistakes.
 it is the training of machine learning models to make a sequence
of decisions.
 A start state and end state are defined.
 The agents discovers the path and the relationships on its own.
 It is a slightly complex as compared to traditional machine
learning.
 eg:- Chess game
 Self driven cars etc..

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Common Machine Learning Algorithms.

KNN
Naïve Bayes
Decision Trees
Regression Model
Neural Networks
Support Vector Machine(SVM)

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
The KNN (K-Nearest Neighbors) Algorithm:

 It uses information about an example's K-nearest Neighbors


to classify unlabeled examples.

 A Simple, Easy-to-implement supervised machine learning


algorithm.

 Widely used.
 k  a variable implying that any number of nearest
neighbors could be used.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
The KNN (K-Nearest Neighbors) Algorithm(cntd.):

Uses:
 Computer vision applications:
 (Optical Character Recognition and Facial Recognition).
 Predicting whether a person will enjoy a movie or
music .
 Identifying patterns in genetic data.
 Classification

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
The KNN (K-Nearest Neighbors) Algorithm(cntd.):

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Is Tomato a Fruit or Vegetable?
 Locating the tomato's nearest
neighbors requires a distance
function / A formula that measures
the similarity between the two
instances.
 k-NN algorithm uses Euclidean
distance:
 p & q  examples to be compared,
each having n - features.
 p1  the value of the first feature
of example p;
 q1  the value of the first feature of
example q:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Euclidean Distance (cntd.):

• The distance formula involves comparing the values of each


feature.
 Eg:- To calculate the distance between Tomato And Green Bean:
 Tomato (Sweetness = 6, Crunchiness = 4), &
 Green Bean (Sweetness = 3, Crunchiness = 7);
• use the formula as:

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


Measuring similarity with distance
(cntd.)
• calculate the distance between the tomato and several
of its closest neighbors as follows:


• K=1;  Orange  FRUIT Tomato==FRUIT.
• K=3;  Orange, Grapes, Nuts  Among these majority class is
Fruit  Tomato = FRUIT.

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


•Naive Bays' classifier:
– Probabilistic Learning:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Naive Bayes' classifier
 A probabilistic Machine Learning Model that is
used for classification task.
 Probabilistic Classifier:
 A classifier that is able to predict, given a sample input, a
probability distribution over a set of classes.
 Eg:- Meteorologist – weather forecast- “70 % chance of rain
“.
 A 70% chance of rain  7 out of the 10 past cases with
similar conditions, precipitation(weather condition) occurred
somewhere in the area.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Naive Bayes' classifier(cntd.)
 Based on the Bayes theorem.
 It captures the chance(probability) that an event will
occur in the light of the available evidence.
 Bayes Theorem:

 P(A|B)  “probability of event A, given that event B


occurred”.
Since, probability of A is dependent on what
happened with event B.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Naive Bayes' classifier(cntd.)
Uses:
 Text Classification (eg:- spam e-mail filtering).

 Intrusion / Anomaly Detection in computer networks.

 Diagnosing medical conditions. (given a set of observed


symptoms).

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


Naive Bayes' classifier(cntd.)
• Eg: - Spam Email Filter:
Eg: - “Congratulations, you’ve won the $500
Wishpond Gift Card Grand Prize in our ‘$500
Summer Giveaway’ contest!”

P(spam|congratulations):= 0.80.
• probability is 80 % that a message
is spam, given that it contains the
word congratulations.
• In light of this result, any message
containing this term should
probably be filtered.

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


Decision Trees.
 A type of Supervised Learning Algorithm

 Used to visually represent a Decision Making Process.

 Present their knowledge in the form of logical


structures(Tree).

 Useful for business strategy and process improvement.


 Powerful classifiers.
 Utilize a tree structure to model the relationships among the
features and the potential outcomes.

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


Decision Trees(cntd).
Components:
 Root node.
 Decision nodes choices to be made based on the attributes of
the job.
 Branches  potential outcomes of a decision (yes or no ).
 Leaf nodes final decision (terminal nodes).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Decision Trees(cntd).
Decision Trees(cntd).
Benefits:
 Interpretability: Easy to Interpret, understand, and visualize
 Can handle both Numerical and Categorical Data.
 Simple to prepare and fit model.
Uses:
1. Credit scoring models  An applicant to be rejected /NOT.
2. Marketing studies of customer behavior such as Satisfied or
NOT.
3. Diagnosis of medical conditions based on laboratory
measurements, symptoms, or the rate of disease progression.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Decision Trees(cntd).
Divide and Conquer.
 Decision trees are built using a heuristic called Recursive
Partitioning.
 commonly known as Divide and Conquer:
 It splits the data into subsets, which are then split repeatedly
into even smaller subsets, and so on &
 Until the process stops when the algorithm determines the
data within the subsets are sufficiently homogenous, or
another stopping criterion has been met.
 STOPPING Conditions:
1. All (or nearly all) of the examples at the node have the same class.
2. There are no remaining features to distinguish among the examples.
3. The tree has grown to a predefined size limit.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Regression Methods:
1. Simple Linear Regression
2. Multiple Linear Regression

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Regression.
 A Supervised Machine Learning Algorithm.
 Specifies the mathematical relationship between a single numeric
dependent variable (the value to be predicted) and one or more
numeric independent variables (the predictors).
 eg:- Income  related to education and job experience.
 Regression equations model data using a Slope-intercept Format.
y = a + bx. y  Dependent variable
x  Independent variable.
b  Slope
a  Intercept

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Regression(cntd.).
1. Simple Linear Regression:
 Defines a Mathematical Relationship between a dependent
variable and a Single independent variable using a Line.

 defined by equation :

Ordinary Least Squares (OLS) Estimation:


 An Estimation Method used to determine the optimal
estimates of α and β.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Regression(cntd.).
2. Multiple Linear Regression
(Multiple Regression):
Mathematical Relationship between a dependent
variable Two or more independent variables.

 General form:

 epsilon - €  An error term (residual term)

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Other Regression Methods:
 Logistic Regression:

 Used to model a Binary Categorical Outcome.

 Poisson Regression:

 Models Integer Count Data.

 Multinomial Logistic Regression:

 Models a Categorical Outcome;

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Black Box Methods:
1. Neural Networks &
2. Support Vector Machines ( SVM )

• The mechanism that transforms the input into the


output is obfuscated(unclear) by an imaginary box.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
An Artificial Neural Network (ANN)
 A supervised Machine Learning Algorithm.
 Designed as Conceptual Models of Human Brain Activity.
 ANN uses a Network of Artificial Neurons or nodes to solve
learning problems.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
An Artificial Neural Network (ANN) (cntd.)

Applications:
 ANNs are versatile learners that can be applied to
nearly any learning task:
– Classification,
– Numeric prediction
– Unsupervised pattern recognition.
• Speech and handwriting recognition programs.
• Automation of smart devices.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
An Artificial Neural Network (ANN) (cntd.)
Directed Network Diagram:
 Defines a relationship between the input signals received by
the dendrites (x variables), and the output signal (y variable).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
An Artificial Neural Network (ANN) (cntd.)

An Artificial Neuron with n – inputs:


 A typical artificial neuron with n input dendrites can be
represented by the formula :

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
An Artificial Neural Network (ANN) (cntd.)

Characteristics of Neural Networks:


– An activation function.
– Network Topology (Architecture).
– Training Algorithm

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
An Artificial Neural Network (ANN) (cntd.)

1. An activation function:
 Transforms a neuron's combined input signals into a single
output signal to be broadcasted further in the network.
• eg: Threshold Activation Function.

The neuron fires when


the sum of input
signals is at least zero.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
An Artificial Neural Network (ANN) (cntd.)

2. Network Topology (Architecture).


 3- Key Characteristics:
1. The number of layers.
2. Whether information in the network is allowed to travel
backward.
3. The number of nodes within each layer of the network.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Network Topology (cntd.).

1. The Number of Layers:


• A terminology that Distinguishes artificial neurons based on their
position in the network.
 Layers:
 The input and output nodes are arranged in groups known as
layers.
• Figure : Topology of a very simple network.
Input Nodes:
A set of neurons which receives
unprocessed signals directly from the
input data.
Output Node:
The signals sent by the input nodes are
received by the output node, which uses
its own activation function to generate a
final prediction (p).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Network Topology (cntd.).

The Number of Layers(cntd):

 Single-layer Networks:
– Only One Layer.
 Multilayer Network:
 Create more Complex Networks  by adding additional Hidden
layers.
Single Layer Network: Multilayer Network:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Network Topology (cntd.).

2. Direction of Information Travel:


Feed Forward Networks.
Recurrent Network (Feedback Network).

Feed Forward Networks: A Simple Recurrent Network:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Network Topology (cntd.).

Multi-Layer Perceptron (MLP):


 Multilayer feedforward network is also known as MLP.
 It is the de-facto standard ANN topology.
 Perceptron  “Artificial Neuron”.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Network Topology (cntd.).

3. Number of Nodes in each Layer:


 Neural networks can also vary in complexity by the number of
nodes in each layer.
 Number of Input Nodes:
– Predetermined by the No. of Features in the input data.
 Number of Output Nodes:
– Predetermined by the No. of Outcomes to be modeled or the
number of class levels in the outcome.
 Number of Hidden Nodes:
 No reliable rule to determine the number of neurons in the
hidden layer.
 Best Practice: Use the fewest nodes that result in adequate
performance.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Deep Learning
Deep Neural Network (DNN):
 A neural network with Multiple
Hidden Layers.
 Practice of training DNN 
Deep Learning.
Applications:
 Facebook - Identifying faces
in photographs by using deep
learning.
 Speech Recognition.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Support Vector
Machines (SVM):

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Support Vector Machines(SVM)
 Goal of SVM:
 To create a flat boundary called a hyperplane, which divides
the space to create fairly homogeneous partitions on either
side.
 SVM Learning Combines :
 KNN + Linear Regression.
 The combination is extremely powerful.
 To model highly complex relationships.
 Uses:
Classification
Numeric prediction.
Pattern recognition.
Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Support Vector Machines(cntd.)
Applications:
1. Gene Expression Data Classification:
 In the field of bioinformatics to identify cancer or
other genetic diseases.
2. Text categorization:
Identification of the language used in a document
classification of documents by subject matter.
3. The detection of rare yet important events:
Combustion engine failure, security breaches, or
earthquakes.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Hyperplanes

 A boundary which partitions the data into groups of


similar class values.
 SVM’s uses hyperplanes to partition data into groups
of similar class values.
 In Two Dimensions:
 The task of the SVM algorithm is to identify a line
that separates the two classes.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Hyperplanes (cntd..)

 More than one choice of dividing


line between the groups of circles
and squares.
 Three such possibilities are
labeled a, b, and c.
 How does the algorithm choose?
 Maximum Margin
Hyperplane.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Maximum Margin Hyperplane(MMH):
Creates the greatest separation between the two classes.

Support Vectors:
 Points from each class that are the
closest to the MMH;
 Using the support vectors alone, it is
possible to define the MMH.
 This is a key feature of SVMs;

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Clustering
• Unsupervised learning algorithms
• It mainly deals with finding a structure or pattern in a collection
of uncategorized data.
• Clustering algorithms will process your data and find natural
clusters(groups) if they exist in the data.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Evaluating Model Performance:

• Evaluating Model Performance:


Confusion Matrix

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering.
Evaluating Model Performance(cntd):

 The process of evaluating machine learning


algorithms/Models.

 Algorithms have varying strengths and weaknesses,


tests should distinguish among the learners.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Evaluating Model Performance(cntd):

Confusion Matrices

 A Table that Categorizes Predictions according to whether they


Match the Actual Value.

 One dimension  Predicted Class values;

 Other dimension  Actual Class values.

Prepared
Prepared by:by: Gloriya
Gloriya Mathew,
Mathew, Asst.
Asst. Professor,
Professor, Amal
Amal Jyothi
Jyothi College
College of of Engineering
Engineering
Evaluating Model Performance(cntd):

2 x 2 Confusion Matrix for a Two-class Binary Model.

Correct Predictions:
 Predicted Value = Actual Value 
a correct classification.
 Diagonal Elements in the
confusion matrix.(denoted by O).
Incorrect Predictions:
 Predicted Value Differs from the
Actual Value.
 The off-diagonal matrix cells.
Confusion Matrix (cntd):
Positive Class:
• The Class of Interest is known as the positive class;
• All others are known as Negative Class.
 Predictions fall into one of the 4- categories:
1. True Positive (TP): Correctly classified as the class of interest.
2. True Negative (TN):  Correctly classified as NOT the class of
interest.
3. False Positive (FP):  Incorrectly classified as the class of
interest.
4. False Negative (FN):  Incorrectly classified as NOT the class of
interest.

Preparedby:
Prepared by:Gloriya
GloriyaMathew,
Mathew, Asst.Professor,
Asst. Professor, AmalJyothi
Amal JyothiCollege
CollegeofofEngineering
Engineering
Using Confusion Matrices to Measure Performance.

Prediction Accuracy (Success Rate):


• Accuracy = (TP + TN)/(TP+TN+FP+FN);

Error Rate:
 Proportion of the Incorrectly Classified examples:
 Error rate = 1 - accuracy.
 Error Rate=(FP+FN)/(TP+TN+FP+FN)

Eg: A model is correct 95% of the time is, incorrect 5% of


the time.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Evaluating Model Performance(cntd):

Precision:
 Proportion of positive examples that are truly positive;

Recall :
 Measure of how complete the results are.
 Eg:-SMS spam filter has a high recall if the majority of spam
messages are correctly identified.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
The Holdout Method
 The procedure of partitioning data into Training Datasets
and Test Datasets :
Training Dataset(2/3)  Used to Generate The Model;
Test Dataset(1/3)  To Generate Predictions for
evaluation.
 Validation Dataset  Used for Iterating and Refining
The Model or models chosen.
 Eg:- A typical split :
 Training DS(50%), Test DS(25%), Validation DS(25%).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
The Holdout Method
Improving
Model Performance:

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance:

Meta-learning:
• Technique of combining and managing the
predictions from multiple models to form a powerful
model.
Ensemble methods:
 Meta-learning approach
 Idea:
By combining multiple weaker learners, a stronger
learner is created.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance(cntd.)

Fig: Ensemble Approaches

1. Input Training Data  Used to build a number of models.


2. Allocation Function  Dictates how much of the training
data each model receives.
3. Combination Function  How the Results are Combined?

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance(cntd.)

Improving Model Performance


with Ensemble Learning:
 Bagging
 Boosting.
 Random Forest.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance(cntd.)
 Bagging
 One of the first ensemble
method.
 Widespread Acceptance.
 Uses a technique called
bootstrap aggregating or
bagging.
 The models' predictions are
combined using Voting (for
classification) or Averaging
(for numeric prediction).

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance(cntd.)

Boosting
 Another common ensemble-based method
 It boosts the performance of weak learners to attain the
performance of stronger learners.
 Similar to bagging.

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Improving Model Performance(cntd.)

Random Forests.
(Decision Tree Forests.)
Improving Model Performance(cntd.)
Random Forests (Decision Tree Forests.)
Ensembles of decision trees.
After the ensemble of trees (the forest) is generated,
the model uses a vote to combine the trees' predictions.
 randomForest()

Prepared by: Gloriya Mathew, Asst. Professor, Amal Jyothi College of Engineering
Tools & Languages.
• Languages: • Visualization tools:
 R
• Tableau
 Python
• QlikView
 Java
 Javascript • D3.js
 SAS
 Julia • Other tools commonly
• Databases: used:
 SQL
• Excel
 Oracle
 Hadoop • Powerpoint
Applications of Machine Learning in day-to-day life

 Automatic Friend Tagging Suggestions in Facebook.


 Smartphones detecting faces while taking photos or unlocking
themselves.
 Facebook, LinkedIn or any other social media site
recommending your friends and ads you might be interested in.
 Amazon / Flipkart recommending you the products based on
your browsing history.
 Banks using Machine Learning to detect Fraud transactions in
real-time.
 Speech to Text Conversion.
 Google Maps.
 Online Customer Support, etc.

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.


STTP: Introduction to Machine Learning and its Applications.

Thank You.

Prepared by: Gloriya Mathew - Asst.Professor, Amal Jyothi College of Engineering.

You might also like