0% found this document useful (0 votes)
14 views35 pages

Introduction to Machine Learning Concepts

Uploaded by

Aastha Pandey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views35 pages

Introduction to Machine Learning Concepts

Uploaded by

Aastha Pandey
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

What is Machine Learning

In the real world, we are surrounded by humans who can learn everything from
their experiences with their learning capability, and we have computers or
machines which work on our instructions. But can a machine also learn from
experiences or past data like a human does? So here comes the role of Machine
Learning.

Introduction to Machine Learning


A subset of artificial intelligence known as machine learning focuses primarily
on the creation of algorithms that enable a computer to independently learn
from data and previous experiences. Arthur Samuel first used the term "machine
learning" in 1959. It could be summarized as follows:
Without being explicitly programmed, machine learning enables a machine to
automatically learn from data, improve performance from experiences, and
predict things.
Machine learning algorithms create a mathematical model that, without being
explicitly programmed, aids in making predictions or decisions with the
assistance of sample historical data, or training data. For the purpose of
developing predictive models, machine learning brings together statistics and
computer science. Algorithms that learn from historical data are either
constructed or utilized in machine learning. The performance will rise in
proportion to the quantity of information we provide.
A machine can learn if it can gain more data to improve its performance.

How does Machine Learning work


A machine learning system builds prediction models, learns from previous data,
and predicts the output of new data whenever it receives it. The amount of data
helps to build a better model that accurately predicts the output, which in turn
affects the accuracy of the predicted output.
Let's say we have a complex problem in which we need to make predictions.
Instead of writing code, we just need to feed the data to generic algorithms,
which build the logic based on the data and predict the output. Our perspective
on the issue has changed as a result of machine learning. The Machine Learning
algorithm's operation is depicted in the following block diagram:

Features of Machine Learning:


o Machine learning uses data to detect various patterns in a given dataset.
o It can learn from past data and improve automatically.
o It is a data-driven technology.
o Machine learning is much similar to data mining as it also deals with the
huge amount of the data.

Need for Machine Learning


The demand for machine learning is steadily rising. Because it is able to
perform tasks that are too complex for a person to directly implement, machine
learning is required. Humans are constrained by our inability to manually access
vast amounts of data; as a result, we require computer systems, which is where
machine learning comes in to simplify our lives.
By providing them with a large amount of data and allowing them to
automatically explore the data, build models, and predict the required output,
we can train machine learning algorithms. The cost function can be used to
determine the amount of data and the machine learning algorithm's
performance. We can save both time and money by using machine learning.
The significance of AI can be handily perceived by its utilization's cases,
Presently, AI is utilized in self-driving vehicles, digital misrepresentation
identification, face acknowledgment, and companion idea by Facebook, and so
on. Different top organizations, for example, Netflix and Amazon have
constructed AI models that are utilizing an immense measure of information to
examine the client interest and suggest item likewise.
Following are some key points which show the importance of Machine
Learning:
o Rapid increment in the production of data
o Solving complex problems, which are difficult for a human
o Decision making in various sector including finance
o Finding hidden patterns and extracting useful information from data.

Classification of Machine Learning


At a broad level, machine learning can be classified into three types:
1. Supervised learning
2. Unsupervised learning
3. Reinforcement learning

1) Supervised Learning
In supervised learning, sample labeled data are provided to the machine learning
system for training, and the system then predicts the output based on the
training data.
The system uses labeled data to build a model that understands the datasets and
learns about each one. After the training and processing are done, we test the
model with sample data to see if it can accurately predict the output.
The mapping of the input data to the output data is the objective of supervised
learning. The managed learning depends on oversight, and it is equivalent to
when an understudy learns things in the management of the educator. Spam
filtering is an example of supervised learning.
Supervised learning can be grouped further in two categories of algorithms:
o Classification
o Regression

2) Unsupervised Learning
Unsupervised learning is a learning method in which a machine learns without
any supervision.
The training is provided to the machine with the set of data that has not been
labeled, classified, or categorized, and the algorithm needs to act on that data
without any supervision. The goal of unsupervised learning is to restructure the
input data into new features or a group of objects with similar patterns.
In unsupervised learning, we don't have a predetermined result. The machine
tries to find useful insights from the huge amount of data. It can be further
classifieds into two categories of algorithms:
o Clustering
o Association

3) Reinforcement Learning
Reinforcement learning is a feedback-based learning method, in which a
learning agent gets a reward for each right action and gets a penalty for each
wrong action. The agent learns automatically with these feedbacks and
improves its performance. In reinforcement learning, the agent interacts with the
environment and explores it. The goal of an agent is to get the most reward
points, and hence, it improves its performance.
The robotic dog, which automatically learns the movement of his arms, is an
example of Reinforcement learning.
Note: We will learn about the above types of machine learning in detail in later
chapters.
History of Machine Learning
Before some years (about 40-50 years), machine learning was science fiction,
but today it is the part of our daily life. Machine learning is making our day to
day life easy from self-driving cars to Amazon virtual assistant "Alexa".
However, the idea behind machine learning is so old and has a long history.
Below some milestones are given which have occurred in the

History of machine learning:

The early history of Machine Learning (Pre-1940):


