Boat Type Prediction

In this post, we will investigate one such Image Classification issue in particular Boat Type Recognition, which is a difficult issue in light of the fact that there are large types of Boat around the globe. As we are probably aware AI is tied in with gaining from past information, we need gigantic dataset of boat pictures to perform continuous boat type acknowledgment. Without stressing a lot on constant boat acknowledgment, we will figure out how to play out a basic Image Classification using various Machine Learning Algorithms and Image Feature Extraction techniques.

Harshit Gupta
5 min readOct 13, 2019

How Computer sees an Image

Consider the above image, a normal human can easily tell that, there is a Lion in the image. But, can computers really see the Lion? The answer is no, computers see a matrix of numbers ( between 0 to 255 ). Broadly, we can classify images as grayscale images or color images. First of all, I will discuss grayscale images then color. The above image is a grayscale image that means each pixel represents the brightness of a pixel. Let me first show you what computers see in the case of the below image.

This picture will be seen by the computer as a 2D matrix with each pixel is a number between 0–255.Something like this

Since every color on earth is just a combination of three colors that are Red Green Blue so a colored Image is a 3 2D matrix with each matrix showing the value of each color ranging from 0–255.

Now let’s switch the topic and focus on our goal.

Dataset Description

The Dataset consists of images of boats classified into nine categories :

  1. Buoy
  2. Cruise Ship
  3. Ferry Boat
  4. Freight Boat
  5. Gondola
  6. Inflatable Boat
  7. Kayak
  8. Paper Boat
  9. Sail Boat

These images first resized to 50x50 image, greyscaled and finally appended into an array.

Feature Extraction

Features are the data or list of numbers that are extracted from a picture. These are numbers (whole numbers, float, binary). There is a more extensive scope of Feature extraction calculations in Computer Vision.

When choosing the highlights that could evaluate these boats, we could consider Color and Shape as the essential ones.

Global Feature Descriptor

These are the feature descriptors that quantifies an image globally. These don’t have the concept of interest points and thus, takes in the entire image for processing. Some of the commonly used global feature descriptors are

Below Code, Snapshots Specifies how to perform those tasks.

  1. Hu Moments

2. Color Histogram

3. Haralick Texture

Now lets clear the abbreviations we are going to use in this project.

‘NN’-Using Pixels values directly as input to models.

‘HM’-Using Feature values generated by Humoments as an input to models

‘HA’-Using Feature values generated by Haralick as an input to models

‘CH’-Using Feature values generated by Color Histogram as an input to models

Training Models(Classifiers)

After extracting features and labels from our training dataset, it’s time to train our system. We will use sci-kit learn for this purpose.

Furthermore, we will use train_test_split() function provided by scikit-learn to split our training dataset into train_data and test_data. In this way, we train the models with the train_data and test the trained model with the unseen test_data.

Importing Libraries

Decision Tree Classifier

A Decision tree is a decision making tool that uses a tree-like model of decisions and their potential results, including probabilty of possible outcomes. It is one approach to show a calculation that just contains contingent control statements.

Here we applied a grid search to choose best hyperparameter.

Now plot the accuracy

In this Model Shape feature(haralick) Extraction technique gave the best results.

Random Forest Classifier

Random forests or random decision forests are an ensemble learning method for classification, regression and other tasks that operates by constructing a multitude of decision trees at training time and outputting the class that is the mode of the classes (classification) or mean prediction (regression) of the individual trees. Random decision forests correct for decision trees’ habit of overfitting to their training set.

In this Model both color(color histogram) and Shape feature(haralick) Extraction technique gave the best results.

Logistic Regression

In this Model both color(color histogram) and Shape feature(haralick) Extraction technique gave the best results.

Neural Networks

Applied one-hot encoding on our Data since it can't take any Strings.

In this Model both color(color histogram) and Shape feature(haralick) Extraction technique gave the best results.

Let's Summarize all the networks we have done so far in Box plot

Summary

As we can see that Random Forest Outperform every other algorithm in the line.

Improving Classifier Accuracy

In order to improve the Accuracy Further we can use various techniques:

  1. Gather more data at least 1000 images per class.
  2. Instead of using Global Feature Extraction Techniques, we can use local.
  3. Using CNN can provide extraordinary results.
  4. In CNN various neural network models can be used like Alex Net.

--

--