3
CLASSIFICATION MODEL
• Following are the Machine Learning Classification models:
1. Logistic Regression
2. K-Nearest Neighbors (K-NN)
3. Support Vector Machine
4. Kernel SVM
5. Naïve Bayes
6. Decision Tree Classification
7. Random Forest Classification
4. Classification.pdf
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
1. Logistic Regression
Logistic Regression IMP Code
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression(random_state = 0)
classifier.fit(X_train, y_train)
1. Logistic Regression
# Visualising the Training set results
from matplotlib.colors import ListedColormap
X_set, y_set = X_train, y_train
X1, X2 = np.meshgrid(np.arange(start = X_set[:, 0].min() - 1, stop = X_set[:, 0].max() + 1, step = 0.01),
np.arange(start = X_set[:, 1].min() - 1, stop = X_set[:, 1].max() + 1, step = 0.01))
plt.contourf(X1, X2, classifier.predict(np.array([X1.ravel(), X2.ravel()]).T).reshape(X1.shape),
alpha = 0.75, cmap = ListedColormap(('red', 'green')))
plt.xlim(X1.min(), X1.max())
plt.ylim(X2.min(), X2.max())
for i, j in enumerate(np.unique(y_set)):
plt.scatter(X_set[y_set == j, 0], X_set[y_set == j, 1],
c = ListedColormap(('red', 'green'))(i), label = j)
plt.title('Logistic Regression (Training set)')
plt.xlabel('Age')
plt.ylabel('Estimated Salary')
plt.legend()
plt.show()
2. K-Nearest Neighbor (KNN)
KNN Algorithm
4. Classification.pdf
Euclidean Distance
4. Classification.pdf
4. Classification.pdf
4. Classification.pdf
4. Classification.pdf
KNN IMP Code
from sklearn.neighbors import KNeighborsClassifier
classifier = KNeighborsClassifier(n_neighbors = 5, metric = 'minkowski', p = 2)
classifier.fit(X_train, y_train)
Support Vector Machine (SVM)
3. Support Vector Machine (SVM)
3. Support Vector Machine (SVM)
3. Support Vector Machine (SVM)
What is so special about SVM?
What is so special about SVM?
What is so special about SVM?
SVM IMP Code & Confusion Matrix
from sklearn.svm import SVC
classifier = SVC(kernel = 'linear', random_state = 0)
classifier.fit(X_train, y_train)
array([[66, 2],
[ 8, 24]], dtype=int64)
Output of SVM
4. Kernel SVM
4. Kernel SVM
4. Classification.pdf
Mapping to Higher Dimension
Mapping to Higher Dimension
Mapping to Higher Dimension
Mapping to Higher Dimension
Mapping to Higher Dimension
SVM Kernel Functions
What is the Kernel Trick?
The Kernel trick is a very interesting and powerful tool.
It is powerful because it provides a bridge from linearity to non-linearity to any
algorithm that can be expressed solely on terms of dot products between two
vectors. It comes from the fact that, if we first map our input data into a higher-
dimensional space, a linear algorithm operating in this space will behave non-
linearly in the original input space. And, we do not exactly need the exact data
points, but only their inner products to compute our decision boundary.
What it implies is that if we want to transform our existing data into a higher
dimensional data, which in many cases help us classify better, we need not
compute the exact transformation of our data, we just need the inner product of
our data in that higher dimensional space.
What is the Kernel Trick?
What is the Kernel Trick?
Mapping from 1D to 2D
Regularization
The Gaussian RBF Kernel
The Gaussian RBF Kernel
The Gaussian RBF Kernel
The Gaussian RBF Kernel
The Gaussian RBF Kernel
The Gaussian RBF Kernel
Types of Kernel Functions
Types of Kernel Functions in 3D
IMP Code for Kernel SVM
from sklearn.svm import SVC
classifier = SVC(kernel = 'rbf', random_state = 0)
classifier.fit(X_train, y_train)
array([[64, 4],
[ 3, 29]], dtype=int64)
93 correctly classified and 7 incorrectly classified.
Projection from 3D to 2D using Kernel SVM
Projection from 3D to 2D using Kernel SVM
Output of Kernel SVM
4. Naïve Bayes Classification
Find the Defective Spanner
Bayes Theorem
Bayes Theorem
Bayes Theorem
Bayes Theorem
Bayes Theorem is Intuitive
Bayes Theorem is Intuitive
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
4. Classification.pdf
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
Naïve Bayes Theorem
IMP code for Naïve Bayes
from sklearn.naive_bayes import GaussianNB
classifier = GaussianNB()
classifier.fit(X_train, y_train)
Confusion Matrix
array([[65, 3],
[ 7, 25]], dtype=int64)
IMP code for Naïve Bayes
5. Decision Tree Classification
IMP code for DTC
from sklearn.tree import DecisionTreeClassifier
classifier = DecisionTreeClassifier(criterion = 'entropy', random_state = 0)
classifier.fit(X_train, y_train)
• Confusion Matrix
array([[62, 6],
[ 3, 29]], dtype=int64)
91 correctly classified and 9 incorrectly classified
Output of DTC
6. Random Forest Classification : Based on Ensemble Learning
IMP Code for Random Forest Classification
from sklearn.ensemble import RandomForestClassifier
classifier = RandomForestClassifier(n_estimators = 10, criterion = 'entropy', random_state = 0)
classifier.fit(X_train, y_train)
Confusion Matrix
array([[63, 5],
[ 4, 28]], dtype=int64)
91 correctly classified and 9 incorrectly classified
Out of RFC
Classification Model Pros and Cons
Evaluating Classification
Models Performance
1. False Positives and False Negatives
2. Confusion Matrix
3. Accuracy Paradox
4. CAP Curve and its Analysis
1. False Positives & False Negatives
False Positives & False Negatives
There are two errors that often rear their head when you are learning about
hypothesis testing — false positives and false negatives, technically referred to
as type I error and type II error respectively.
A false positive (type I error) — when you reject a true null hypothesis
A false negative (type II error) — when you accept a false null hypothesis?
A False Positive Rate is an accuracy metric that can be measured on a
subset of machine learning models.
False Positives & False Negatives
False Positives & False Negatives
In binary prediction/classification terminology, there are four conditions
for any given outcome:
•True Positive: is the correct identification of anomalous data as such,
e.g., classifying as “abnormal” data which is in fact abnormal.
•True Negative: is the correct identification of data as not being
anomalous, i.e. classifying as “normal” data which is in fact normal.
•False Positive: is the incorrect identification of anomalous data as such,
i.e. classifying as “abnormal” data which is in fact normal.
•False Negative: is the incorrect identification of data as not being
anomalous, i.e. classifying as “normal” data which is in fact abnormal.
False Positives & False Negatives
False Positives & False Negatives
• A true positive is an outcome where the model correctly predicts the positive class. Similarly,
a true negative is an outcome where the model correctly predicts the negative class.
• A false positive is an outcome where the model incorrectly predicts the positive class. And a false
negative is an outcome where the model incorrectly predicts the negative class.
False Positives & False Negatives
False Positives & False Negatives
False Positives & False Negatives
False Positives & False Negatives
False Positives & False Negatives
False Positives & False Negatives
False Positives & False Negatives
A false positive is an
outcome where the
model incorrectly
predicts
the positive class.
A false negative is
an outcome where
the model incorrectly
predicts
the negative class.
2. Confusion Matrix
Confusion Matrix
Confusion Matrix
3. Accuracy Paradox
Accuracy Paradox
Accuracy Paradox
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
CAP Curve
CAP Curve
Cumulative Accuracy Profile (CAP)
Cumulative Accuracy Profile (CAP)
4. Classification.pdf