o 1834: In 1834, Charles Babbage, the father of the computer, conceived a
device that could be programmed with punch cards. However, the
machine was never built, but all modern computers rely on its logical
structure.
o 1936: In 1936, Alan Turing gave a theory that how a machine can
determine and execute a set of instructions.
The era of stored program computers:
o 1940: In 1940, the first manually operated computer, "ENIAC" was
invented, which was the first electronic general-purpose computer. After
that stored program computer such as EDSAC in 1949 and EDVAC in
1951 were invented.
o 1943: In 1943, a human neural network was modeled with an electrical
circuit. In 1950, the scientists started applying their idea to work and
analyzed how human neurons might work.
Computer machinery and intelligence:
o 1950: In 1950, Alan Turing published a seminal paper, "Computer
Machinery and Intelligence," on the topic of artificial intelligence. In
his paper, he asked, "Can machines think?"
Machine intelligence in Games:
o 1952: Arthur Samuel, who was the pioneer of machine learning, created a
program that helped an IBM computer to play a checkers game. It
performed better more it played.
o 1959: In 1959, the term "Machine Learning" was first coined by Arthur
Samuel.
The first "AI" winter:
o The duration of 1974 to 1980 was the tough time for AI and ML
researchers, and this duration was called as AI winter.
o In this duration, failure of machine translation occurred, and people had
reduced their interest from AI, which led to reduced funding by the
government to the researches.
Machine Learning from theory to reality
o 1959: In 1959, the first neural network was applied to a real-world
problem to remove echoes over phone lines using an adaptive filter.
o 1985: In 1985, Terry Sejnowski and Charles Rosenberg invented a neural
network NETtalk, which was able to teach itself how to correctly
pronounce 20,000 words in one week.
o 1997: The IBM's Deep blue intelligent computer won the chess game
against the chess expert Garry Kasparov, and it became the first computer
which had beaten a human chess expert.
Machine Learning at 21st century
2006:
o Geoffrey Hinton and his group presented the idea of profound getting the
hang of utilizing profound conviction organizations.
o The Elastic Compute Cloud (EC2) was launched by Amazon to provide
scalable computing resources that made it easier to create and implement
machine learning models.
2007:
o Participants were tasked with increasing the accuracy of Netflix's
recommendation algorithm when the Netflix Prize competition began.
o Support learning made critical progress when a group of specialists
utilized it to prepare a PC to play backgammon at a top-notch level.
2008:
o Google delivered the Google Forecast Programming interface, a cloud-
based help that permitted designers to integrate AI into their applications.
o Confined Boltzmann Machines (RBMs), a kind of generative brain
organization, acquired consideration for their capacity to demonstrate
complex information conveyances.
2009:
o Profound learning gained ground as analysts showed its viability in
different errands, including discourse acknowledgment and picture
grouping.
o The expression "Large Information" acquired ubiquity, featuring the
difficulties and open doors related with taking care of huge datasets.
2010:
o The ImageNet Huge Scope Visual Acknowledgment Challenge
(ILSVRC) was presented, driving progressions in PC vision, and
prompting the advancement of profound convolutional brain
organizations (CNNs).
2011:
o On Jeopardy! IBM's Watson defeated human champions., demonstrating
the potential of question-answering systems and natural language
processing.
2012:
o AlexNet, a profound CNN created by Alex Krizhevsky, won the
ILSVRC, fundamentally further developing picture order precision and
laying out profound advancing as a predominant methodology in PC
vision.
o Google's Cerebrum project, drove by Andrew Ng and Jeff Dignitary,
utilized profound figuring out how to prepare a brain organization to
perceive felines from unlabeled YouTube recordings.
2013:
o Ian Goodfellow introduced generative adversarial networks (GANs),
which made it possible to create realistic synthetic data.
o Google later acquired the startup DeepMind Technologies, which focused
on deep learning and artificial intelligence.
2014:
o Facebook presented the DeepFace framework, which accomplished close
human precision in facial acknowledgment.
o AlphaGo, a program created by DeepMind at Google, defeated a world
champion Go player and demonstrated the potential of reinforcement
learning in challenging games.
2015:
o Microsoft delivered the Mental Toolbox (previously known as CNTK),
an open-source profound learning library.
o The performance of sequence-to-sequence models in tasks like machine
translation was enhanced by the introduction of the idea of attention
mechanisms.
2016:
o The goal of explainable AI, which focuses on making machine learning
models easier to understand, received some attention.
o Google's DeepMind created AlphaGo Zero, which accomplished godlike
Go abilities to play without human information, utilizing just support
learning.
2017:
o Move learning acquired noticeable quality, permitting pretrained models
to be utilized for different errands with restricted information.
o Better synthesis and generation of complex data were made possible by
the introduction of generative models like variational autoencoders
(VAEs) and Wasserstein GANs.
o These are only a portion of the eminent headways and achievements in AI
during the predefined period. The field kept on advancing quickly past
2017, with new leap forwards, strategies, and applications arising.

Machine Learning at present:


The field of machine learning has made significant strides in recent years, and
its applications are numerous, including self-driving cars, Amazon Alexa,
Catboats, and the recommender system. It incorporates clustering, classification,
decision tree, SVM algorithms, and reinforcement learning, as well as
unsupervised and supervised learning.
Present day AI models can be utilized for making different expectations,
including climate expectation, sickness forecast, financial exchange
examination, and so on.

Applications of Machine learning


Machine learning is a buzzword for today's technology, and it is growing very
rapidly day by day. We are using machine learning in our daily life even
without knowing it such as Google Maps, Google assistant, Alexa, etc. Below
are some most trending real-world applications of Machine Learning:
1. Image Recognition:
Image recognition is one of the most common applications of machine learning.
It is used to identify objects, persons, places, digital images, etc. The popular
use case of image recognition and face detection is, Automatic friend tagging
suggestion:
Facebook provides us a feature of auto friend tagging suggestion. Whenever we
upload a photo with our Facebook friends, then we automatically get a tagging
suggestion with name, and the technology behind this is machine learning's face
detection and recognition algorithm.
It is based on the Facebook project named "Deep Face," which is responsible
for face recognition and person identification in the picture.

