Download as pdf or txt
Download as pdf or txt
You are on page 1of 57

FML(4341603)

Unit-1
Unit – I
Introduction to machine learning
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.
 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

#(FML)  Unit 1 – Introduction to Machine Learning 2


Types of Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 3


Types of Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 4


Supervised Machine Learning

 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.

#(FML)  Unit 1 – Introduction to Machine Learning 5


Supervised Machine Learning
 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.
#(FML)  Unit 1 – Introduction to Machine Learning 6
Supervised Machine 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


1. Classification
2. Regression

#(FML)  Unit 1 – Introduction to Machine Learning 7


Supervised Machine Learning Categories:
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:


1. Random Forest Algorithm
2. Decision Tree Algorithm
3. Logistic Regression Algorithm
4. Support Vector Machine Algorithm
#(FML)  Unit 1 – Introduction to Machine Learning 8
Supervised Machine Learning Categories:
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:
1. Simple Linear Regression Algorithm
2. Multivariate Regression Algorithm
3. Decision Tree Algorithm
4. Lasso Regression

#(FML)  Unit 1 – Introduction to Machine Learning 9


Supervised Machine Learning
 Advantages:
 Since supervised learning work with the labelled dataset so we can
have an exact idea about the classes of objects.
 These algorithms are helpful in predicting the output on the basis of
prior experience.

#(FML)  Unit 1 – Introduction to Machine Learning 10


Supervised Machine Learning
 Disadvantages:
 These algorithms are not able to solve complex tasks.
 It may predict the wrong output if the test data is different from the
training data.
 It requires lots of computational time to train the algorithm.

#(FML)  Unit 1 – Introduction to Machine Learning 11


Applications of Supervised Machine Learning
 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.

 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.

#(FML)  Unit 1 – Introduction to Machine Learning 12


Applications of Supervised Machine Learning
 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.
 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.
 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.
#(FML)  Unit 1 – Introduction to Machine Learning 13
Unsupervised Machine Learning
 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.
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 14


Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 15


Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 16


Unsupervised Machine Learning
 Example:

#(FML)  Unit 1 – Introduction to Machine Learning 17


Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 18


Why to use Unsupervised Machine Learning?
 Unsupervised learning is helpful for finding useful insights from the
data.
 Unsupervised learning is much similar as a human learns to think by
their own experiences, which makes it closer to the real AI.
 Unsupervised learning works on unlabeled and uncategorized data
which make unsupervised learning more important.
 In real-world, we do not always have input data with the corresponding
output so to solve such cases, we need unsupervised learning.

#(FML)  Unit 1 – Introduction to Machine Learning 19


Working of Unsupervised Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 20


Working of Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 21


Types of Unsupervised Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 22


Clustering in Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 23


Association in Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 24


Association in Unsupervised Machine Learning
 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.

#(FML)  Unit 1 – Introduction to Machine Learning 25


Popular Unsupervised Machine Learning Algorithms
 K-means clustering
 KNN (k-nearest neighbors)
 Hierarchal clustering
 Anomaly detection
 Neural Networks
 Principle Component Analysis
 Independent Component Analysis
 Apriori algorithm
 Singular value decomposition
#(FML)  Unit 1 – Introduction to Machine Learning 26
Advantages of Unsupervised Machine Learning Algorithms
 Unsupervised learning is used for more complex tasks as compared to
supervised learning because, in unsupervised learning, we don't have
labeled input data.

 Unsupervised learning is preferable as it is easy to get unlabeled data


in comparison to labeled data.

#(FML)  Unit 1 – Introduction to Machine Learning 27


Applications of Unsupervised Machine Learning Algorithms
1. Clustering: the process of grouping the given data into different
clusters or groups.
2. Visualization: the process of creating diagrams, images, graphs,
charts, etc., to communicate some information.
3. Dimensionality Reduction: the process of reducing the number of
random variables under consideration by getting a set of principal
variables.
4. Association Rules: the process of finding associations between
different parameters in the available data.
5. Anomaly Detection: the identification of rare items, events, or
observations, which brings suspicions by differing significantly from
the normal data. #(FML)  Unit 1 – Introduction to Machine Learning 28
Real World Applications of Unsupervised Machine Learning Algorithms

 Unsupervised learning can be used to do clustering when we don’t


