Supervised Learning in Machine Learning



From the name itself, we will understand that supervised learning works as a supervisor or teacher. Basically, in supervised learning, we teach or train the machine using well-labeled data (Input and Output) which means some data is already tagged with the right answer. After that, the machine is given a brand new set of examples (data) in order that the supervised learning algorithm analyses the training data (set of coaching examples) and produces an accurate outcome from labeled data.

Supervised learning is the type of Machine Learning where you have input variables (x) and an output variable (Y) and you utilize an algorithm to be told the mapping function from the input to the output.

Y = f(X)

The goal is to approximate the mapping function so well that after you have a new computer file (x) that you just can predict the output variables (Y) for that data.

For example:

Imagine there is a basket full of different kinds of fruits. The initial step is to train the machine with all the different fruits one by one like this:

·         If the shape of the object is rounded and depression at the top having color Red, then it will be labeled as –Apple.

·         If the shape of the object is a long curving cylinder having the color Green-Yellow, then it will be labeled as –Banana


Now suppose after training on the given data, you take a new separate fruit for example apple from the basket and try to identify it.

Since the machine has already learned the specifications from previous data it will classify the fruit with its

·         Shape

·         Colour


After confirming the fruit name as apple and put it in the apple category. Thus, the machine learns the things from training data (i.e. basket containing fruits) and then applies that knowledge to different test data (i.e. new fruit).



Supervised learning is classed into two categories of algorithms:

·          Classification: A classification problem is when the output variable could be a category, like “Red” or “blue” or “disease” and “no disease”.

·          Regression: A regression problem is when the output variable may be a real value or continuous, like “dollars” or “weight”.



Classification may be a reasonable technique to categorize any data into a desired and distinct number of classes where we are able to assign labels to every class. Classes are sometimes called as targets/ labels or categories. Classification predictive modeling is the task of approximating a mapping function (f) from the input (X) to discrete output variables (y).

For example, spam detection in email service providers will be identified as a classification problem. This can be s binary classification since there are only 2 classes as spam and not spam. A classifier utilizes some training data to know how given input variables relate to the category. During this case, known spam and non-spam emails must be used because of the training data. When the classifier is trained accurately, it will be wont to detect an unknown email. There are many applications in classification in many domains like in credit approval, diagnosing, target marketing, etc.

There are two sorts of learners in classification

1. Lazy learners

Lazy learners simply store the training data and wait until testing data appear. When it does, classification is conducted supported by the closest related data within the stored training data. Compared to eager learners, lazy learners have less training time but longer in predicting.    Ex. k-nearest neighbor, Case-based reasoning


2. Eager learners

Eager learners construct a classification model that supported by the given training data before receiving data for classification. It must be able to decide on one hypothesis that covers the whole instance space. Because of the model construction, eager learners take a protracted time for train and less time to predict.          Ex. Decision Tree, Naive Bayes, Artificial Neural Networks


There are many classification algorithms available nowadays, but it’s impractical to conclude which one is superior to other(s) because it may differ depending on the problem. It depends on the applying and nature of the accessible data set. Few classifications algorithms are:


A decision tree builds classification or regression models within the sort of a tree structure. It uses an if-then rule set which is both exclusive and exhaustive for classification. The principles are learned sequentially using the training data one at a time. Anytime a rule is learned, the tuples covered by the foundations are removed. This process is sustained on the training set until meeting a termination condition.

The tree is made in an exceedingly top-down recursive divide-and-conquer manner. All the attributes should be categorical. Otherwise, they ought to be discretized beforehand. Attributes at the top of the tree have more impact on the classification and they are identified using the data gain concept.

These decisions (Splits) generate rules for classification/Prediction of a dataset using statistical criterions like

·         Entropy

·         Information gain

·         Gini index

·         Chi-square tests. Etc

A decision tree is easily over-fitted generating too many branches and should reflect anomalies thanks to noise or outliers. An over-fitted model contains a very poor performance on the unseen data although it gives a powerful performance on training data. This will be avoided by pre-pruning which halts tree construction early or post-pruning which removes branches from the grownup tree.



Naive Bayes could be a probabilistic classifier inspired by the Bayes theorem under an easy assumption which is that the attributes are conditionally independent.

Simply, a Naive Bayes classifier assumes the presence of a feature in an exceeding class is not related to the presence of the other feature.

It may be represented employing a very simple Bayesian network. Naive Bayes classifiers are especially popular for text classification and are a standard solution for problems like spam detection.

The naive Bayes model is quite straightforward to create and useful for large data sets. Alongside simplicity, Naive Bayes is thought to outperform even highly sophisticated classification methods.

NAIVE BAYES Algorithms

K-Nearest Neighbor(KNN):

The k-Nearest-Neighbours (kNN) method is the simplest method in machine learning and simple to know, remember and implement, this method has seen wide application in many domains, like in semantic searching, recommendation systems, and anomaly detection.

K-Nearest A neighbor could be a lazy learning algorithm that stores all instances correspond to training data points in n-dimensional space. When an unknown discrete data is received, it analyses the closest k number of instances saved (nearest neighbors) and returns the foremost common class because of the prediction and for real-valued data, it returns the mean of k nearest neighbors.

In the distance-weighted nearest neighbor algorithm, it weights the contribution of every of the k neighbors per their distance using the subsequent query giving greater weight to the closest neighbors.

k-Nearest-Neighbours (kNN) method

            Distance calculating query