2. Speech Recognition
While using Google, we get an option of "Search by voice," it comes under
speech recognition, and it's a popular application of machine learning.
Speech recognition is a process of converting voice instructions into text, and it
is also known as "Speech to text", or "Computer speech recognition." At
present, machine learning algorithms are widely used by various applications of
speech recognition. Google assistant, Siri, Cortana, and Alexa are using
speech recognition technology to follow the voice instructions.

3. Traffic prediction:
If we want to visit a new place, we take help of Google Maps, which shows us
the correct path with the shortest route and predicts the traffic conditions.
It predicts the traffic conditions such as whether traffic is cleared, slow-moving,
or heavily congested with the help of two ways:
o Real Time location of the vehicle form Google Map app and sensors
o Average time has taken on past days at the same time.
Everyone who is using Google Map is helping this app to make it better. It takes
information from the user and sends back to its database to improve the
performance.

4. Product recommendations:
Machine learning is widely used by various e-commerce and entertainment
companies such as Amazon, Netflix, etc., for product recommendation to the
user. Whenever we search for some product on Amazon, then we started getting
an advertisement for the same product while internet surfing on the same
browser and this is because of machine learning.
Google understands the user interest using various machine learning algorithms
and suggests the product as per customer interest.
As similar, when we use Netflix, we find some recommendations for
entertainment series, movies, etc., and this is also done with the help of machine
learning.
5. Self-driving cars:
One of the most exciting applications of machine learning is self-driving cars.
Machine learning plays a significant role in self-driving cars. Tesla, the most
popular car manufacturing company is working on self-driving car. It is using
unsupervised learning method to train the car models to detect people and
objects while driving.

6. Email Spam and Malware Filtering:


Whenever we receive a new email, it is filtered automatically as important,
normal, and spam. We always receive an important mail in our inbox with the
important symbol and spam emails in our spam box, and the technology behind
this is Machine learning. Below are some spam filters used by Gmail:
o Content Filter
o Header filter
o General blacklists filter
o Rules-based filters
o Permission filters
Some machine learning algorithms such as Multi-Layer Perceptron, Decision
tree, and Naïve Bayes classifier are used for email spam filtering and malware
detection.

7. Virtual Personal Assistant:


We have various virtual personal assistants such as Google
assistant, Alexa, Cortana, Siri. As the name suggests, they help us in finding
the information using our voice instruction. These assistants can help us in
various ways just by our voice instructions such as Play music, call someone,
Open an email, Scheduling an appointment, etc.
These virtual assistants use machine learning algorithms as an important part.
These assistant record our voice instructions, send it over the server on a cloud,
and decode it using ML algorithms and act accordingly.

8. Online Fraud Detection:


Machine learning is making our online transaction safe and secure by detecting
fraud transaction. Whenever we perform some online transaction, there may be
various ways that a fraudulent transaction can take place such as fake
accounts, fake ids, and steal money in the middle of a transaction. So to detect
this, Feed Forward Neural network helps us by checking whether it is a
genuine transaction or a fraud transaction.
For each genuine transaction, the output is converted into some hash values, and
these values become the input for the next round. For each genuine transaction,
there is a specific pattern which gets change for the fraud transaction hence, it
detects it and makes our online transactions more secure.
9. Stock Market trading:
Machine learning is widely used in stock market trading. In the stock market,
there is always a risk of up and downs in shares, so for this machine
learning's long short term memory neural network is used for the prediction
of stock market trends.

10. Medical Diagnosis:


In medical science, machine learning is used for diseases diagnoses. With this,
medical technology is growing very fast and able to build 3D models that can
predict the exact position of lesions in the brain.
It helps in finding brain tumors and other brain-related diseases easily.

11. Automatic Language Translation:


Nowadays, if we visit a new place and we are not aware of the language then it
is not a problem at all, as for this also machine learning helps us by converting
the text into our known languages. Google's GNMT (Google Neural Machine
Translation) provide this feature, which is a Neural Machine Learning that
translates the text into our familiar language, and it called as automatic
translation. The technology behind the automatic translation is a sequence to
sequence learning algorithm, which is used with image recognition and
translates the text from one language to another language.

Types of Machine Learning


Machine learning is a subset of AI, which enables the machine to automatically
learn from data, improve performance from past experiences, and make
predictions. Machine learning contains a set of algorithms that work on a huge
amount of data. Data is fed to these algorithms to train them, and on the basis of
training, they build the model & perform a specific task.

These ML algorithms help to solve different business problems like Regression,


Classification, Forecasting, Clustering, and Associations, etc.

Based on the methods and way of learning, machine learning is divided into
mainly four types, which are:
1. Supervised Machine Learning
2. Unsupervised Machine Learning
3. Semi-Supervised Machine Learning
4. Reinforcement Learning
Types of Machine Learning along with their respective algorithms:

1. Supervised Machine Learning


As its name suggests, Supervised machine learning is based on supervision. It
means in the supervised learning technique, we train the machines using the
"labelled" dataset, and based on the training, the machine predicts the output.
Here, the labelled data specifies that some of the inputs are already mapped to
the output. More preciously, we can say; first, we train the machine with the
input and corresponding output, and then we ask the machine to predict the
output using the test dataset.
Let's understand supervised learning with an example. Suppose we have an
input dataset of cats and dog images. So, first, we will provide the training to
the machine to understand the images, such as the shape & size of the tail of
cat and dog, Shape of eyes, colour, height (dogs are taller, cats are smaller),
etc. After completion of training, we input the picture of a cat and ask the
machine to identify the object and predict the output. Now, the machine is well
trained, so it will check all the features of the object, such as height, shape,
colour, eyes, ears, tail, etc., and find that it's a cat. So, it will put it in the Cat
category. This is the process of how the machine identifies the objects in
Supervised Learning.
The main goal of the supervised learning technique is to map the input
variable(x) with the output variable(y). Some real-world applications of
supervised learning are Risk Assessment, Fraud Detection, Spam
filtering, etc.

