Important ML algorithms and how to choose?

Types of Machine Learning algorithms

What Is a Machine Learning (ML) Algorithm?

A machine learning algorithm is,
  • A mathematical model or
  • A set of rules
that helps and enables a Machine Learning (ML) system to identify patterns or make predictions from data it is going to be trained on. What is mathematical modeling…? In this process real world situation is produced by a mathematical model. For that, real world data (inputs and relevant outputs) are needed. After simplifying the natural phenomenon/ process using valid assumptions, then it is mathematically modeled. Finally, predictions are verified using the real data and whether model interact imitating the real world scenario. This cycle continues until a best mathematical model is tuned. (Figure: 01)
Mathematical modeling of Real Scenario
Figure 01: Mathematical modeling of a real scenario.

Since ML is a mathematical model, it needs no explicit coding for a given goal. It is the core component of a ML system that allows it to automatically learn and improve from its new data or new experiences in other words.

ML algorithms uses statistical techniques to identify patterns, relations and its dependencies to inputs and outputs in the data being a mathematical model. Then those models and patterns are used to make new predictions or decisions for even unseen data. This is the power of Machine Learning and accuracy lies mostly on the

  • training algorithm and 

  • quality of data which is being used in the training phase.

In this article, let’s discuss more what are the existing ML algorithms and for what type of tasks suit the most.

What are the most common types of ML algorithms?

Types of Machine Learning algorithms
Figure 02: Machine learning algorithm types.

Most common sets of ML algorithms as in the following list. We will discuss each in more detail in coming up articles. There are three main types of algorithms under ML algorithms umbrella,

Supervised Algorithms:

Supervised learning algorithms use labeled datasets, in which inputs and relevant outputs are coupled. And typically, these data are labeled by an external supervisor (human/ program). For example: In Figure 03 [left], images of cats with label cats are fed and trained.

How Supervised learning happens and what are training and testing data
Figure 3: How Supervised Learning is done,

There are several supervised algorithms that can be used for training ML models. Then the trained model are used to predict unseen/new data (Figure 03 [right]).

# Supervised Learning Algorithms:

Here are some important supervised algorithms that are in literature.

Supervised Learning Algorithm Description Use cases
Regression: Linear Regression Captures the relation between the input variables and the output variable using a linear equation and finds the best-fitting line that minimizes the difference between the predicted and actual values. Estimating real values (number of vehicle registrations, revenue of a company)
Regression: Polynomial Learns the relation between the input variables and the output variable using a polynomial equation and finds the best-fitting line that minimizes the difference between the predicted and actual values. Estimating real values (non-linear relation between the temperature of a chemical reaction and the reaction rate)
Classification: Logistic Regression Captures the relation between the input variables and the probability of belonging to a particular class. It applies a logistic function to map the input features to the probability of the output class. Binary classification tasks
Classification: Naive Bayes Probabilistic classifier based on Bayes’ theorem; given the class, it calculates the probability of each class for a given input. It is simple and needs less computation, thus it is fast. Text classification tasks.
Random Forest: Widely adopted in the industry since it’s very easy to deploy and gives good results, even though it performs a little worse than XGBoost. This is an ensemble learning method. Combining multiple decision trees, it builds a collection of decision trees and predicts based on the majority vote or average prediction of the individual trees.
Classification/Regression: XGBoost (Extreme Gradient Boosting) The algorithm that usually gives the best results and optimizes the objective function by iteratively adding new models and minimizing a loss function. Recommendation Systems, Image Processing, Natural Language Processing (NLP), etc.
Classification/Regression: K-Nearest Neighbors (KNN) KNN is a non-parametric algorithm and classifies or predicts the output based on the majority vote or average of the nearest k neighbors in the training data, where “k” is a user-defined training parameter. Movie recommendation systems, Anomaly Detection
Classification and Regression: Support Vector Machine (SVM) It constructs a hyperplane in a high-dimensional feature space to separate different classes. The algorithm aims to maximize the margin between the classes, making it robust to outliers. SVM can also handle non-linear relationships by using kernel functions to transform the data into a higher-dimensional space.
Classification and Regression: Decision Tree Create a tree-like model where each internal node represents a feature, and each leaf node represents a class or a predicted value. Decision trees make binary splits based on feature thresholds to partition the data into homogeneous subsets. They are easy to interpret and can handle both categorical and numerical features.

For more info, follow this link

Unsupervised ML Algorithms:

Unsupervised learning uses unlabeled data and try to group similar things together or find hidden structures. Sorting out some different objects into groups/categories without given any category just by matching the similarities data have. These algorithms are very useful for letting a machine to decide/explore from their own, without explicitly telling what is expected.

Unsupervised learning uses unlabeled data
Figure 04: Supervised Learning mechanism.

There are several unsupervised algorithms that can be used for training ML models. Then the trained model are used to predict unseen/new data or cluster or categorize given new data point (Figure 04).

Unsupervised Algorithms:

Here are some important supervised algorithms that are in literature.

Unsupervised Algorithm:

Description

Use case

Classification or Regression:

Singular Value Decomposition (SVD)

SVD and PCA are dimensionality reduction techniques used to extract the most important features from high-dimensional data. SVD factorizes a matrix into three matrices, capturing the latent relationships between variables.

Collaborative Filtering for Recommender Systems

Classification or Regression:

Principal Component Analysis (PCA)

PCA is a specific application of SVD, where it identifies orthogonal components that explain the maximum variance in the data. These techniques are widely used for feature extraction, noise reduction, and data visualization.

Dimensionality Reduction for Classification

Classification:

K-means:

K-means is an unsupervised clustering algorithm used to partition data into k distinct clusters. It assigns each data point to the nearest cluster centroid based on the distance metric (Euclidean distance). K-means aims to minimize the within-cluster sum of squared distances, forming tight clusters. It is a simple and efficient algorithm but requires a specific k value in advance.

Customer Segmentation for Marketing

For more info, follow this link

Reinforcement Learning (RL) Algorithms: 

In Reinforcement learning algorithm, ML model has access to an agent (physical/virtual). This agent interacts with its environment (physical/virtual) by sensing given/current state and learns to take an action in order to maximize its long-term reward. For example in training a dog to fetch a stick, reinforcement learning also involve a similar approach. The dog is the agent, and the environment is the area where the dog interacts with the stick and other objects. Goal is to bring back the throwed object and the reward is some snacks for it. Through trial-and-error method the dog finally finds the action of picking up the stick [Goal].

Reinforcement learning algorithm
Figure 05: Reinforcement learning algorithm and a real world scenario of training a dog to fetch a thrown stick.

There are several RL algorithms that can be used for training ML models. Then the trained models are used by the agent to take actions/decisions given environments. (Figure 05 [right]).

# Reinforcement Learning (RL) Algorithms: 

We will now discuss what are the algorithms and what they are used and ideal for?

RL algorithm

Description

Use case

Model-free RL:

Q-Learning:

Q-Learning is a popular model-free RL algorithm. It is based on the concept of learning action-value functions (Q-values) that represent the expected cumulative rewards for taking a particular action in a given state. The agent iteratively updates Q-values based on the observed rewards and the exploration-exploitation trade-off.

Problems with discrete state and action spaces.

Model-free RL:

Deep Q-Network (DQN):

Extension of Q-Learning and combines RL with deep neural networks. It uses a deep neural network to approximate Q-values, enabling RL in environments with high-dimensional state spaces. DQN utilizes experience replay and target networks to stabilize learning and improve sample efficiency.

Playing Atari games and controlling robotic systems.

Model-free RL:

Policy Gradient (PG):

Policy Gradient methods directly optimize a parameterized policy that maps states to actions. These methods use gradient ascent to update the policy parameters, aiming to maximize the expected cumulative rewards.

For tasks like robotic control and game playing.

Model-Based Monte Carlo (MBMC):

MBMC is an RL algorithm that learns a model of the environment dynamics through Monte Carlo simulation. It collects samples by executing actions in the real environment and then uses those samples to learn a transition model and reward model.

Trained models are used for planning and decision-making.

Model-Based:

Dyna-Q:

Combines Q-Learning with planning. It maintains a learned model of the environment and uses it to simulate additional transitions. The simulated transitions are used to update the Q-values, allowing for more efficient exploration and faster convergence.

Model-Based Tree Search:

Model-Based Tree Search algorithms, such as Monte Carlo Tree Search (MCTS), combine RL with tree search techniques. These algorithms build a search tree by iteratively simulating trajectories using the learned model.

Enables efficient exploration and planning to find the optimal actions.

For more info, follow this link

Conclusion

Conclusion

In conclusion, machine learning algorithms play a crucial role in solving complex problems and extracting insights from data. In this article, we have provided an overview of various machine learning algorithms. In future articles, we will delve into each algorithm in detail, exploring their implementation side mostly with Python code. Stay connected with us and our social media for latest updates on this series.