SlideShare a Scribd company logo
1 of 42
COURSE NAME: INTRODUCTION
TO MACHINE LEARNING
(ELECTIVE)
CREDITS: 3
ACADEMIC YEAR: 2022-23 (EVEN SEMESTER)
1
MODULE 3
2
SYLLABUS
� A Tour of Machine Learning Classifiers Using Scikit-
learn
� Choosing a classification algorithm First steps with
scikit-learn Training a perception via scikit-learn
� Modeling class probabilities via logistic regression
Logistic regression intuition and conditional probabilities
Learning the weights of the logistic cost function Training a
logistic regression model with scikit-learn Tackling over
fitting via regularization.
�
3
SYLLABUS
� Maximum margin classification with support vector
machines Maximum margin intuition Dealing with the
nonlinearly separable case using slack variables Alternative
implementations in scikit-learn
� Solving nonlinear problems using a kernel SVM Using
the kernel trick to find separating hyper planes in higher
dimensional space
� Decision tree learning Maximizing information gain –
getting the most bang for the buck Building a decision tree
Combining weak to strong learners via random forests
� Self Learning Exercise: K-nearest neighbors – a lazy
learning algorithm
4
A TOUR OF MACHINE LEARNING CLASSIFIERS
USING SCIKIT-LEARN
� There are popular and powerful ML algorithms
that are commonly used in academia as well as in
industry.
� While learning about the differences between
several supervised learning algorithms for
classification, we will also develop an intuitive
appreciation of their individual strengths and
weaknesses.
� The scikit-learn library, which offers a user-
friendly interface for using those algorithms
efficiently and productively. 5
� Robust and popular algorithms for classification,
such as
⚫ logistic regression,
⚫ support vector machines, and
⚫ decision trees
� Examples and explanations using the scikit-learn
machine learning library, which provides a wide
variety of machine learning algorithms via a
user-friendly Python API
� Discussions about the strengths and weaknesses
of classifiers with linear and nonlinear decision
boundaries
6
CHOOSING A CLASSIFICATION ALGORITHM
� To restate the no free lunch theorem by David
H. Wolpert, no single classifier works best across
all possible scenarios.
� In practice, it is always recommended that you
compare the performance of at least a handful of
different learning algorithms to select the best
model for the particular problem;
� these may differ in the number of features or
examples, the amount of noise in a dataset, and
whether the classes are linearly separable or not. 7
� The performance of a classifier—computational
performance as well as predictive power—
depends heavily on the underlying data that is
available for learning
� The five main steps that are involved in training
a supervised machine learning algorithm
1. Selecting features and collecting labeled training
examples.
2. Choosing a performance metric.
3. Choosing a classifier and optimization algorithm.
4. Evaluating the performance of the model.
5. Tuning the algorithm. 8
FIRST STEPS WITH SCIKIT-LEARN – TRAINING A
PERCEPTRON
� In Module 2, Training Simple Machine Learning
Algorithms for Classification,
the perceptron rule and Adaline, which is
implemented in Python and NumPy.
� Now consider the scikit-learn API, which,
combines a user-friendly and consistent interface
with a highly optimized implementation of
several classification algorithms.
� The scikit-learn library offers not only a large
variety of learning algorithms, but also many
convenient functions to preprocess data and to
fine-tune and evaluate our models. 9
� To get started with the scikit-learn library, we will
train a perceptron model similar to the one that we
implemented in Module 2.
� For simplicity, we will use the already familiar Iris
dataset .
� we will only use two features from the Iris dataset for
visualization purposes.
� We will assign the petal length and petal width of the
150 flower examples to the feature matrix, X, and the
corresponding class labels of the flower species to the
vector array, y: 10
11
12
13
14
15
16
17
18
LOGISTIC REGRESSION IN MACHINE LEARNING
� Supervised Learning technique used for predicting
the categorical dependent variable using a given set
of independent variables.
� it gives the probabilistic values which lie
between 0 and 1.
� Linear Regression is used for solving Regression
problems, whereas Logistic regression is used for
solving the classification problems.
19
� Logistic Regression can be used to classify the
observations using different types of data and can
easily determine the most effective variables used
for the classification. The below image is showing
the logistic function:
20
LOGISTIC FUNCTION (SIGMOID FUNCTION):
� The sigmoid function is a mathematical function used to
map the predicted values to probabilities.
� It maps any real value into another value within a range of
0 and 1.
� The value of the logistic regression must be between 0 and
1, so it forms a curve like the "S" form.
� The S-form curve is called the Sigmoid function or the
logistic function.
� In logistic regression, we use the concept of the threshold
value, which defines the probability of either 0 or 1.
21
LOGISTIC REGRESSION EQUATION:
22
� Type of Logistic Regression:
� On the basis of the categories, Logistic Regression can be
classified into three types:
� Binomial: In binomial Logistic regression, there can be,
Pass or Fail, etc. only two possible types of the dependent
variables, such as 0 or 1.
� Multinomial: In multinomial Logistic regression, there
can be 3 or more possible unordered types of the
dependent variable, such as "cat", "dogs", or "sheep“
� Ordinal: In ordinal Logistic regression, there can be 3 or
more possible ordered types of dependent variables, such
as "low", "Medium", or "High".
23
SUPPORT VECTOR MACHINE ALGORITHM
� SVM is Supervised ML algorithms, which is used for
Classification as well as Regression problems.
�
� The goal of the SVM algorithm is to create the best line
or decision boundary that can segregate n-dimensional
space into classes. This best decision boundary is called
a hyperplane.
� SVM chooses the extreme points/vectors that help in
creating the hyperplane.
� These extreme cases are called as support vectors, and
hence algorithm is termed as Support Vector Machine.
24
25
Consider the below diagram in which there are two different
categories that are classified using a decision boundary or
hyperplane:
26
SVM algorithm can be used for Face detection,
image classification, text categorization, etc.
TYPES OF SVM
� SVM can be of two types:
� Linear SVM: Linear SVM is used for linearly
separable data, which means if a dataset can be
classified into two classes by using a single straight
line, then such data is termed as linearly separable
data, and classifier is used called as Linear SVM
classifier.
� Non-linear SVM: Non-Linear SVM is used for non-
linearly separated data, which means if a dataset
cannot be classified by using a straight line, then such
data is termed as non-linear data and classifier used is
called as Non-linear SVM classifier.
27
HYPERPLANE AND SUPPORT VECTORS IN THE
SVM ALGORITHM:
� Hyperplane: There can be multiple lines/decision
boundaries to segregate the classes in n-dimensional
space, but we need to find out the best decision
boundary that helps to classify the data points. This
best boundary is known as the hyperplane of SVM.
� The dimensions of the hyperplane depend on the
features present in the dataset, which means if there
are 2 features (as shown in image), then hyperplane
will be a straight line. And if there are 3 features, then
hyperplane will be a 2-dimension plane.
� We always create a hyperplane that has a maximum
margin, which means the maximum distance between
the data points.
28
SUPPORT VECTORS:
� The data points or vectors that are the closest to the
hyperplane and which affect the position of the
hyperplane are termed as Support Vector.
� Since these vectors support the hyperplane, hence
called a Support vector.
29
HOW DOES SVM WORKS?
� Linear SVM:
� The working of the SVM algorithm can be
understood by using an example.
� Suppose we have a dataset that has two tags
(green and blue), and the dataset has two
features x1 and x2.
30
31
We want a classifier that can classify the pair(x1,
x2) of coordinates in either green or blue.
Consider the below image:
� So as it is 2-d space so by just using a straight
line, we can easily separate these two classes.
But there can be multiple lines that can separate
these classes. Consider the below image:
32
� Hence, the SVM algorithm helps to find the best line
or decision boundary; this best boundary or region is
called as a hyperplane.
� SVM algorithm finds the closest point of the lines
from both the classes. These points are called support
vectors.
� The distance between the vectors and the hyperplane
is called as margin.
� And the goal of SVM is to maximize this margin.
� The hyperplane with maximum margin is called
the optimal hyperplane. 33
34
� Non-Linear SVM:
� If data is linearly arranged, then we can separate
it by using a straight line, but for non-linear
data, we cannot draw a single straight line.
Consider the below image:
35
� So to separate these data points, we need to add one more
dimension. For linear data, we have used two dimensions x and
y, so for non-linear data, we will add a third dimension z.
� It can be calculated as: z=x2 +y2
� By adding the third dimension, the sample space will become as
below image:
36
� So now, SVM will divide the datasets into classes
in the following way. Consider the below image:
37
� Since we are in 3-d Space, hence it is looking like a
plane parallel to the x-axis. If we convert it in 2d
space with z=1, then it will become as:
� Hence we get a circumference of radius 1 in case of
non-linear data.
38
� Python Implementation of Support Vector
Machine
� Now we will implement the SVM algorithm using
Python. Here we will use the same dataset user_data,
which we have used in Logistic regression and KNN
classification.
� Data Pre-processing step
� Till the Data pre-processing step, the code will remain
the same. Below is the code:
https://www.javatpoint.com/machine-learning-support-
vector-machine-algorithm
39
40
41
MODELING CLASS PROBABILITIES VIA LOGISTIC
REGRESSION
42