Categories of Supervised Machine Learning


Supervised machine learning can be classified into two types of problems,
which are given below:
o Classification
o Regression
a) Classification
Classification algorithms are used to solve the classification problems in which
the output variable is categorical, such as "Yes" or No, Male or Female, Red
or Blue, etc. The classification algorithms predict the categories present in the
dataset. Some real-world examples of classification algorithms are Spam
Detection, Email filtering, etc.
Some popular classification algorithms are given below:
o Random Forest Algorithm
o Decision Tree Algorithm
o Logistic Regression Algorithm
o Support Vector Machine Algorithm

b) Regression
Regression algorithms are used to solve regression problems in which there is a
linear relationship between input and output variables. These are used to predict
continuous output variables, such as market trends, weather prediction, etc.
Some popular Regression algorithms are given below:
o Simple Linear Regression Algorithm
o Multivariate Regression Algorithm
o Decision Tree Algorithm
o Lasso Regression

Advantages:
o Since supervised learning work with the labelled dataset so we can have
an exact idea about the classes of objects.
o These algorithms are helpful in predicting the output on the basis of prior
experience.
Disadvantages:
o These algorithms are not able to solve complex tasks.
o It may predict the wrong output if the test data is different from the
training data.
o It requires lots of computational time to train the algorithm.

Applications of Supervised Learning


Some common applications of Supervised Learning are given below:
o Image Segmentation:
Supervised Learning algorithms are used in image segmentation. In this
process, image classification is performed on different image data with
pre-defined labels.
o Medical Diagnosis:
Supervised algorithms are also used in the medical field for diagnosis
purposes. It is done by using medical images and past labelled data with
labels for disease conditions. With such a process, the machine can
identify a disease for the new patients.
o Fraud Detection - Supervised Learning classification algorithms are
used for identifying fraud transactions, fraud customers, etc. It is done by
using historic data to identify the patterns that can lead to possible fraud.
o Spam detection - In spam detection & filtering, classification algorithms
are used. These algorithms classify an email as spam or not spam. The
spam emails are sent to the spam folder.
o Speech Recognition - Supervised learning algorithms are also used in
speech recognition. The algorithm is trained with voice data, and various
identifications can be done using the same, such as voice-activated
passwords, voice commands, etc.

2. Unsupervised Machine Learning


Unsupervised learning is different from the Supervised learning technique; as its
name suggests, there is no need for supervision. It means, in unsupervised
machine learning, the machine is trained using the unlabeled dataset, and the
machine predicts the output without any supervision.
In unsupervised learning, the models are trained with the data that is neither
classified nor labelled, and the model acts on that data without any supervision.
The main aim of the unsupervised learning algorithm is to group or
categories the unsorted dataset according to the similarities, patterns, and
differences. Machines are instructed to find the hidden patterns from the input
dataset.
Let's take an example to understand it more preciously; suppose there is a
basket of fruit images, and we input it into the machine learning model. The
images are totally unknown to the model, and the task of the machine is to find
the patterns and categories of the objects.
So, now the machine will discover its patterns and differences, such as colour
difference, shape difference, and predict the output when it is tested with the
test dataset.

Categories of Unsupervised Machine Learning


Unsupervised Learning can be further classified into two types, which are given
below:
o Clustering
o Association

1) Clustering
The clustering technique is used when we want to find the inherent groups from
the data. It is a way to group the objects into a cluster such that the objects with
the most similarities remain in one group and have fewer or no similarities with
the objects of other groups. An example of the clustering algorithm is grouping
the customers by their purchasing behaviour.
Some of the popular clustering algorithms are given below:
o K-Means Clustering algorithm
o Mean-shift algorithm
o DBSCAN Algorithm
o Principal Component Analysis
o Independent Component Analysis

2) Association
Association rule learning is an unsupervised learning technique, which finds
interesting relations among variables within a large dataset. The main aim of
this learning algorithm is to find the dependency of one data item on another
data item and map those variables accordingly so that it can generate maximum
profit. This algorithm is mainly applied in Market Basket analysis, Web usage
mining, continuous production, etc.
Some popular algorithms of Association rule learning are Apriori Algorithm,
Eclat, FP-growth algorithm.

Advantages:
o These algorithms can be used for complicated tasks compared to the
supervised ones because these algorithms work on the unlabeled dataset.
o Unsupervised algorithms are preferable for various tasks as getting the
unlabeled dataset is easier as compared to the labelled dataset.
Disadvantages:
o The output of an unsupervised algorithm can be less accurate as the
dataset is not labelled, and algorithms are not trained with the exact
output in prior.
o Working with Unsupervised learning is more difficult as it works with the
unlabelled dataset that does not map with the output.

Applications of Unsupervised Learning


o Network Analysis: Unsupervised learning is used for identifying
plagiarism and copyright in document network analysis of text data for
scholarly articles.
o Recommendation Systems: Recommendation systems widely use
unsupervised learning techniques for building recommendation
applications for different web applications and e-commerce websites.
o Anomaly Detection: Anomaly detection is a popular application of
unsupervised learning, which can identify unusual data points within the
dataset. It is used to discover fraudulent transactions.
o Singular Value Decomposition: Singular Value Decomposition or SVD
is used to extract particular information from the database. For example,
extracting information of each user located at a particular location.
3. Semi-Supervised Learning
Semi-Supervised learning is a type of Machine Learning algorithm that lies
between Supervised and Unsupervised machine learning. It represents the
intermediate ground between Supervised (With Labelled training data) and
Unsupervised learning (with no labelled training data) algorithms and uses the
combination of labelled and unlabeled datasets during the training period.
Although Semi-supervised learning is the middle ground between supervised
and unsupervised learning and operates on the data that consists of a few labels,
it mostly consists of unlabeled data. As labels are costly, but for corporate
purposes, they may have few labels. It is completely different from supervised
and unsupervised learning as they are based on the presence & absence of
labels.
To overcome the drawbacks of supervised learning and unsupervised
learning algorithms, the concept of Semi-supervised learning is introduced.
The main aim of semi-supervised learning is to effectively use all the available
data, rather than only labelled data like in supervised learning. Initially, similar
data is clustered along with an unsupervised learning algorithm, and further, it
helps to label the unlabeled data into labelled data. It is because labelled data is
a comparatively more expensive acquisition than unlabeled data.
We can imagine these algorithms with an example. Supervised learning is
where a student is under the supervision of an instructor at home and college.
Further, if that student is self-analysing the same concept without any help from
the instructor, it comes under unsupervised learning. Under semi-supervised
learning, the student has to revise himself after analyzing the same concept
under the guidance of an instructor at college.

