In my previous blog, I had given an overview of the two major classes of machine learning algorithms. This article shall explain the 4 types of algorithms most common among Machine Learning Algorithm programmers – the algorithms classified as per their learning style.

## The Learning In Machine Learning Algorithms

In here, we look at machine learning algorithms based on how they ‘learn’ to create a model from input data. This learning happens due to the interaction of the machine with the environment and the subsequent data it is exposed to, and the manner in which the machine prepares and uses the data to create a model is the learning style of the algorithm.

There are only four types of algorithms when classified through learning style:

Supervised learning

Unsupervised learning

Semi-supervised learning

Reinforcement learning

You would come across these terms quite often in this post:

Labeled data: Data consisting of a set of training examples, where each example is a pair consisting of an input and a desired output value

Classification: The goal is to predict discrete values, e.g. {1,0}, {True, False}, {spam, not spam}.

Regression: The goal is to predict continuous values, e.g. home prices.

We shall now explore each with considerable sincerity:

Supervised Learning:

*Function: *Predict output value for any new data based on generalizations from past input data.

*Uses: *a set of labeled data with known outcomes, also known as the training dataset.

Each input data has a known outcome. Thus, the outcome(Y) is a function of all inputs (X). Mathematically, Y = f(X), where X is one or more inputs (independent variables)

For all different possible values of all Xs, we get a different Y. The catch is to be able to predict Y if a new set of Xs is confronted. Thus, the machine is trained to keep on predicting Y and this training happens on the data about Xs we have and the data which keeps on coming from the machine’s environment at every defined moment. Each new set of Xs is a test of the predictive ability of the algorithm, the ability to predict the “correct” Y. Thus, the process of predicting Y from Xs is being supervised by the algorithm.

The decision to use an algorithm depends on the nature of the target outcome – Y. Y can be either categorical (whether the borrower will default on the loan or not) or continuous (the price of a stock). Based on this, the two major classes of supervised learning algorithms are Classification and Regression Algorithms.

Let us understand these with over-simplified examples.

Classification algorithms are meant to deliver discrete / categorical outcomes – either binary (1/0) decisions or multi-class decisions (high-moderate-low risk). Let’s say we show 25 *different* pictures of an apple to our machine and after showing each picture – we tell it that it is an apple. Thus, we are labeling our inputs and also defining the outcome, and during the course of this task, we are training our machine to be able to determine what an apple is. The success of this exercise would be when we show a totally different picture of an apple (one the machine has not seen previously) and the machine is still able to determine that it is an apple. Or, if we show the picture of an orange, it can determine that it is not an apple. Here, the decision is binary (is an apple / is not an apple). The training ends when this prediction of Y is as accurate as needed. The algorithms used to predict categorical outcomes are known as classification algorithms, and the class consists of algorithms like logistic regression, random forest and Support Vector Machines.

Regression algorithms or more specifically regressive algorithms are deployed to predict a Y which is continuous, a real value such as profit in rupees or distance in kms. Here, we can look at classic economics where the price of a good is a function of its demand and supply. Thus, for one particular good – say sugar, we feed in demand, supply and price data of each month’s average for the last umpteen years. This would train our machine to be able to predict the next period’s price once the demand and supply data is fed into it. Common regression algorithms are simple and multiple regression, and random forest.

Unsupervised Learning:

*Function: *Predict output value for any new data based on discovering underlying structure and patterns in the input data

*Uses: *a set of unlabeled data with unknown outcomes

We can best understand this with an example from the current Covid-19 pandemic. Soon after the outbreak, there were revelations that people with co-morbidity were at higher risk of fatality. When fatalities started increasing, all that we had was a record of each patient who succumbed and each one who survived. It was only after a considerable number of observations that doctors got the clue that there was increased fatality amongst old-age patients with existing diseases and ailments. This is classic pattern detection. Unsupervised learning relies on the machine’s ability to learn on its own. There won’t be any predetermined input-output relation to train the machine to develop the prediction model. Rather than predicting an outcome, the focus is more in identifying commonalities amongst the input data sets. Training, or rather self-learning of the machine happens on unlabeled data. The model is prepared by deducing structures present in the data.