More Related Content

Similar to Introduction to Machine Learning Elective Course

Lec_XX_Support Vector Machine Algorithm.pptx
Lec_XX_Support Vector Machine Algorithm.pptxLec_XX_Support Vector Machine Algorithm.pptx
Lec_XX_Support Vector Machine Algorithm.pptxpiwig56192
 
SVM & KNN Presentation.pptx
SVM & KNN Presentation.pptxSVM & KNN Presentation.pptx
SVM & KNN Presentation.pptxMohamedMonir33
 
Introduction to Support Vector Machines
Introduction to Support Vector MachinesIntroduction to Support Vector Machines
Introduction to Support Vector MachinesSilicon Mentor
 
SVM Tutorial
SVM TutorialSVM Tutorial
SVM Tutorialbutest
 
SVM Tutorial
SVM TutorialSVM Tutorial
SVM Tutorialbutest
 
Support Vector Machine.pptx
Support Vector Machine.pptxSupport Vector Machine.pptx
Support Vector Machine.pptxHarishNayak44
 
Classification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptxClassification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptxCiceer Ghimirey
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...gerogepatton
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...ijaia
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learningAmAn Singh
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdfMariaKhan905189
 
Real-Time Stock Market Analysis using Spark Streaming
 Real-Time Stock Market Analysis using Spark Streaming Real-Time Stock Market Analysis using Spark Streaming