Advantages:
o It is simple and easy to understand the algorithm.
o It is highly efficient.
o It is used to solve drawbacks of Supervised and Unsupervised Learning
algorithms.
Disadvantages:
o Iterations results may not be stable.
o We cannot apply these algorithms to network-level data.
o Accuracy is low.

4. Reinforcement Learning
Reinforcement learning works on a feedback-based process, in which an AI
agent (A software component) automatically explore its surrounding by
hitting & trail, taking action, learning from experiences, and improving its
performance. Agent gets rewarded for each good action and get punished for
each bad action; hence the goal of reinforcement learning agent is to maximize
the rewards.
In reinforcement learning, there is no labelled data like supervised learning, and
agents learn from their experiences only.
The reinforcement learning process is similar to a human being; for example, a
child learns various things by experiences in his day-to-day life. An example of
reinforcement learning is to play a game, where the Game is the environment,
moves of an agent at each step define states, and the goal of the agent is to get a
high score. Agent receives feedback in terms of punishment and rewards.
Due to its way of working, reinforcement learning is employed in different
fields such as Game theory, Operation Research, Information theory, multi-
agent systems.
A reinforcement learning problem can be formalized using Markov Decision
Process(MDP). In MDP, the agent constantly interacts with the environment
and performs actions; at each action, the environment responds and generates a
new state.

Categories of Reinforcement Learning


Reinforcement learning is categorized mainly into two types of
methods/algorithms:
o Positive Reinforcement Learning: Positive reinforcement learning
specifies increasing the tendency that the required behaviour would occur
again by adding something. It enhances the strength of the behaviour of
the agent and positively impacts it.
o Negative Reinforcement Learning: Negative reinforcement learning
works exactly opposite to the positive RL. It increases the tendency that
the specific behaviour would occur again by avoiding the negative
condition.

Real-world Use cases of Reinforcement Learning


o Video Games:
RL algorithms are much popular in gaming applications. It is used to gain
super-human performance. Some popular games that use RL algorithms
are AlphaGO and AlphaGO Zero.
o Resource Management:
The "Resource Management with Deep Reinforcement Learning" paper
showed that how to use RL in computer to automatically learn and
schedule resources to wait for different jobs in order to minimize average
job slowdown.
o Robotics:
RL is widely being used in Robotics applications. Robots are used in the
industrial and manufacturing area, and these robots are made more
powerful with reinforcement learning. There are different industries that
have their vision of building intelligent robots using AI and Machine
learning technology.
o Text Mining
Text-mining, one of the great applications of NLP, is now being
implemented with the help of Reinforcement Learning by Salesforce
company.

Advantages
o It helps in solving complex real-world problems which are difficult to be
solved by general techniques.
o The learning model of RL is similar to the learning of human beings;
hence most accurate results can be found.
o Helps in achieving long term results.
Disadvantage
o RL algorithms are not preferred for simple problems.
o RL algorithms require huge data and computations.
o Too much reinforcement learning can lead to an overload of states which
can weaken the results.

How Supervised Learning Works?


In supervised learning, models are trained using labelled dataset,
where the model learns about each type of data. Once the training
process is completed, the model is tested on the basis of test data
(a subset of the training set), and then it predicts the output.

The working of Supervised learning can be easily understood by the


below example and diagram:
Suppose we have a dataset of different types of shapes which
includes square, rectangle, triangle, and Polygon. Now the first step
is that we need to train the model for each shape.

o If the given shape has four sides, and all the sides are equal, then it
will be labelled as a Square.

o If the given shape has three sides, then it will be labelled as


a triangle.

o If the given shape has six equal sides then it will be labelled
as hexagon.
Now, after training, we test our model using the test set, and the
task of the model is to identify the shape.

The machine is already trained on all types of shapes, and when it


finds a new shape, it classifies the shape on the bases of a number
of sides, and predicts the output.

Steps Involved in Supervised Learning:


o First Determine the type of training dataset

o Collect/Gather the labelled training data.

o Split the training dataset into training dataset, test dataset, and
validation dataset.

o Determine the input features of the training dataset, which should


have enough knowledge so that the model can accurately predict
the output.

o Determine the suitable algorithm for the model, such as support


vector machine, decision tree, etc.

o Execute the algorithm on the training dataset. Sometimes we need


validation sets as the control parameters, which are the subset of
training datasets.

o Evaluate the accuracy of the model by providing the test set. If the
model predicts the correct output, which means our model is
accurate.

Types of supervised Machine learning Algorithms:


Supervised learning can be further divided into two types of
problems:
1. Regression

Regression algorithms are used if there is a relationship between the


input variable and the output variable. It is used for the prediction of
continuous variables, such as Weather forecasting, Market Trends,
etc. Below are some popular Regression algorithms which come
under supervised learning:

o Linear Regression

o Regression Trees

o Non-Linear Regression

o Bayesian Linear Regression

o Polynomial Regression
2. Classification