know exactly the information about the clusters.

 It is used for analyzing and grouping data, which does not include pre-
labeled classes or class attributes. Clustering can be helpful for
businesses to manage their data in a better way.

#(FML)  Unit 1 – Introduction to Machine Learning 29


Real World Applications of Unsupervised Machine Learning Algorithms

 For example, you can go to Walmart or a supermarket and see how


different items are grouped and arranged there.

#(FML)  Unit 1 – Introduction to Machine Learning 30


Real World Applications of Unsupervised Machine Learning Algorithms

 Also, e-commerce websites like Amazon use clustering algorithms to


implement a user-specific recommendation system.
 Another example. Let’s say you have a YouTube channel. You may
have a lot of data about the subscribers of your channel. If you want to
detect groups of similar subscribers, then you may need to run a
clustering algorithm.
 You don’t need to tell the algorithm which group a subscriber belongs
to. The algorithm can find those connections without your help.
 For example, it may tell you that 35% of your subscribers are from
Canada, while 20% of them are from the United States.

#(FML)  Unit 1 – Introduction to Machine Learning 31


SemiSupervised Machine Learning
 Semi-Supervised learning is a type of Machine Learning algorithm that
represents the intermediate ground between Supervised and
Unsupervised learning algorithms. It uses the combination of labeled
and unlabeled datasets during the training period.

 The basic disadvantage of supervised learning is that it requires hand-


labeling by ML specialists or data scientists, and it also requires a high
cost to process. Further unsupervised learning also has a limited
spectrum for its applications. To overcome these drawbacks of
supervised learning and unsupervised learning algorithms, the
concept of Semi-supervised learning is introduced.
#(FML)  Unit 1 – Introduction to Machine Learning 32
SemiSupervised Machine Learning
 In this algorithm, training data is a combination of both labeled and
unlabeled data. However, labeled data exists with a very small amount
while it consists of a huge amount of unlabeled data. Initially, similar
data is clustered along with an unsupervised learning algorithm, and
further, it helps to label the unlabeled data into labeled data. It is why
label data is a comparatively, more expensive acquisition than
unlabeled data.

#(FML)  Unit 1 – Introduction to Machine Learning 33


SemiSupervised Machine Learning Example
 Supervised learning is where a student is under the supervision of an
instructor at home and college. Further, if that student is self-analyzing
the same concept without any help from the instructor, it comes under
unsupervised learning. Under semi-supervised learning, the student
has to revise itself after analyzing the same concept under the
guidance of an instructor at college.

#(FML)  Unit 1 – Introduction to Machine Learning 34


Working of SemiSupervised Machine Learning
 Firstly, it trains the model with less amount of training data similar to
the supervised learning models. The training continues until the model
gives accurate results.
 The algorithms use the unlabeled dataset with pseudo labels in the
next step, and now the result may not be accurate.
 Now, the labels from labeled training data and pseudo labels data are
linked together.
 The input data in labeled training data and unlabeled training data are
also linked.
 In the end, again train the model with the new combined input as did in
the first step. It will reduce errors and improve the accuracy of the
model. #(FML)  Unit 1 – Introduction to Machine Learning 35
Real Worls Applications of SemiSupervised Machine Learning
 Speech Analysis- It is the most classic example of semi-supervised
learning applications. Since, labeling the audio data is the most
impassable task that requires many human resources, this problem
can be naturally overcome with the help of applying SSL in a Semi-
supervised learning model.
 Web content classification- However, this is very critical and
impossible to label each page on the internet because it needs mode
human intervention. Still, this problem can be reduced through Semi-
Supervised learning algorithms.
Further, Google also uses semi-supervised learning algorithms to rank
a webpage for a given query.
#(FML)  Unit 1 – Introduction to Machine Learning 36
Real Worls Applications of SemiSupervised Machine Learning
 Protein sequence classification- DNA strands are larger, they require
