0% found this document useful (0 votes)
2 views

Image Classification Using SVM

The document discusses the use of Support Vector Machine (SVM) for image classification within the field of machine learning. It outlines the tools and libraries used, key parameters of SVM, and the process of model construction, training, and evaluation. Additionally, it highlights the advantages and disadvantages of SVM, as well as how computers interpret images for classification tasks.

Uploaded by

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

Image Classification Using SVM

The document discusses the use of Support Vector Machine (SVM) for image classification within the field of machine learning. It outlines the tools and libraries used, key parameters of SVM, and the process of model construction, training, and evaluation. Additionally, it highlights the advantages and disadvantages of SVM, as well as how computers interpret images for classification tasks.

Uploaded by

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

Image Classification Using

Machine Learning-Support Vector


Machine(SVM)
INTRODUCTION

Machine learning is an application of artificial intelligence, which allows the computer to operate in a self-learning
mode, without being explicitly programmed. It is a very interesting and complex topic, which could drive the future of
technology.

There are copious applications of Machine learning, out of which Image Classification is one. To classify images, here
we are using SVM. Scikit-learn is a free software machine learning library for the Python programming language and
Support vector machine(SVM) is subsumed under Scikit-learn.
TOOLS USED

→ Python syntax

→ Pandas library for data frame

→ Support vector Machine(svm) from sklearn (a.k.a scikit-learn) library

→ GridSearchCV

→ skimage library for reading the image

→ matplotlib for visualization purpose


Support Vector Machine(SVM)

“Support Vector Machine” (SVM) is a supervised machine learning algorithm that can be used for both classification

or regression challenges. However, it is mostly used in classification problems. In this SVM algorithm, we plot each

data item as a point in n-dimensional space (where n is the number of features you have) with the value of each

feature being the value of a particular coordinate. Then, we perform classification by finding the hyper-plane that

differentiates the two classes very well.


Support Vector Machine(SVM)

Some of the key parameters in SVM are:

→ Gamma : defines how far the influence of single training examples reaches values leads to biased results.

→ C : Controls the cost of miscalculations

Small C — makes the cost of misclassification LOW

Large C — makes the cost of misclassification HIGH

→ Kernel : SVM algorithms use a set of mathematical functions that are defined as the kernel.

Types of Kernels are: Linear, RBF(Radial Basis Function), Polynomial Kernel


Support Vector Machine(SVM)

Some of the key parameters in SVM are:

→ Gamma : defines how far the influence of single training examples reaches values leads to biased results.

→ C : Controls the cost of miscalculations

Small C — makes the cost of misclassification LOW

Large C — makes the cost of misclassification HIGH

→ Kernel : SVM algorithms use a set of mathematical functions that are defined as the kernel.

Types of Kernels are: Linear, RBF(Radial Basis Function), Polynomial Kernel


Support Vector Machine(SVM)

Support vector machines (SVMs) are a set of supervised learning methods used for classification, regression and
outliers detection.
The advantages of support vector machines are:
 Effective in high dimensional spaces.
 Still effective in cases where number of dimensions is greater than the number of samples.
 Uses a subset of training points in the decision function (called support vectors), so it is also memory efficient.
 Versatile: different Kernel functions can be specified for the decision function. Common kernels are provided, but it
is also possible to specify custom kernels.
The disadvantages of support vector machines include:
• If the number of features is much greater than the number of samples, avoid over-fitting in choosing Kernel
functions and regularization term is crucial.
• SVMs do not directly provide probability estimates, these are calculated using an expensive five-fold cross-
validation (see Scores and probabilities, below).
• The support vector machines in scikit-learn support both dense (numpy.ndarray and convertible to that by
numpy.asarray) and sparse (any scipy.sparse) sample vectors as input. However, to use an SVM to make predictions
for sparse data, it must have been fit on such data. For optimal performance, use C-ordered numpy.ndarray
(dense) or scipy.sparse.csr_matrix (sparse) with dtype=float64.Z
Support Vector Machine(SVM)
How Does the Computer Read The Image?

The main task of image Classification is to read the input image, the computer sees the image quite differently:

The computer sees the image as an array of pixels, if the size of the image is 200 X 200, the size of the array will be
200 X 200 X 3 wherein the first 200 is the width and second 200 is height and the next 3 is RGB channel values. The
values in the array would range from 0–255 which describes the intensity of the pixel at each point.
How Does the Computer Read The Image?

The main task of image Classification is to read the input image, the computer sees the image quite differently:

GridSearchCV
It is a library function that is a member of sklearn’s model_selection package. It helps to loop through
predefined hyperparameters and fit your estimator (model) on your training set. So, in the end, you can select
the best parameters from the listed hyperparameters.
SVM

Process
It is one of the ways of machine learning where the model is trained by input data and expected output data.
To create such a model, it is necessary to go through the following phases:

1.Taking input
2. Model construction
3. Model training
4. Model testing
5.Model evaluation

Taking input: 3 Different categories of images(Cars, Ice cream cone, Cricket ball) are read and labeled as 0,1,2 in the
following way:
SVM

Since SVM receives inputs of the same size, all images need to be resized to a fixed size before inputting them to
the SVM. df is the data frame created using pandas and x and y are input and output data respectively
Model construction: In this project case, the model is Support vector machine.
The algorithm for model construction looks like this:
1. Create a support vector classifier:
→ svc=svm.SVC()
2. With the help of GridSearchCV and parameters grid, create a model:
→model=GridSearchCV(svc,parameters_grid)

Model training: The data is split into two categories: training data and testing data. Training data is used to train
the model whereas testing data is used to test the trained model.
For splitting the data into training and testing, train_test_split() from sklearn library is used.
Model is trained using training data in this way
→ model.fit(training_data,expected_output)
SVM

Model testing: Now the model is tested using testing data in this way
→ model.predict(testing_data)
The accuracy of the model can be calculated using the accuracy_score() method from sklearn.metrics
Finally, in the Model evaluation phase, the model generated can be used to evaluate new data.

You might also like