Classification algorithms are used when the output variable is


categorical, which means there are two classes such as Yes-No,
Male-Female, True-false, etc.

Spam Filtering,

o Random Forest

o Decision Trees

o Logistic Regression

o Support vector Machines

Note: We will discuss these algorithms in detail in later chapters.

Advantages of Supervised learning:


o With the help of supervised learning, the model can predict the
output on the basis of prior experiences.

o In supervised learning, we can have an exact idea about the classes


of objects.

o Supervised learning model helps us to solve various real-world


problems such as fraud detection, spam filtering, etc.

Disadvantages of supervised learning:


o Supervised learning models are not suitable for handling the
complex tasks.

o Supervised learning cannot predict the correct output if the test


data is different from the training dataset.

o Training required lots of computation times.

o In supervised learning, we need enough knowledge about the


classes of object.

Unsupervised Machine Learning


In the previous topic, we learned supervised machine learning in
which models are trained using labeled data under the supervision
of training data. But there may be many cases in which we do not
have labeled data and need to find the hidden patterns from the
given dataset. So, to solve such types of cases in machine learning,
we need unsupervised learning techniques.

What is Unsupervised Learning?


As the name suggests, unsupervised learning is a machine learning
technique in which models are not supervised using training
dataset. Instead, models itself find the hidden patterns and insights
from the given data. It can be compared to learning which takes
place in the human brain while learning new things. It can be
defined as:

Unsupervised learning is a type of machine learning in which models are


trained using unlabeled dataset and are allowed to act on that data
without any supervision.
Unsupervised learning cannot be directly applied to a regression or
classification problem because unlike supervised learning, we have
the input data but no corresponding output data. The goal of
unsupervised learning is to find the underlying structure of
dataset, group that data according to similarities, and
represent that dataset in a compressed format.

Example: Suppose the unsupervised learning algorithm is given an


input dataset containing images of different types of cats and dogs.
The algorithm is never trained upon the given dataset, which means
it does not have any idea about the features of the dataset. The task
of the unsupervised learning algorithm is to identify the image
features on their own. Unsupervised learning algorithm will perform
this task by clustering the image dataset into the groups according
to similarities between images.

Why use Unsupervised Learning?


Below are some main reasons which describe the importance of
Unsupervised Learning:

o Unsupervised learning is helpful for finding useful insights from the


data.

o Unsupervised learning is much similar as a human learns to think by


their own experiences, which makes it closer to the real AI.

o Unsupervised learning works on unlabeled and uncategorized data


which make unsupervised learning more important.

o In real-world, we do not always have input data with the


corresponding output so to solve such cases, we need unsupervised
learning.

Working of Unsupervised Learning


Working of unsupervised learning can be understood by the below
diagram:

Here, we have taken an unlabeled input data, which means it is not


categorized and corresponding outputs are also not given. Now, this
unlabeled input data is fed to the machine learning model in order
to train it. Firstly, it will interpret the raw data to find the hidden
patterns from the data and then will apply suitable algorithms such
as k-means clustering, Decision tree, etc.

Once it applies the suitable algorithm, the algorithm divides the data
objects into groups according to the similarities and difference
between the objects.

Types of Unsupervised Learning Algorithm:


The unsupervised learning algorithm can be further categorized into
two types of problems:
o Clustering: Clustering is a method of grouping the objects into
clusters such that objects with most similarities remains into a
group and has less or no similarities with the objects of another
group. Cluster analysis finds the commonalities between the data
objects and categorizes them as per the presence and absence of
those commonalities.

o Association: An association rule is an unsupervised learning


method which is used for finding the relationships between variables
in the large database. It determines the set of items that occurs
together in the dataset. Association rule makes marketing strategy
more effective. Such as people who buy X item (suppose a bread)
are also tend to purchase Y (Butter/Jam) item. A typical example of
Association rule is Market Basket Analysis.

Note: We will learn these algorithms in later chapters.

Unsupervised Learning algorithms:


Below is the list of some popular unsupervised learning algorithms:

o K-means clustering

o KNN (k-nearest neighbors)

o Hierarchal clustering

o Anomaly detection

o Neural Networks

o Principle Component Analysis

o Independent Component Analysis

o Apriori algorithm

o Singular value decomposition

Advantages of Unsupervised Learning


o Unsupervised learning is used for more complex tasks as compared
to supervised learning because, in unsupervised learning, we don't
have labeled input data.

o Unsupervised learning is preferable as it is easy to get unlabeled


data in comparison to labeled data.
Disadvantages of Unsupervised Learning
o Unsupervised learning is intrinsically more difficult than supervised
learning as it does not have corresponding output.

o The result of the unsupervised learning algorithm might be less


accurate as input data is not labeled, and algorithms do not know
the exact output in advance.

Machine learning Life cycle


Machine learning has given the computer systems the abilities
to automatically learn without being explicitly programmed. But
how does a machine learning system work? So, it can be
described using the life cycle of machine learning. Machine
learning life cycle is a cyclic process to build an efficient
machine learning project. The main purpose of the life cycle is
to find a solution to the problem or project.
Machine learning life cycle involves seven major steps, which
are given below:
o Gathering Data
o Data preparation
o Data Wrangling
o Analyse Data
o Train the model
o Test the model
o Deployment
The most important thing in the complete process is to
understand the problem and to know the purpose of the
problem. Therefore, before starting the life cycle, we need to
understand the problem because the good result depends on
the better understanding of the problem.
In the complete life cycle process, to solve a problem, we
create a machine learning system called "model", and this
model is created by providing "training". But to train a model,
we need data, hence, life cycle starts by collecting data.