active human intervention. So, the rise of the Semi-supervised model
has been proximate in this field.
 Text document classifier- As we know, it would be very unfeasible to
find a large amount of labeled text data, so semi-supervised learning is
an ideal model to overcome this.

#(FML)  Unit 1 – Introduction to Machine Learning 37


Reinforcement Machine Learning
 Reinforcement Learning is a feedback-based Machine learning
technique in which an agent learns to behave in an environment by
performing the actions.
 For each good action, the agent gets positive feedback, and for each
bad action, the agent gets negative feedback or penalty.
 In Reinforcement Learning, the agent learns automatically using
feedbacks without any labeled data (Non-Labeled Data).
 Since there is no labeled data, so the agent is bound to learn by its
experience only.

#(FML)  Unit 1 – Introduction to Machine Learning 38


Important Terms Used in Reinforcement Machine Learning
 Agent(): An entity that can perceive/explore the environment and act
upon it.
 Environment(): A situation in which an agent is present or surrounded
by. In RL, we assume the stochastic environment, which means it is
random in nature.
 Action(): Actions are the moves taken by an agent within the
environment.
 State(): State is a situation returned by the environment after each
action taken by the agent.

#(FML)  Unit 1 – Introduction to Machine Learning 39


Important Terms Used in Reinforcement Machine Learning
 Reward(): A feedback returned to the agent from the environment to
evaluate the action of the agent.
 Policy(): Policy is a strategy applied by the agent for the next action
based on the current state.
 Value(): It is expected long-term reward with the discount factor and
opposite to the short-term reward.
 Q-value(): It is mostly similar to the value, but it takes one additional
parameter a current action (a).

#(FML)  Unit 1 – Introduction to Machine Learning 40


Reinforcement Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 41


Reinforcement Machine Learning
 The agent learns with the process of hit and trial, and based on the
experience, it learns to perform the task in a better way.

 "Reinforcement learning is a type of machine learning method where


an intelligent agent (computer program) interacts with the
environment and learns to act within that."

 e.g. How a Robotic dog learns the movement of his arms is an


example of Reinforcement learning.

#(FML)  Unit 1 – Introduction to Machine Learning 42


Reinforcement Machine Learning
 It is a core part of Artificial intelligence, and all AI agent works on the
concept of reinforcement learning. Here we do not need to pre-
program the agent, as it learns from its own experience without any
human intervention.
 Example: Suppose there is an AI agent present within a maze
environment, and his goal is to find the diamond. The agent interacts
with the environment by performing some actions, and based on those
actions, the state of the agent gets changed, and it also receives a
reward or penalty as feedback.
 The agent continues doing these three things (take action, change
state/remain in the same state, and get feedback), and by doing these
actions, he learns and explores the environment.
#(FML)  Unit 1 – Introduction to Machine Learning 43
Reinforcement Machine Learning
 Example: Suppose there is an AI agent present within a maze
environment, and his goal is to find the diamond. The agent interacts
with the environment by performing some actions, and based on those
actions, the state of the agent gets changed, and it also receives a
reward or penalty as feedback.
 The agent continues doing these three things (take action, change
state/remain in the same state, and get feedback), and by doing these
actions, he learns and explores the environment.
 The agent learns that what actions lead to positive feedback or
rewards and what actions lead to negative feedback penalty. As a
positive reward, the agent gets a positive point, and as a penalty, it
gets a negative point.
#(FML)  Unit 1 – Introduction to Machine Learning 44
Key Features of Reinforcement Machine Learning
 In RL, the agent is not instructed about the environment and what
actions need to be taken.
 It is based on the hit and trial process.
 The agent takes the next action and changes states according to the
feedback of the previous action.
 The agent may get a delayed reward.
 The environment is stochastic, and the agent needs to explore it to
reach to get the maximum positive rewards.