More Related Content

PDF
3. Regression.pdf
PDF
6. Association Rule.pdf
PDF
5. Types of Clustering Algorithms in ML.pdf
PDF
8. Deep Learning.pdf
PDF
1. Demystifying ML.pdf
PDF
2. Data Preprocessing.pdf
PDF
7. Reinforcement Learning.pdf
PPTX
Support Vector Machine
3. Regression.pdf
6. Association Rule.pdf
5. Types of Clustering Algorithms in ML.pdf
8. Deep Learning.pdf
1. Demystifying ML.pdf
2. Data Preprocessing.pdf
7. Reinforcement Learning.pdf
Support Vector Machine

What's hot (20)

PPTX
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
PPTX
Support vector machine
PDF
Recurrent neural networks rnn
PPTX
Ensemble Learning and Random Forests
PPTX
Support vector machine
PPTX
Support vector machine-SVM's
PDF
Supervised Machine Learning With Types And Techniques
PPTX
K-means clustering algorithm
PPTX
Decision tree
PPTX
Machine Learning lecture6(regularization)
PPTX
Support Vector Machine ppt presentation
PDF
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
DOC
SVM Tutorial
PDF
Support Vector Machines (SVM)
 
PDF
Linear Regression vs Logistic Regression | Edureka
PDF
Deep Feed Forward Neural Networks and Regularization
PPTX
support vector machine 1.pptx
PDF
Support Vector Machines ( SVM )
PPTX
Support Vector Machines
PPTX
boosting algorithm
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Support vector machine
Recurrent neural networks rnn
Ensemble Learning and Random Forests
Support vector machine
Support vector machine-SVM's
Supervised Machine Learning With Types And Techniques
K-means clustering algorithm
Decision tree
Machine Learning lecture6(regularization)
Support Vector Machine ppt presentation
Recurrent Neural Networks (RNN) | RNN LSTM | Deep Learning Tutorial | Tensorf...
SVM Tutorial
Support Vector Machines (SVM)
 