1. Gathering Data:
Data Gathering is the first step of the machine learning life
cycle. The goal of this step is to identify and obtain all data-
related problems.
In this step, we need to identify the different data sources, as
data can be collected from various sources such
as files, database, internet, or mobile devices. It is one of
the most important steps of the life cycle. The quantity and
quality of the collected data will determine the efficiency of the
output. The more will be the data, the more accurate will be the
prediction.
This step includes the below tasks:

o Identify various data sources


o Collect data
o Integrate the data obtained from different sources
By performing the above task, we get a coherent set of data,
also called as a dataset. It will be used in further steps.

2. Data preparation
After collecting the data, we need to prepare it for further
steps. Data preparation is a step where we put our data into a
suitable place and prepare it to use in our machine learning
training.
In this step, first, we put all data together, and then randomize
the ordering of data.
This step can be further divided into two processes:
o Data exploration:
It is used to understand the nature of data that we have to
work with. We need to understand the characteristics,
format, and quality of data.
A better understanding of data leads to an effective
outcome. In this, we find Correlations, general trends, and
outliers.
o Data pre-processing:
Now the next step is preprocessing of data for its analysis.

3. Data Wrangling
Data wrangling is the process of cleaning and converting raw
data into a useable format. It is the process of cleaning the
data, selecting the variable to use, and transforming the data in
a proper format to make it more suitable for analysis in the
next step. It is one of the most important steps of the complete
process. Cleaning of data is required to address the quality
issues.
It is not necessary that data we have collected is always of our
use as some of the data may not be useful. In real-world
applications, collected data may have various issues, including:
o Missing Values
o Duplicate data
o Invalid data
o Noise
So, we use various filtering techniques to clean the data.
It is mandatory to detect and remove the above issues because
it can negatively affect the quality of the outcome.

4. Data Analysis
Now the cleaned and prepared data is passed on to the analysis
step. This step involves:
o Selection of analytical techniques
o Building models
o Review the result
The aim of this step is to build a machine learning model to
analyze the data using various analytical techniques and review
the outcome. It starts with the determination of the type of the
problems, where we select the machine learning techniques
such as Classification, Regression, Cluster
analysis, Association, etc. then build the model using
prepared data, and evaluate the model.
Hence, in this step, we take the data and use machine learning
algorithms to build the model.

5. Train Model
Now the next step is to train the model, in this step we train our
model to improve its performance for better outcome of the
problem.
We use datasets to train the model using various machine
learning algorithms. Training a model is required so that it can
understand the various patterns, rules, and, features.

6. Test Model
Once our machine learning model has been trained on a given
dataset, then we test the model. In this step, we check for the
accuracy of our model by providing a test dataset to it.

Testing the model determines the percentage accuracy of the


model as per the requirement of project or problem.

7. Deployment
The last step of machine learning life cycle is deployment,
where we deploy the model in the real-world system.
If the above-prepared model is producing an accurate result as
per our requirement with acceptable speed, then we deploy the
model in the real system. But before deploying the project, we
will check whether it is improving its performance using
available data or not. The deployment phase is similar to
making the final report for a project.

Data Preprocessing in Machine learning


Data preprocessing is a process of preparing the raw data and
making it suitable for a machine learning model. It is the first
and crucial step while creating a machine learning model.
When creating a machine learning project, it is not always a
case that we come across the clean and formatted data. And
while doing any operation with data, it is mandatory to clean it
and put in a formatted way. So for this, we use data
preprocessing task.
Why do we need Data Preprocessing?
A real-world data generally contains noises, missing values, and
maybe in an unusable format which cannot be directly used for
machine learning models. Data preprocessing is required tasks
for cleaning the data and making it suitable for a machine
learning model which also increases the accuracy and
efficiency of a machine learning model.
It involves below steps:
o Getting the dataset
o Importing libraries
o Importing datasets
o Finding Missing Data
o Encoding Categorical Data
o Splitting dataset into training and test set
o Feature scaling

1) Get the Dataset


To create a machine learning model, the first thing we required
is a dataset as a machine learning model completely works on
data. The collected data for a particular problem in a proper
format is known as the dataset.
Dataset may be of different formats for different purposes, such
as, if we want to create a machine learning model for business
purpose, then dataset will be different with the dataset
required for a liver patient. So each dataset is different from
another dataset. To use the dataset in our code, we usually put
it into a CSV file. However, sometimes, we may also need to
use an HTML or xlsx file.
2) Importing Libraries
In order to perform data preprocessing using Python, we need
to import some predefined Python libraries. These libraries are
used to perform some specific jobs. There are three specific
libraries that we will use for data preprocessing, which are:
Numpy: Numpy Python library is used for including any type of
mathematical operation in the code. It is the fundamental
package for scientific calculation in Python. It also supports to
add large, multidimensional arrays and matrices. So, in Python,
we can import it as:
1. import numpy as nm
Here we have used nm, which is a short name for Numpy, and
it will be used in the whole program.
Matplotlib: The second library is matplotlib, which is a
Python 2D plotting library, and with this library, we need to
import a sub-library pyplot. This library is used to plot any type
of charts in Python for the code. It will be imported as below:
1. import [Link] as mpt
Here we have used mpt as a short name for this library.
Pandas: The last library is the Pandas library, which is one of
the most famous Python libraries and used for importing and
managing the datasets. It is an open-source data manipulation
and analysis library. It will be imported as below:
Here, we have used pd as a short name for this library.
Consider the below image:

3) Importing the Datasets


