The Data Scientist

Real World Machine Learning Examples: Image classification

Wanna become a data scientist within 3 months, and get a job? Then you need to check this out !

There have been significant advancements in Artificial Intelligence (AI) research. The evolution of AI has led to machine learning applications becoming some of the most widespread technologies right now. Considering how much machine learning has impacted our lives, it’ll continue to be at the forefront. Forecasts predict the global machine learning market to grow from \$21.17b in 2022 to \$209.91b by 2029. Read on to learn about a few machine learning examples from the growing market of machine learning technologies.

Today we see machine learning examples everywhere. From daily life tasks to professional and industrial procedures, machine learning has a major impact on businesses. Our dependency on machines in routine tasks has fuelled data creation in all major industries across the globe. These vast datasets include unstructured data in the form of texts, images, videos, and audio. These industries leverage machine learning technology to simplify working with large amounts of unstructured data.

Machine Learning in Classification Problems

Let’s consider machine learning classification that separates a given dataset into two or more categories. Classification techniques employ supervised machine learning algorithms that use labeled training data for model training.

Image classification is the most popular machine learning classification problems. It involves the categorisation and labelling of image pixels using particular machine learning models. Let’s go step-by-step through the code of a practical image classification example to understand its workings.

Image Classification Tutorial

Here is a simple tutorial of binary image classification using Convolutional Neural Network (CNN). A convolutional neural network (CNN) is a deep learning modelling technique that is analogous to the working of neurons in the human brain. This technique is mostly applied to image analysis. CNN model takes an input image and assigns weights to image objects that can be differentiated from one another. The image objects act as neurons that are stimulated using mathematical functions called convolutions.

This tutorial has been created in Google Colab using Kaggle’s Cats & Dogs images dataset.

The dataset includes images of cats and dogs divided into three directories:

• Training set including training images.
• Test set including test images.
• Single predictions for single image predictions.

The following python code takes you through building a machine learning model using various cats and dogs images. The model is then plotted to graphically demonstrate training accuracy and loss. After model training, we’ll evaluate its accuracy through test images.

Step 1: Setting up dataset from Kaggle to Colab

We used this guide for loading the dataset from Kaggle to Colab.

Step2: Importing Libraries

In this section, we load our training and test images in batches and resize them all to fit the same size. This is also where we define the type of classification (binary in our case) and the color mode of the images (we are using RGB images).

Step 4: Data visualizing

The following code fetched one image each of both cat and dog from their training sets for visualizing the training data.

Step 5: Building a CNN model

This step involves building a CNN model by adding layers and defining the functions to be performed on those layers.

The following code shows a display of the layers we created in our model. The result of the convolution functions applied to them are also displayed in the form of their output shape.

Step 6: Fitting the model

The model training was done using GPU for faster results. For this tutorial we limited the epochs to 20, which took around 15-17 minutes to execute.

Step 7: Plotting the model

We graphically visualize the accuracy and loss metrics for our training and test sets.

Step 8: Prediction testing on unknown single prediction set image

The CNN model can be trained to comprehend complex details of an image. The model correctly predicted the test image as that of a dog. Using this model, we were able to achieve 87% accuracy on the test dataset in 20 epochs.

Real-World Machine Learning Examples using Classification

Classification with machine learning involves the use of deep learning algorithms to understand sophisticated details of given data. Deep learning involves using many hidden layers in a model and has significantly improved the performance of classification tasks.

Let us explore a few industries where classification algorithms have opened doors for technological accomplishments:

HealthCare

Machine learning has revolutionized the healthcare sector with its disease prognostics and diagnostics applications. Image classification is the most popular machine learning technique that helps healthcare professionals timely diagnose patients.

Some prominent image classification examples in healthcare include

• Cancer detection through the classification of cancerous and noncancerous scans.
• Identifying disease progression to prioritize critically ill patients.
• Potential heart failure prediction using patient’s cardiovascular history

Social Media

In today’s age, social media is a huge contributor to data generation across the globe. Machine learning solutions have allowed for a more personalized user experience in apps. The social media industry uses machine learning classification in the following ways:

• Tagging on social media platforms is done by assigning labels to images.
• Categorizing ‘People You May Know’ based on friend list, profile visits, workplace, etc.
• Image sentimental analysis to classify positive and negative emotions based on image and suggesting appropriate emoticons.

E-commerce

E-commerce industries use machine learning solutions for better customer needs satisfaction and inventory management. The rapidly changing customer demands can only be met with advanced machine learning techniques.

E-commerce industries commonly use classification models for:

• Providing product recommendations based on customers’ previous purchases, browsing patterns, cart history, etc.
• Categorising customers based on their browsing and buying patterns.
• Product categorisation in catalog-based websites that combine products from different retailers.

Finance

Industries like banking and finance deal with critical data and transactions that cannot be compromised. Machine learning has become very popular in these sectors for its applications in:

• Using historical transactions for predicting potential threats like credit card fraud and money laundering.
• Determining creditworthiness of a customer based on transactional history.
• Identifying trading strategies using analysis of economic variables.

Cybersecurity

The cyberspace witnesses large volumes of data movement. The security of this space is crucial to preserving data integrity and stopping polluted data from entering computer systems. These security practices are put in place using machine learning algorithms for:

• Malware categorisation by using existing malware to predict and prevent potential malware.
• Spam filtering by classifying email as spam and non-spam using spam features.

What does the future hold for machine learning?

To avoid explicitly programming processes for growing amounts of data globally, we will continue to depend on machine learning algorithms. The machine learning examples we listed in this article touch on just a few industries affected by machine learning. The list of machine learning breakthroughs will continue to evolve and will be challenging to summarise in a single article.

Machine learning is advancing by leaps and bounds, making room for even more possibilities for modernising our lifestyles. The coming years will witness how far this self-improving technology takes us.

If machine learning and AI intrigue you and you want to learn more, check out our collection of resources on the topic. Also, make sure to check out our courses and our special program for aspiring data scientists Beyond Machine.

Wanna become a data scientist within 3 months, and get a job? Then you need to check this out !