Linear Regression vs Logistic Regression | Edureka
Deep Feed Forward Neural Networks and Regularization
support vector machine 1.pptx
Support Vector Machines ( SVM )
Support Vector Machines
boosting algorithm
Ad

Similar to 4. Classification.pdf (20)

PPT
Supervised and unsupervised learning
PDF
IRJET- Performance Evaluation of Various Classification Algorithms
PDF
IRJET- Performance Evaluation of Various Classification Algorithms
PPT
Introduction
PPTX
Supervised learning
PDF
Machine Learning with Python- Machine Learning Algorithms.pdf
PPTX
Machine learning
DOCX
Performance of the classification algorithm
PDF
20MEMECH Part 3- Classification.pdf
PDF
IRJET- Supervised Learning Classification Algorithms Comparison
PDF
IRJET- Supervised Learning Classification Algorithms Comparison
PDF
lec21.pdf
PPT
Download It
PPTX
Naïve Bayes Classifier Algorithm.pptx
PPTX
Machine Learning in the Financial Industry
PPTX
Machine Learning Unit 2 Semester 3 MSc IT Part 2 Mumbai University
PPT
ai4.ppt
PPTX
SVM,BAYES,DECISION TREE MACHINE LEARNING .pptx
PPT
Introduction
PPTX
SVM - Functional Verification
Supervised and unsupervised learning
IRJET- Performance Evaluation of Various Classification Algorithms
IRJET- Performance Evaluation of Various Classification Algorithms
Introduction
Supervised learning
Machine Learning with Python- Machine Learning Algorithms.pdf
Machine learning
Performance of the classification algorithm
20MEMECH Part 3- Classification.pdf
IRJET- Supervised Learning Classification Algorithms Comparison
IRJET- Supervised Learning Classification Algorithms Comparison
lec21.pdf
Download It
Naïve Bayes Classifier Algorithm.pptx
Machine Learning in the Financial Industry
Machine Learning Unit 2 Semester 3 MSc IT Part 2 Mumbai University
ai4.ppt
SVM,BAYES,DECISION TREE MACHINE LEARNING .pptx
Introduction
SVM - Functional Verification
Ad

More from Jyoti Yadav (12)

PDF
Part 4: Understanding the working of Smart Contracts
PDF
Part 3 Introduction to Cryptocurrency.pdf
PDF
Part 2 Blockchain Programming Using Python.pdf
PDF
Part 1: Introduction to Blockchain Fundamentals
PDF
Natural Language Processing Algorithm...
PDF
6. Web Publishing
PDF
5. Web Technology CSS Advanced
PDF
4. Web Technology CSS Basics-1
PDF
3. Web Technology Advanced HTML
PDF
2b. Web Technology HTML Basics-2
PDF
2a web technology html basics 1
PDF
1. web technology basics
Part 4: Understanding the working of Smart Contracts
Part 3 Introduction to Cryptocurrency.pdf
Part 2 Blockchain Programming Using Python.pdf
Part 1: Introduction to Blockchain Fundamentals
Natural Language Processing Algorithm...
6. Web Publishing
5. Web Technology CSS Advanced
4. Web Technology CSS Basics-1
3. Web Technology Advanced HTML
2b. Web Technology HTML Basics-2
2a web technology html basics 1
1. web technology basics

Recently uploaded (20)

PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Architecture types and enterprise applications.pdf
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Getting Started with Data Integration: FME Form 101
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
DOCX
search engine optimization ppt fir known well about this
PPTX
Tartificialntelligence_presentation.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
A comparative study of natural language inference in Swahili using monolingua...
Module 1.ppt Iot fundamentals and Architecture
Architecture types and enterprise applications.pdf
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Hindi spoken digit analysis for native and non-native speakers
Getting Started with Data Integration: FME Form 101
Taming the Chaos: How to Turn Unstructured Data into Decisions
search engine optimization ppt fir known well about this
Tartificialntelligence_presentation.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Benefits of Physical activity for teenagers.pptx
1 - Historical Antecedents, Social Consideration.pdf
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
O2C Customer Invoices to Receipt V15A.pptx
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
DP Operators-handbook-extract for the Mautical Institute
Univ-Connecticut-ChatGPT-Presentaion.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Web Crawler for Trend Tracking Gen Z Insights.pptx
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
A comparative study of natural language inference in Swahili using monolingua...

4. Classification.pdf