Normally KNN is robust to noisy data because it is averaging the k-nearest neighbors.

K-Nearest Neighbor lazy learning algorithm


Random Forest may be a versatile ensemble machine learning method capable of performing both regression and classification tasks. It also undertakes dimensional reduction methods, treats missing values, outlier values, and other essential steps of information exploration, and does a reasonably good job. it’s a sort of ensemble learning method, where a gaggle of weak models combines to make a strong model.

The pseudo-code for a random forest algorithm can be split into two stages. First, within which ‘n’ random trees are created, this forms the random forest. Within the second stage, the end result for the identical test feature from all decision trees is combined. Then the ultimate prediction comes by assessing the results of every decision tree or simply by going with a prediction that appears the foremost times within the decision trees.

Random Forest Machine Learning Algorithm is accurate even when there are inconsistent data and is really straightforward to use. It gives estimates on what variables are important for the specific classification. It runs efficiently on large databases while generating an inside unbiased estimate of the generalization error.

The random algorithm especially helps data scientists to avoid wasting data preparation time, as they are doing not require any input preparation and are ready to handle numerical data and categorical features without scaling or transformation.It is utilized in wide varieties applications like Medicine, securities market, E-commerce, and Banking sector.

Random Forest Machine Learning Algorithm


The goal of the SVM algorithm is to make the most effective line or decision boundary which will segregate n-dimensional space into classes in order that we are able to easily put the new datum within the correct category within the future. This best decision a boundary is named a hyperplane.

SVM chooses the intense points/vectors that help in creating the hyperplane. These specific cases are called support vectors, and hence the algorithm is termed as Support Vector Machine.

The followings are important concepts in SVM −

·         Support Vectors − Datapoints that are closest to the hyperplane is termed support vectors. Separating lines are going to be defined with the assistance of those data points.

·         Hyperplane − As we are able to see within the above diagram, it’s a choice plane or space which is split between a group of objects having different classes.

·         Margin − it should be defined because of the gap between two lines on the closet data points of various classes. It will be calculated because of the perpendicular distance from the road to the support vectors. A large margin is taken into account as a decent margin and a tiny margin is taken into account as a foul margin.

Support vectors are data points that are closer to the hyperplane and influence the position and orientation of the hyperplane. Using these support vectors, we maximize the margin of the classifier. Deleting the support vectors will change the position of the hyperplane. These points help us build our SVM.

Representation of data before fitting the hyperplane

            Representation of data before fitting the hyperplane


Representation of data after fitting the Best hyperplane

Representation of data after fitting the Best hyperplane



Artificial Neural Network could be considered a set of connected input and output units with each connection encompassing a weight-related to it. The idea came from psychologists and neurobiologists to develop and test computational analogs of neurons. During the training phase, the network learns by adjusting the weights to be ready to predict the proper class label of the input tuples.

There are many networks architectures available now like Feed-forward, Convolutional, and Recurrent, etc. the suitable architecture depends on the applying of the model. For many cases feed-forward models give reasonably accurate results and particularly for image processing applications, convolutional networks perform better.

There are often multiple hidden layers within the model reckoning on the complexity of the function which goes to be mapped by the model. Having more hidden layers will enable us to model complex relationships like deep neural networks.

However, when there are many hidden layers, it takes plenty of your time to coach and adjusts wights. the opposite disadvantage is that the poor interpretability of the model compared to other models like Decision Trees because of the unknown symbolic meaning behind the learned weights.

But Artificial Neural Networks have had a great performance in most real-world applications. It’s high tolerance to noisy data and ready to classify untrained patterns. Usually, Artificial Neural Networks perform best when continuous-valued inputs and outputs are available.

Representation of artificial neural networks

Representation of artificial neural networks

Challenges in Supervised machine learning

Here, are challenges faced in supervised machine learning:

·         Irrelevant input feature present training data could give inaccurate results

·         Data preparation and pre-processing is often a challenge.

·         Accuracy suffers when impossible, unlikely, and incomplete values are inputted as training data

·         If the concerned expert isn’t available, then the opposite approach is “brute-force.” It means you would like to think that the proper features (input variables) to coach the machine on. It may well be inaccurate.


Advantages of Supervised Learning:

·         Supervised learning allows you to gather data or produce an information output from the previous experience

·         Helps you to optimize performance criteria using experience

·         Supervised machine-learning helps you to unravel various styles of real-world computation problems.


Disadvantages of Supervised Learning:

·         Decision a boundary may be overtrained if your training set which does not have examples that you simply want to own in an exceedingly class

·         You have to select plenty of good examples from each class while you’re training the classifier.

·         Classifying big data are often a true challenge.

·         Training for supervised learning needs lots of computation time.



·         In supervised learning, you train the machine using data that is well “labeled.”

·         You want to coach a machine which helps you are expecting how long it’ll take you to drive home from your workplace is an example of supervised learning

·         Regression and Classification is two sorts of supervised machine learning techniques.

·         Supervised learning could be a simpler method while Unsupervised learning may be a complex method.

·         The biggest challenge in supervised learning is that the Irrelevant input feature present training data could give inaccurate results.

·         The main advantage of supervised learning is that it allows you to gather data or produce an information output from the previous experience.

·         A drawback of this model is that call boundary could be overstrained if your training set doesn’t have examples that you simply want to possess in an exceedingly class.

·         As a best practice of supervised learning, you initially have to decide what reasonably data should be used as a training set.

Leave a Comment

Scroll to Top