DEV Community

Cover image for Machine Learning Explained: Understanding the Different Types of Machine Learning
Barbara Morara
Barbara Morara

Posted on

Machine Learning Explained: Understanding the Different Types of Machine Learning

Introduction

Currently, our everyday lives generate a lot of data. From recommending products while online shopping and predicting which posts will be in your social media feed, through detecting fraud and medical diagnosis – all of these require algorithms that can learn from data and make decisions. Machine Learning (ML) is here for that.

Machine Learning is a branch of Artificial Intelligence (AI), which is aimed at teaching machines to learn from data, identify patterns, and make decisions with little or no human involvement. It differs from traditional software programs as they follow certain instructions, while machine learning algorithms analyze data samples, learn relationships between them, and draw conclusions.

From the perspective of a data scientist, ML is one of the key techniques to extract insights from the available data and apply it to automation.

What is Machine Learning?

Machine Learning is an algorithmic process that includes learning patterns in the historical data and applying them to predictions or tasks execution.

Traditionally, program is created according to this pattern:

Rules + Data → Output
The programmer writes a set of rules to calculate taxes depending on income.

The machine learning program works differently:

Data + Expected Outputs → Learning Algorithm → Model

The computer discovers rules by examining examples.

Instead of writing a program that will distinguish between spam email and not spam, we feed the learning algorithm thousands of examples, and the model learns to detect spam.

Why Machine Learning is Important?

Machine Learning has become a must in the world of data and advanced computing capabilities. Organizations implement ML in order to solve problems.

A few common applications of machine learning are:

1. Recommendation Systems
Recommendation systems on sites such as Netflix, YouTube, and other online stores are developed using machine learning algorithms which suggest content or products based on user activities.

2. Healthcare
Machine learning algorithms are useful for disease detection, analyzing medical images, and predicting risk for patients.

3. Finance
Banks utilize machine learning for fraud detection, credit scoring, and market analysis.

4. Transportation
Autonomous vehicles use machine learning algorithms to understand surroundings and take appropriate driving actions.

5. Marketing
Companies analyze customer behavior to design customized advertisements.

Machine Learning Types
Machine learning can be broadly classified into four major categories:

  • Supervised learning
  • Unsupervised learning
  • Semi-supervised learning
  • Reinforcement learning These types differ based on how they learn from the data and the problem they solve.

1. Supervised learning
Supervised learning is the most popular form of machine learning. In supervised learning models, learning occurs based on data where the output has been provided. The input data already contains the answer or label.

The objective is to learn the relationship between input variables and output variables in order to be able to predict future instances of data.

Example:
Suppose we wish to predict the prices of houses.

The dataset may contain:

Size of House Number of Rooms Location Price
1200 sq ft 3 Nairobi 8 million
2000 sq ft 5 Nairobi 15 million

The algorithm will learn about the relation of size and location to prices so that we may predict prices of a new house.

Types of Supervised Learning:

a) Regression
Regression involves predicting continuous numeric values.

Example:

  • Predicting house prices.
  • Sales forecasting.
  • Temperature prediction.
  • Forecasting future stock prices.

Common regression algorithms are:

  • Linear Regression
  • Decision Tree Regression
  • Random Forest Regression
  • Support Vector Regression

Example

from sklearn.linear_model import LinearRegression

model = LinearRegression()

model.fit(X_train, y_train)

prediction = model.predict(X_test)
Enter fullscreen mode Exit fullscreen mode

b) Classification

Classification predicts classes or categories.

Examples:

  • Email: Spam or Not Spam
  • Disease prediction: Positive or Negative
  • Client: Will purchase or Will not purchase

Examples of classification algorithms:

  • Logistic Regression
  • Decision Trees
  • Random Forest
  • Support Vector Machines
  • Neural Networks

Example:

A bank might use classification to check if the transaction is fraudulent.

2. Unsupervised Learning
In contrast with the supervised learning, the data used in the unsupervised learning is unlabeled. In other words, the machine learning algorithm gets data and there are no answers given to the algorithm.
The aim of the unsupervised learning is to find out natural structure in data.