Real-Time Stock Market Analysis using Spark StreamingSigmoid
 
Principal component analysis and lda
Principal component analysis and ldaPrincipal component analysis and lda
Principal component analysis and ldaSuresh Pokharel
 
Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithmsArunangsu Sahu
 
Supervised Learning.pdf
Supervised Learning.pdfSupervised Learning.pdf
Supervised Learning.pdfgadissaassefa
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesVimal Gupta
 
Single to multiple kernel learning with four popular svm kernels (survey)
Single to multiple kernel learning with four popular svm kernels (survey)Single to multiple kernel learning with four popular svm kernels (survey)
Single to multiple kernel learning with four popular svm kernels (survey)eSAT Journals
 
Machine Learning Notes for beginners ,Step by step
Machine Learning Notes for beginners ,Step by stepMachine Learning Notes for beginners ,Step by step
Machine Learning Notes for beginners ,Step by stepSanjanaSaxena17
 

Similar to Introduction to Machine Learning Elective Course (20)

Lec_XX_Support Vector Machine Algorithm.pptx
Lec_XX_Support Vector Machine Algorithm.pptxLec_XX_Support Vector Machine Algorithm.pptx
Lec_XX_Support Vector Machine Algorithm.pptx
 
SVM & KNN Presentation.pptx
SVM & KNN Presentation.pptxSVM & KNN Presentation.pptx
SVM & KNN Presentation.pptx
 
Introduction to Support Vector Machines
Introduction to Support Vector MachinesIntroduction to Support Vector Machines
Introduction to Support Vector Machines
 