The choice of algorithm to be used depends upon the solution which is to be derived. One may wish to identify similarity among the data, or one may wish to mine for rules that describe large portions of data. Based on this, the two major classes of unsupervised learning algorithms are Clustering Association rule learning.

Clustering refers to grouping data into clusters which are internally homogenous and externally heterogeneous. The way to define a group and its constituents is determined by different clustering algorithms such as k-means, kNN, centroid, distance to centre, etc. A good problem to use clustering algorithms would be to segment consumers of entertainment and leisure on the base of their threat perception of Covid. Once these clusters are detected, marketers can study the consumers of each cluster in detail and understand their future demand intentions with more clarity.

The detection of co-morbidity in Covid-19 fatalities is an example of Association Rule Learning algorithm. By linking items, events, situations or characteristics, rules can be learned by the machine through which the relations between data can be identified and understood. Apriori algorithms are used to generate the rules for establishing relations among data.

Semi-Supervised Learning:

*Function: *Predict output value for any new data based on a combination of generalization of the past data and underlying patterns among past input data

*Uses: *a set of partially labeled input data

In the learning algorithms mentioned above, we either had labels for all data observations in the dataset (supervised) or there were no labels for any of the observations in the dataset (unsupervised). The first approach is possible when it is feasible to label all data and prediction is the requirement. The second approach is adopted when prediction is not a requirement and thus we can do with unlabeled data, irrespective of the size of the dataset. A trade-off is needed when we need predictive capabilities based on huge datasets wherein labeling all data observations is not feasible. This is where the middle of the road semi-supervised learning algorithms is used.

Herein, some of the input data is labeled and some is not. To be able to predict, the model must first learn the structures to organize data (unsupervised) and then use this data to make predictions (supervised).

Revisiting our Covid-19 example, it would be practically impossible to label data of all the fatalities that have happened across the world as of now, though it can be done in some time to come. Relying on labeled data of a few thousand observations, the remaining unlabeled data can be labeled by first grouping data through some clustering algorithm, and then using this labeled data for predictive analytics.

The algorithms used are a combination of those used in supervised and unsupervised learning: classification, regression, clustering or association rule learning.

Reinforcement Learning:

*Function: *Find the best way to earn a reward.

*Uses: *decisions taken in an environment, and the corresponding reward. Reinforced learning algorithms are wherein machine learning meets artificial intelligence. The algorithm, referred to as the agent here, uses it’s learning from interacting with the environment, and take actions aimed at enhancing rewards or reducing risks. The learning is iterative and continuous, until it has encountered and factored in all possible states of the environment.

Imagine playing chess against Anand or Karpov. A single move you make triggers off a very rapid and complex set of calculations about all possible outcomes of the game by the masters. And then they make their move, which would later on be verified as a masterstroke or a gross error depending upon whether the master wins or loses. And this outcome shall etch into the master’s mind forever, whether to repeat this move in any future game if the same state (move) is confronted. So, over thousands of games and millions of anticipated moves, the master knows the best possible countermove to every move you make.

The agent learns in the same manner in reinforced learning. Continuous reward feedback teaches the agent to determine the ideal behaviour for a specific context. Most crucial to its functioning is the retaining of the state-action pair information about the reward. It is this learning which reinforces the behaviour to execute a particular action which is rewarding. Some of the algorithms used for reinforced learning are Q-Learning, Temporal Difference, Deep Adversarial Networks.

In my next write-up, I shall explain the second way to classify Machine Learning Algorithms. The algorithms would be grouped on their similarity, and would comprise the same ones mentioned here, the only difference being they shall be clubbed according to some inherent similarity shared by them in terms of functioning and purpose.

## Comments