Example:

A firm has client data but it does not know client clusters. Machine learning algorithm can automatically discover the clusters according to their purchasing behavior.

Types of Unsupervised Learning

a) Clustering
Clustering groups together similar data.

Examples:

  • Customer segmentation
  • Similar documents grouping
  • Communities detection in networks

Clustering algorithms:

  • K-Means Clustering
  • Hierarchical Clustering
  • DBSCAN

Example:

A supermarket could group customers into:

  • Frequent buyers
  • Occasional buyers
  • Important clients

b) Dimensionality Reduction
Dimensionality reduction reduces the number of variables while keeping important information.
Sometimes large dataset includes hundreds of features and it becomes impossible to analyze data. Therefore, it is necessary to simplify data.

Popular dimensionality reduction techniques:

  • Principal Component Analysis (PCA)
  • t-SNE

Applications of dimensionality reduction:

  • Data visualization
  • Faster model training
  • Unnecessary features removal

3. Semi-Supervised Learning
Semi-supervised learning is a combination of both supervised and unsupervised learning.

It uses:

  • Labeled data (a little bit)
  • Unlabeled data (a lot)

Labelling data can be expensive and time consuming. Semi-supervised learning is useful when the number of labeled data is limited.

For instance,

A firm needs to develop an image recognition system. Rather than labeling all million images manually, it would label some of the images and let the model learn on its own from the unlabeled images.

Applications include:

  • Image Classification
  • Speech Recognition
  • Medical data analysis

4. Reinforcement Learning
Reinforcement learning is grounded on learning from interaction with the environment.

The agent learns through:

  • Performing actions
  • Getting rewarded or penalized
  • Improving future decisions

The objective is to increase the rewards in the future.

For instance,

A robot learning

  • How to move around the room
  • Getting the rewards for moving right
  • Being punished for hitting obstacles

In the long run, it learns the optimal path

Applications of Reinforcement Learning

Gaming
AI agents use reinforcement learning to master gaming and come up with effective strategies.

Robotics
Robots learn how to perform certain operations such as walking, grasping objects, etc.

Autonomous Vehicles
Vehicles learn driving behavior based on various situations.
Machine Learning Workflow

Machine learning projects usually consist of the following steps:

1. Data Collection
Collection of the relevant data from the database, website, sensors, survey, etc.

2. Data Cleaning
Eliminating errors and missing values from the dataset.

3. Feature Selection
Selecting relevant variables that will assist in predictions.

4. Model Training
Learning of patterns in training dataset by the algorithm.

5. Model Evaluation
Evaluation of the model through accuracy, precision, recall, Mean Squared Error, etc.

6. Model Deployment
Deployment of the learned model into production

Challenges in Machine Learning

1. Poor Data
Low-quality data generates low-quality predictions.

The popular phrase in the data science industry goes as follows:

"Garbage in, garbage out."

2. Overfitting
Overfitting takes place when a machine learning model trains too closely to the training data and does not function properly with other data.

3. Bias
Bias in the data causes bias in the results generated by machine learning algorithms.

4. Computing Requirements

Large-scale machine learning models require lots of computing power.

Differences between AI and Machine Learning

While these terms are interchangeable, they refer to different things.

Artificial Intelligence is the general idea of creating machines capable of performing the tasks that require human intellect.

Machine Learning is a subfield of Artificial Intelligence concerned with providing such machines with the ability to learn from the data.

Relationship is as follows:

Artificial Intelligence -> Machine Learning -> Deep Learning

Deep Learning is a field within machine learning where the artificial neural networks are used to solve challenging problems.

Conclusion

Machine Learning has completely revolutionized data analysis, automation, and decision making processes in modern businesses. Thanks to machine learning, computers can be trained on experience.
Major machine learning types such as supervised learning, unsupervised learning, semi-supervised learning, and reinforcement learning give various ways to solve specific problems based on the data type and required outcome.

For everyone stepping into the field of data science, knowing about the machine learning is crucial as these concepts represent the core of model and data-driven solution creation.

Top comments (0)