SVM Tutorial
SVM TutorialSVM Tutorial
SVM Tutorial
 
SVM Tutorial
SVM TutorialSVM Tutorial
SVM Tutorial
 
Support Vector Machine.pptx
Support Vector Machine.pptxSupport Vector Machine.pptx
Support Vector Machine.pptx
 
Classification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptxClassification-Support Vector Machines.pptx
Classification-Support Vector Machines.pptx
 
Stock Market Prediction Using ANN
Stock Market Prediction Using ANNStock Market Prediction Using ANN
Stock Market Prediction Using ANN
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
 
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
A BI-OBJECTIVE MODEL FOR SVM WITH AN INTERACTIVE PROCEDURE TO IDENTIFY THE BE...
 
Supervised and unsupervised learning
Supervised and unsupervised learningSupervised and unsupervised learning
Supervised and unsupervised learning
 
20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf20MEMECH Part 3- Classification.pdf
20MEMECH Part 3- Classification.pdf
 
Real-Time Stock Market Analysis using Spark Streaming
 Real-Time Stock Market Analysis using Spark Streaming Real-Time Stock Market Analysis using Spark Streaming
Real-Time Stock Market Analysis using Spark Streaming
 
MSE.pptx
MSE.pptxMSE.pptx
MSE.pptx
 
Principal component analysis and lda
Principal component analysis and ldaPrincipal component analysis and lda
Principal component analysis and lda
 
Essentials of machine learning algorithms
Essentials of machine learning algorithmsEssentials of machine learning algorithms
Essentials of machine learning algorithms
 
Supervised Learning.pdf
Supervised Learning.pdfSupervised Learning.pdf
Supervised Learning.pdf
 
A tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbiesA tour of the top 10 algorithms for machine learning newbies
A tour of the top 10 algorithms for machine learning newbies
 
Single to multiple kernel learning with four popular svm kernels (survey)
Single to multiple kernel learning with four popular svm kernels (survey)Single to multiple kernel learning with four popular svm kernels (survey)
Single to multiple kernel learning with four popular svm kernels (survey)
 
Machine Learning Notes for beginners ,Step by step
Machine Learning Notes for beginners ,Step by stepMachine Learning Notes for beginners ,Step by step
Machine Learning Notes for beginners ,Step by step
 

More from MayuraD1

SDP_May2023:student developement program
SDP_May2023:student developement programSDP_May2023:student developement program
SDP_May2023:student developement programMayuraD1
 
cyber_security_brochure details of workshop
cyber_security_brochure details of workshopcyber_security_brochure details of workshop
cyber_security_brochure details of workshopMayuraD1
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Machine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMachine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMayuraD1
 
Module1 of Introduction to Machine Learning
Module1 of Introduction to Machine LearningModule1 of Introduction to Machine Learning
Module1 of Introduction to Machine LearningMayuraD1
 
Research Methodology Module 1 useful for any course work
Research Methodology Module 1 useful for any course workResearch Methodology Module 1 useful for any course work
Research Methodology Module 1 useful for any course workMayuraD1
 
Cloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxCloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxMayuraD1
 
Introduction to Computer Forensics for all streams.
Introduction to Computer Forensics for all streams.Introduction to Computer Forensics for all streams.
Introduction to Computer Forensics for all streams.MayuraD1
 
Cloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxCloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxMayuraD1
 
Introduction about research methodology explained in simple language.
Introduction about research methodology explained in simple language.Introduction about research methodology explained in simple language.
Introduction about research methodology explained in simple language.MayuraD1
 
Cloud Computing Introduction. Engineering seventh Semester
Cloud Computing Introduction. Engineering seventh SemesterCloud Computing Introduction. Engineering seventh Semester
Cloud Computing Introduction. Engineering seventh SemesterMayuraD1
 

More from MayuraD1 (13)

SDP_May2023:student developement program
SDP_May2023:student developement programSDP_May2023:student developement program
SDP_May2023:student developement program
 