#(FML)  Unit 1 – Introduction to Machine Learning 45


Approaches to implement Reinforcement Learning
1. Value-based:
 The value-based approach is about to find the optimal value function,
which is the maximum value at a state under any policy. Therefore, the
agent expects the long-term return at any state(s) under policy π.

#(FML)  Unit 1 – Introduction to Machine Learning 46


Approaches to implement Reinforcement Learning
2. Policy-based:
 Policy-based approach is to find the optimal policy for the maximum
future rewards without using the value function. In this approach, the
agent tries to apply such a policy that the action performed in each
step helps to maximize the future reward.
 The policy-based approach has mainly two types of policy:
oDeterministic: The same action is produced by the policy (π) at any
state.
oStochastic: In this policy, probability determines the produced action.

#(FML)  Unit 1 – Introduction to Machine Learning 47


Approaches to implement Reinforcement Learning
3. Model-based: In the model-based approach, a virtual model is created
for the environment, and the agent explores that environment to learn
it. There is no particular solution or algorithm for this approach
because the model representation is different for each environment.

#(FML)  Unit 1 – Introduction to Machine Learning 48


Working of Reinforcement Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 49


Applications of Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 50


Tools & Technologies for Machine Learning

#(FML)  Unit 1 – Introduction to Machine Learning 51


1.TensorFlow for Machine Learning
 TensorFlow is one of the most popular open-source libraries used to
train and build both machine learning and deep learning models. It
provides a JS library and was developed by Google Brain Team. It is
much popular among machine learning enthusiasts, and they use it for
building different ML applications. It offers a powerful library, tools,
and resources for numerical computation, specifically for large scale
machine learning and deep learning projects.

 For training and building the ML models, TensorFlow provides a high-


level Keras API, which lets users easily start with TensorFlow and
machine learning.
#(FML)  Unit 1 – Introduction to Machine Learning 52
2.PyTorch for Machine Learning
 PyTorch is an open-source machine learning framework, which is
based on the Torch library. This framework is free and open-source
and developed by FAIR(Facebook's AI Research lab).

 It is one of the popular ML frameworks, which can be used for various


applications, including computer vision and natural language
processing. PyTorch has Python and C++ interfaces; however, the
Python interface is more interactive. Different deep learning software
is made up on top of PyTorch, such as PyTorch Lightning, Hugging
Face's Transformers, Tesla autopilot, etc.

#(FML)  Unit 1 – Introduction to Machine Learning 53


3.Google Cloud ML Engine for Machine Learning
 While training a classifier with a huge amount of data, a computer
system might not perform well. However, various machine learning or
deep learning projects requires millions or billions of training datasets.
Or the algorithm that is being used is taking a long time for execution.
In such a case, one should go for the Google Cloud ML Engine. It is a
hosted platform where ML developers and data scientists build and
run optimum quality machine, learning models. It provides a managed
service that allows developers to easily create ML models with any
type of data and of any size.

#(FML)  Unit 1 – Introduction to Machine Learning 54


4. Amazon Machine Learning (AML) for Machine Learning
 Amazon provides a great number of machine learning tools, and one of
them is Amazon Machine Learning or AML. Amazon Machine Learning
(AML) is a cloud-based and robust machine learning software
application, which is widely used for building machine learning models
and making predictions. Moreover, it integrates data from multiple
sources, including Redshift, Amazon S3, or RDS.

#(FML)  Unit 1 – Introduction to Machine Learning 55


5. Accord.Net for Machine Learning
 Accord.Net is .Net based Machine Learning framework, which is used
for scientific computing. It is combined with audio and image
processing libraries that are written in C#. This framework provides
different libraries for various applications in ML, such as Pattern
Recognition, linear algebra, Statistical Data processing. One popular
package of the Accord.Net framework is Accord. Statistics,
Accord.Math, and Accord.MachineLearning.

#(FML)  Unit 1 – Introduction to Machine Learning 56


Software Engineering (3150711)

Thank
You

You might also like