Now we need to import the datasets which we have collected
for our machine learning project. But before importing a
dataset, we need to set the current directory as a working
directory. To set a working directory in Spyder IDE, we need to
follow the below steps:
1. Save your Python file in the directory which contains
dataset.
2. Go to File explorer option in Spyder IDE, and select the
required directory.
3. Click on F5 button or run option to execute the file.
Note: We can set any directory as a working directory, but it
must contain the required dataset.
Here, in the below image, we can see the Python file along with
required dataset. Now, the current folder is set as a working
directory.
read_csv() function:
Now to import the dataset, we will useread_csv() function of
pandas library, which is used to read acsvfile and performs
various operations on it. Using this function, we can read a csv
file locally as well as through an URL.
We can use read_csv function as below:
1. data_set= pd.read_csv('[Link]')
Here, data_set is a name of the variable to store our dataset,
and inside the function, we have passed the name of our
dataset. Once we execute the above line of code, it will
successfully import the dataset in our code. We can also check
the imported dataset by clicking on the section variable
explorer, and then double click on data_set. Consider the
below image:
As in the above image, indexing is started from 0, which is the
default indexing in Python. We can also change the format of
our dataset by clicking on the format option.

Ways to handle missing data:


There are mainly two ways to handle missing data, which are:
By deleting the particular row: The first way is used to
commonly deal with null values. In this way, we just delete the
specific row or column which consists of null values. But this
way is not so efficient and removing data may lead to loss of
information which will not give the accurate output.
By calculating the mean: In this way, we will calculate the
mean of that column or row which contains any missing value
and will put it on the place of missing value. This strategy is
useful for the features which have numeric data such as age,
salary, year, etc. Here, we will use this approach.
To handle missing values, we will use Scikit-learn library in
our code, which contains various libraries for building machine
learning models.

Training Set: A subset of dataset to train the machine


learning model, and we already know the output.
Test set: A subset of dataset to test the machine learning
model, and by using the test set, model predicts the output.
7) Feature Scaling
Feature scaling is the final step of data preprocessing in
machine learning. It is a technique to standardize the
independent variables of the dataset in a specific range. In
feature scaling, we put our variables in the same range and in
the same scale so that no any variable dominate the other
variable.
Consider the below dataset:

As we can see, the age and salary column values are not on the
same scale. A machine learning model is based on Euclidean
distance, and if we do not scale the variable, then it will cause
some issue in our machine learning model.

What is Test Dataset?


Once we train the model with the training dataset, it's time to
test the model with the test dataset. This dataset evaluates the
performance of the model and ensures that the model can
generalize well with the new or unseen dataset. The test
dataset is another subset of original data, which is
independent of the training dataset. However, it has some
similar types of features and class probability distribution and
uses it as a benchmark for model evaluation once the model
training is completed. Test data is a well-organized dataset that
contains data for each type of scenario for a given problem that
the model would be facing when used in the real world. Usually,
the test dataset is approximately 20-25% of the total original
data for an ML project.
At this stage, we can also check and compare the testing
accuracy with the training accuracy, which means how accurate
our model is with the test dataset against the training dataset.
If the accuracy of the model on training data is greater than
that on testing data, then the model is said to have overfitting.
The testing data should:
o Represent or part of the original dataset.
o It should be large enough to give meaningful predictions.
Need of Splitting dataset into Train and Test set
Splitting the dataset into train and test sets is one of the
important parts of data pre-processing, as by doing so, we can
improve the performance of our model and hence give better
predictability.
We can understand it as if we train our model with a training
set and then test it with a completely different test dataset, and
then our model will not be able to understand the correlations
between the features.

Therefore, if we train and test the model with two different


datasets, then it will decrease the performance of the model.
Hence it is important to split a dataset into two parts, i.e., train
and test set.
In this way, we can easily evaluate the performance of our
model. Such as, if it performs well with the training data, but
does not perform well with the test dataset, then it is estimated
that the model may be overfitted.

Traits of Quality training data


As the ability to the prediction of an ML model highly depends
on how it has been trained, therefore it is important to train the
model with quality data. Further, ML works on the concept of
"Garbage In, Garbage Out." It means that whatever type of
data we will input into our model, it will make the predictions
accordingly. For a quality training data, the below points should
be considered:
1. Relevant

The very first quality of training data should be relevant to the


problem that you are going to solve. It means that whatever
data you are using should be relevant to the current problem.
For example, if you are building a model to analyze social
media data, then data should be taken from different social
sites such as Twitter, Facebook, Instagram, etc.
2. Uniform:
There should always be uniformity among the features of a
dataset. It means all data for a particular problem should be
taken from the same source with the same attributes.
3. Consistency: In the dataset, the similar attributes must
always correspond to the similar label in order to ensure
uniformity in the dataset.
4. Comprehensive: The training data must be large enough to
represent sufficient features that you need to train the model in
a better way. With a comprehensive dataset, the model will be
able to learn all the edge cases.

Conclusion
Good training data is the backbone of machine learning. It is
crucial to understand the importance of good training data in
Machine Learning, as it ensures that you have data with the
right quality and quantity to train your model.
The main difference between training data and testing data is
that training data is the subset of original data that is used to
train the machine learning model, whereas testing data is used
to check the accuracy of the model.

 Importance of Choosing the Positive Class:


The choice of which class is the positive class can impact how
performance metrics like precision and recall are interpreted.
 Confusion Matrix:
This tool is used to evaluate the performance of a binary
classification model by showing the counts of true positives
(TP), true negatives (TN), false positives (FP), and false
negatives (FN).
 True Positive (TP):
The model correctly predicts the positive class.
 True Negative (TN):
The model correctly predicts the negative class.
 False Positive (FP):
The model incorrectly predicts the positive class when it's
actually negative (Type 1 error).
 False Negative (FN):
The model incorrectly predicts the negative class when it's
actually positive (Type 2 error).

What is Cross Validation?


Cross-Validation is a resampling technique with the
fundamental idea of splitting the dataset into 2 parts- training
data and test data. Train data is used to train the model and
the unseen test data is used for prediction. If the model
performs well over the test data and gives good accuracy, it
means the model hasn’t overfitted the training data and can be
used for prediction.

You might also like