cyber_security_brochure details of workshop
cyber_security_brochure details of workshopcyber_security_brochure details of workshop
cyber_security_brochure details of workshop
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Machine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester ElectiveMachine learning Module-2, 6th Semester Elective
Machine learning Module-2, 6th Semester Elective
 
Module1 of Introduction to Machine Learning
Module1 of Introduction to Machine LearningModule1 of Introduction to Machine Learning
Module1 of Introduction to Machine Learning
 
Research Methodology Module 1 useful for any course work
Research Methodology Module 1 useful for any course workResearch Methodology Module 1 useful for any course work
Research Methodology Module 1 useful for any course work
 
Cloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxCloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptx
 
Introduction to Computer Forensics for all streams.
Introduction to Computer Forensics for all streams.Introduction to Computer Forensics for all streams.
Introduction to Computer Forensics for all streams.
 
Cloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptxCloud computing_Applications and paradigams.pptx
Cloud computing_Applications and paradigams.pptx
 
Introduction about research methodology explained in simple language.
Introduction about research methodology explained in simple language.Introduction about research methodology explained in simple language.
Introduction about research methodology explained in simple language.
 
Cloud Computing Introduction. Engineering seventh Semester
Cloud Computing Introduction. Engineering seventh SemesterCloud Computing Introduction. Engineering seventh Semester
Cloud Computing Introduction. Engineering seventh Semester
 
M2.pptx
M2.pptxM2.pptx
M2.pptx
 
M5.pptx
M5.pptxM5.pptx
M5.pptx
 

Recently uploaded

Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdfKamal Acharya
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisDr.Costas Sachpazis
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Stationsiddharthteach18
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1T.D. Shashikala
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...IJECEIAES
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfSkNahidulIslamShrabo
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentationsj9399037128
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfragupathi90
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfssuser5c9d4b1
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...Amil baba
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...archanaece3
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptjigup7320
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxMustafa Ahmed
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Studentskannan348865
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxCHAIRMAN M
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfEr.Sonali Nasikkar
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashidFaiyazSheikh
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological universityMohd Saifudeen
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksIJECEIAES
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...josephjonse
 

Recently uploaded (20)

Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas SachpazisSeismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
Seismic Hazard Assessment Software in Python by Prof. Dr. Costas Sachpazis
 
Independent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging StationIndependent Solar-Powered Electric Vehicle Charging Station
Independent Solar-Powered Electric Vehicle Charging Station
 
Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1Research Methodolgy & Intellectual Property Rights Series 1
Research Methodolgy & Intellectual Property Rights Series 1
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Working Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdfWorking Principle of Echo Sounder and Doppler Effect.pdf
Working Principle of Echo Sounder and Doppler Effect.pdf
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Adsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) pptAdsorption (mass transfer operations 2) ppt
Adsorption (mass transfer operations 2) ppt
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptxSLIDESHARE PPT-DECISION MAKING METHODS.pptx
SLIDESHARE PPT-DECISION MAKING METHODS.pptx
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
Raashid final report on Embedded Systems
Raashid final report on Embedded SystemsRaashid final report on Embedded Systems
Raashid final report on Embedded Systems
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
Seizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networksSeizure stage detection of epileptic seizure using convolutional neural networks
Seizure stage detection of epileptic seizure using convolutional neural networks
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 

Introduction to Machine Learning Elective Course

  • 1. COURSE NAME: INTRODUCTION TO MACHINE LEARNING (ELECTIVE) CREDITS: 3 ACADEMIC YEAR: 2022-23 (EVEN SEMESTER) 1
  • 3. SYLLABUS � A Tour of Machine Learning Classifiers Using Scikit- learn � Choosing a classification algorithm First steps with scikit-learn Training a perception via scikit-learn � Modeling class probabilities via logistic regression Logistic regression intuition and conditional probabilities Learning the weights of the logistic cost function Training a logistic regression model with scikit-learn Tackling over fitting via regularization. � 3
  • 4. SYLLABUS � Maximum margin classification with support vector machines Maximum margin intuition Dealing with the nonlinearly separable case using slack variables Alternative implementations in scikit-learn � Solving nonlinear problems using a kernel SVM Using the kernel trick to find separating hyper planes in higher dimensional space � Decision tree learning Maximizing information gain – getting the most bang for the buck Building a decision tree Combining weak to strong learners via random forests � Self Learning Exercise: K-nearest neighbors – a lazy learning algorithm 4
  • 5. A TOUR OF MACHINE LEARNING CLASSIFIERS USING SCIKIT-LEARN � There are popular and powerful ML algorithms that are commonly used in academia as well as in industry. � While learning about the differences between several supervised learning algorithms for classification, we will also develop an intuitive appreciation of their individual strengths and weaknesses. � The scikit-learn library, which offers a user- friendly interface for using those algorithms efficiently and productively. 5
  • 6. � Robust and popular algorithms for classification, such as ⚫ logistic regression, ⚫ support vector machines, and ⚫ decision trees � Examples and explanations using the scikit-learn machine learning library, which provides a wide variety of machine learning algorithms via a user-friendly Python API � Discussions about the strengths and weaknesses of classifiers with linear and nonlinear decision boundaries 6
  • 7. CHOOSING A CLASSIFICATION ALGORITHM � To restate the no free lunch theorem by David H. Wolpert, no single classifier works best across all possible scenarios. � In practice, it is always recommended that you compare the performance of at least a handful of different learning algorithms to select the best model for the particular problem; � these may differ in the number of features or examples, the amount of noise in a dataset, and whether the classes are linearly separable or not. 7
  • 8. � The performance of a classifier—computational performance as well as predictive power— depends heavily on the underlying data that is available for learning � The five main steps that are involved in training a supervised machine learning algorithm 1. Selecting features and collecting labeled training examples. 2. Choosing a performance metric. 3. Choosing a classifier and optimization algorithm. 4. Evaluating the performance of the model. 5. Tuning the algorithm. 8
  • 9. FIRST STEPS WITH SCIKIT-LEARN – TRAINING A PERCEPTRON � In Module 2, Training Simple Machine Learning Algorithms for Classification, the perceptron rule and Adaline, which is implemented in Python and NumPy. � Now consider the scikit-learn API, which, combines a user-friendly and consistent interface with a highly optimized implementation of several classification algorithms. � The scikit-learn library offers not only a large variety of learning algorithms, but also many convenient functions to preprocess data and to fine-tune and evaluate our models. 9
  • 10. � To get started with the scikit-learn library, we will train a perceptron model similar to the one that we implemented in Module 2. � For simplicity, we will use the already familiar Iris dataset . � we will only use two features from the Iris dataset for visualization purposes. � We will assign the petal length and petal width of the 150 flower examples to the feature matrix, X, and the corresponding class labels of the flower species to the vector array, y: 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. LOGISTIC REGRESSION IN MACHINE LEARNING � Supervised Learning technique used for predicting the categorical dependent variable using a given set of independent variables. � it gives the probabilistic values which lie between 0 and 1. � Linear Regression is used for solving Regression problems, whereas Logistic regression is used for solving the classification problems. 19
  • 20. � Logistic Regression can be used to classify the observations using different types of data and can easily determine the most effective variables used for the classification. The below image is showing the logistic function: 20
  • 21. LOGISTIC FUNCTION (SIGMOID FUNCTION): � The sigmoid function is a mathematical function used to map the predicted values to probabilities. � It maps any real value into another value within a range of 0 and 1. � The value of the logistic regression must be between 0 and 1, so it forms a curve like the "S" form. � The S-form curve is called the Sigmoid function or the logistic function. � In logistic regression, we use the concept of the threshold value, which defines the probability of either 0 or 1. 21
  • 23. � Type of Logistic Regression: � On the basis of the categories, Logistic Regression can be classified into three types: � Binomial: In binomial Logistic regression, there can be, Pass or Fail, etc. only two possible types of the dependent variables, such as 0 or 1. � Multinomial: In multinomial Logistic regression, there can be 3 or more possible unordered types of the dependent variable, such as "cat", "dogs", or "sheep“ � Ordinal: In ordinal Logistic regression, there can be 3 or more possible ordered types of dependent variables, such as "low", "Medium", or "High". 23
  • 24. SUPPORT VECTOR MACHINE ALGORITHM � SVM is Supervised ML algorithms, which is used for Classification as well as Regression problems. � � The goal of the SVM algorithm is to create the best line or decision boundary that can segregate n-dimensional space into classes. This best decision boundary is called a hyperplane. � SVM chooses the extreme points/vectors that help in creating the hyperplane. � These extreme cases are called as support vectors, and hence algorithm is termed as Support Vector Machine. 24
  • 25. 25 Consider the below diagram in which there are two different categories that are classified using a decision boundary or hyperplane:
  • 26. 26 SVM algorithm can be used for Face detection, image classification, text categorization, etc.
  • 27. TYPES OF SVM � SVM can be of two types: � Linear SVM: Linear SVM is used for linearly separable data, which means if a dataset can be classified into two classes by using a single straight line, then such data is termed as linearly separable data, and classifier is used called as Linear SVM classifier. � Non-linear SVM: Non-Linear SVM is used for non- linearly separated data, which means if a dataset cannot be classified by using a straight line, then such data is termed as non-linear data and classifier used is called as Non-linear SVM classifier. 27
  • 28. HYPERPLANE AND SUPPORT VECTORS IN THE SVM ALGORITHM: � Hyperplane: There can be multiple lines/decision boundaries to segregate the classes in n-dimensional space, but we need to find out the best decision boundary that helps to classify the data points. This best boundary is known as the hyperplane of SVM. � The dimensions of the hyperplane depend on the features present in the dataset, which means if there are 2 features (as shown in image), then hyperplane will be a straight line. And if there are 3 features, then hyperplane will be a 2-dimension plane. � We always create a hyperplane that has a maximum margin, which means the maximum distance between the data points. 28
  • 29. SUPPORT VECTORS: � The data points or vectors that are the closest to the hyperplane and which affect the position of the hyperplane are termed as Support Vector. � Since these vectors support the hyperplane, hence called a Support vector. 29
  • 30. HOW DOES SVM WORKS? � Linear SVM: � The working of the SVM algorithm can be understood by using an example. � Suppose we have a dataset that has two tags (green and blue), and the dataset has two features x1 and x2. 30
  • 31. 31 We want a classifier that can classify the pair(x1, x2) of coordinates in either green or blue. Consider the below image:
  • 32. � So as it is 2-d space so by just using a straight line, we can easily separate these two classes. But there can be multiple lines that can separate these classes. Consider the below image: 32
  • 33. � Hence, the SVM algorithm helps to find the best line or decision boundary; this best boundary or region is called as a hyperplane. � SVM algorithm finds the closest point of the lines from both the classes. These points are called support vectors. � The distance between the vectors and the hyperplane is called as margin. � And the goal of SVM is to maximize this margin. � The hyperplane with maximum margin is called the optimal hyperplane. 33
  • 34. 34
  • 35. � Non-Linear SVM: � If data is linearly arranged, then we can separate it by using a straight line, but for non-linear data, we cannot draw a single straight line. Consider the below image: 35
  • 36. � So to separate these data points, we need to add one more dimension. For linear data, we have used two dimensions x and y, so for non-linear data, we will add a third dimension z. � It can be calculated as: z=x2 +y2 � By adding the third dimension, the sample space will become as below image: 36
  • 37. � So now, SVM will divide the datasets into classes in the following way. Consider the below image: 37
  • 38. � Since we are in 3-d Space, hence it is looking like a plane parallel to the x-axis. If we convert it in 2d space with z=1, then it will become as: � Hence we get a circumference of radius 1 in case of non-linear data. 38
  • 39. � Python Implementation of Support Vector Machine � Now we will implement the SVM algorithm using Python. Here we will use the same dataset user_data, which we have used in Logistic regression and KNN classification. � Data Pre-processing step � Till the Data pre-processing step, the code will remain the same. Below is the code: https://www.javatpoint.com/machine-learning-support- vector-machine-algorithm 39
  • 40. 40
  • 41. 41
  • 42. MODELING CLASS PROBABILITIES VIA LOGISTIC REGRESSION 42