You are on page 1of 48

21-03-2022

Fundamental
Theories
behind ML

Fundamental theories
behind Machine
Learning

1
21-03-2022

The Analytical Engine weaves algebraic


patterns just as the Jaquard weaves
flowers and leaves
— Ada Lovelace

Its Maths everywhere

• Ada Lovelace, one of the founders of


computing, and perhaps the first computer
programmer, realized that anything in the
world could be described with math.

• More importantly, this meant a


mathematical formula can be created to
derive the relationship representing any
phenomenon.

• Ada Lovelace realized that machines had


the potential to understand the world
without the need for human assistance.

2
21-03-2022

Its Maths everywhere


• Around 200 years later, these fundamental
ideas are critical in Machine Learning.

• No matter what the problem is, it’s


information can be plotted onto a graph
as data points.

• Machine Learning then tries to find the


mathematical patterns and relationships
hidden within the original information.

Probability is orderly opinion… inference from data


is nothing other than the revision of such opinion in
the light of relevant new information
— Thomas Bayes

Thomas Bayes, founded ideas that are essential in the probability theory that is manifested into Machine Learning.

3
21-03-2022

Probability Theory
• We live in a probabilistic world.
Everything that happens has
uncertainty attached to it.
• The Bayesian interpretation of
probability is what Machine Learning is
based upon.
• Bayesian probability means that we
think of probability as quantifying the
uncertainty of an event.

Probability Theory
• We have to base our probabilities on the
information available about an event,
rather than counting the number of
repeated trials.
• For example, when predicting a football
match, instead of counting the total
amount of times Manchester United
have won against Liverpool, a Bayesian
approach would use relevant
information such as the current form,
league placing and starting team.
• The benefit of taking this approach is that
probabilities can still be assigned to rare
events, as the decision-making process is
based on relevant features and reasoning.

4
21-03-2022

10

5
21-03-2022

Plan for today!

11

Introduction to
Supervised
Learning

12

6
21-03-2022

Supervised learning
• Like human learning from past experiences.
• A computer does not have “experiences”.
• A computer system learns from data, which
represent some “past experiences” of an
application domain.
• Our focus: learn a target function that can be
used to predict the values of a discrete class
attribute, e.g., approve or not-approved, and
high-risk or low risk.
• The task is commonly called: Supervised
learning, classification, or inductive learning.

13

13

Supervised Learning
• In Supervised learning, you train the
machine using data which is
well "labelled." It means some data is
already tagged with the correct answer. It
can be compared to learning which takes
place in the presence of a supervisor or a
teacher.
• A supervised learning algorithm learns
from labelled training data, helps you to
predict outcomes for unforeseen data.

14

7
21-03-2022

Supervised Learning
• Here the human experts acts as the teacher
where we feed the computer with training
data containing the input/predictors and we
show it the correct answers (output) and from
the data the computer should be able to learn
the patterns.
• Supervised learning algorithms try to model
relationships and dependencies between the
target prediction output and the input
features such that we can predict the output
values for new data based on those
relationships which it learned from the
previous data sets.

15

Supervised learning
• Supervised learning is the machine
learning task of determining a function
from labeled data.
• For example, in a machine learning
algorithm that detects if a post is spam
or not, the training set would include
posts labeled as "spam" and posts
labeled as "not spam" to help teach the
algorithm how to recognize the
difference.

16

16

8
21-03-2022

Supervised learning
• Supervised learning algorithms infer a function from
labeled data and use this function on new examples.
• Since the algorithm receives a data set as input that
already has a correct answer associated with it, the
algorithm will learn by comparing its output with the
correct answer, and if it finds errors, it adjusts the model
accordingly.
• The training continues until the algorithm outputs
information within the desired accuracy range.
• The most widely used supervised learning algorithms
are
• support vector machines, linear regression, logistic
regression, k-nearest-neighbors, and neural
networks.
• Supervised learning is commonly used in situations
where historical data predicts likely future events.
17

17

How Supervised ML works

18

9
21-03-2022

19

20

10
21-03-2022

How Supervised
Learning Works
• For example, you want to train a machine to help you
predict how long it will take you to drive home from
your workplace. Here, you start by creating a set of
labelled data. This data includes
• Weather conditions
• Time of the day
• Holidays
• All these details are your inputs. The output is the
amount of time it took to drive back home on that
specific day.
• You instinctively know that if it's raining outside, then
it will take you longer to drive home. But the machine
needs data and statistics.

21

The first thing you require to create is a training set.


• This training set will contain the total commute time and
corresponding factors like weather, time, etc.
• Based on this training set, your machine might see there's a direct
relationship between the amount of rain and time you will take to
get home.
Lets develop • So, it ascertains that the more it rains, the longer you will be driving
to get back to your home. It might also see the connection between
a ML model the time you leave work and the time you'll be on the road.
• The closer you're to 6 p.m. the longer it takes for you to get home.
for this Your machine may find some of the relationships with your labelled
data.
example

22

11
21-03-2022

Supervised learning
process: Two steps

• Learning (training): Learn a model using the


training data
• Testing: Test the model using unseen test data
to assess the model accuracy

Number of correct classifications


Accuracy = ,
Total number of test cases

23

23

24

12
21-03-2022

Deep dive into


Supervised
Learning

25

Types of Supervised Learning

26

13
21-03-2022

• Classification means to group the output


inside a class.
• If the algorithm tries to label input into two
distinct classes, it is called binary
Classification classification.
• Selecting between more than two classes is
referred to as multiclass classification.
• Example: Determining whether or not
someone will be a defaulter of the loan.

27

• It is a dataset of a shopping store which is useful in predicting


whether a customer will purchase a particular product under
consideration or not based on his/ her gender, age and salary.
• Input : Gender, Age, Salary
• Output : Purchased i.e. 0 or 1 ; 1 means yes the customer will
purchase and 0 means that customer won’t purchase it.

Classification

28

14
21-03-2022

Regression

• Regression technique predicts a single output


value using training data.
• Example: You can use regression to predict the
house price from training data. The input
variables will be locality, size of a house, etc.

29

• It is a Meteorological dataset which serves the purpose of


predicting wind speed based on different parameters.
• Input : Dew Point, Temperature, Pressure, Relative Humidity,
Wind Direction
• Output : Wind Speed

Regression

30

15
21-03-2022

Classification
vs
Regression

31

36

16
21-03-2022

Practical
Examples of
Supervised
Learning

37

Practical examples of
Supervised Learning

38

17
21-03-2022

Ex 1: Hospital bed
allocation
• An emergency room in a hospital
measures 17 variables (e.g., blood
pressure, age, etc.) of newly admitted
patients.
• A decision is needed: whether to put a
new patient in an intensive-care unit.
• Due to the high cost of ICU, those
patients who may survive less than a
month are given higher priority.
• Problem: to predict high-risk patients
and discriminate them from low-risk
patients.

39

Ex 2: Credit Card Approval


• A credit card company receives thousands of applications
for new cards. Each application contains information about
an applicant,
• age
• Marital status
• annual salary
• outstanding debts
• credit rating
• etc.
• Problem: to decide whether an application should
approved, or to classify applications into two categories,
approved and not approved.

40

40

18
21-03-2022

Approved or not

An example:
data (loan
application)

41

41

An example: the
learning task
• Learn a classification model from the
data
• Use the model to classify future loan
applications into
• Yes (approved) and
• No (not approved)
• What is the class for following
case/instance?

42

42

19
21-03-2022

Ex 3: Spam filtering of
emails
• We all use Gmail, Yahoo, or Outlook.
Machine learning algorithms are used
for deciding which email is spam and
which is not.
• Based on the previous data like received
emails, data that we use etc., the
system makes predictions about an
email as for whether it is a spam or not.
• These predictions may not be perfect,
but they are accurate most of the times.

43

43

44

20
21-03-2022

47

Introduction to
Unsupervised
Learning

48

21
21-03-2022

Unsupervised Learning
• Unsupervised learning is a machine learning technique, where
you do not need to supervise the model. Instead, you need to
allow the model to work on its own to discover information.

• It mainly deals with the unlabelled data.

• Unsupervised learning algorithms allows you to perform more


complex processing tasks compared to supervised learning.

• Although, unsupervised learning can be more unpredictable


compared with other natural learning methods.

49

Example of • Let's, take the case of a baby and her family dog.

Unsupervised • She knows and identifies this dog. Few weeks later a family
Machine Learning friend brings along a dog and tries to play with the baby.

50

22
21-03-2022

Example of Unsupervised
Machine Learning
• Baby has not seen this dog earlier. But it
recognizes many features (2 ears, eyes, walking
on 4 legs) are like her pet dog.

• She identifies the new animal as a dog. This is


unsupervised learning, where you are not taught
but you learn from the data (in this case data
about a dog.)

• Had this been supervised learning, the family


friend would have told the baby that it's a dog.

51

Puppy or
Muffin?
Progress in
Image
Recognition

52

52

23
21-03-2022

Unsupervised machine learning finds all kind


of unknown patterns in data.

Why Unsupervised methods help you to find


features which can be useful for
Unsupervised categorization.

learning? It has taken place in real time, so all the


input data to be analysed and labelled in the
presence of learners.

It is easier to get unlabelled data from a


computer than labelled data, which needs
manual intervention.

53

54

24
21-03-2022

Supervised vs. Unsupervised


Learning

55

• Supervised learning: classification is seen as


supervised learning from examples.
• Supervision: The data (observations,
Supervised measurements, etc.) are labeled with
vs. pre-defined classes. It is like that a
“teacher” gives the classes (supervision).
Unsupervised • Test data are classified into these classes
too.
Learning • Unsupervised learning (clustering)
• Class labels of the data are unknown
• Given a set of data, the task is to
establish the existence of classes or
clusters in the data

56

25
21-03-2022

• Supervised learning: discover patterns in


the data that relate data attributes with a
target (class) attribute.
Supervised • These patterns are then utilized to
vs. predict the values of the target
attribute in future data instances.
Unsupervised
• Unsupervised learning: The data have no
learning target attribute.
• We want to explore the data to find
some intrinsic structures in them.

57

57

Supervised vs. Unsupervised Machine Learning

58

26
21-03-2022

59

Deep Dive into


Unsupervised
Learning

60

27
21-03-2022

Types of Unsupervised
Learning

61

Clustering

• Clustering is a technique for finding similarity groups in


data, called clusters. I.e.,
• it groups data instances that are similar to (near) each
other in one cluster and data instances that are very
different (far away) from each other into different
clusters.
• Clustering is often called an unsupervised learning task as
no class values denoting an a priori grouping of the data
instances are given, which is the case in supervised learning.
• Due to historical reasons, clustering is often considered
synonymous with unsupervised learning.
• In fact, association rule mining is also unsupervised

62

28
21-03-2022

Clustering

63

64

29
21-03-2022

This technique uses probability distribution to


create the clusters
Example: Following keywords
• "man's shoe."

Probabilistic • "women's shoe."


• "women's glove."

Model • "man's glove."

can be clustered into two categories "shoe"


and "glove" or "man" and "women."

65

Association
• Association rules allow you to establish
associations amongst data objects inside large
databases.
• This unsupervised technique is about discovering
interesting relationships between variables in
large databases.
• For example, people that buy a new home most
likely to buy new furniture.

66

30
21-03-2022

Association

Examples:
• A subgroup of cancer patients grouped by their
gene expression measurements
• Groups of shopper based on their browsing
and purchasing histories
• Movie group by the rating given by movies
viewers

67

Disadvantages of Unsupervised Learning


• You cannot get precise information regarding data sorting, and the output as data used in
unsupervised learning is labelled and not known
• Less accuracy of the results is because the input data is not known and not labelled by people in
advance. This means that the machine requires to do this itself.
• The spectral classes do not always correspond to informational classes.
• The user needs to spend time interpreting and label the classes which follow that classification.
• Spectral properties of classes can also change over time so you can't have the same class
information while moving from one image to another

68

31
21-03-2022

69

Practical
Examples of
Unsupervised
Learning

70

32
21-03-2022

Examples of Unsupervised
Learning

71

Applications of unsupervised machine learning

Anomaly detection can discover


Clustering automatically split the
unusual data points in your dataset.
dataset into groups base on their
It is useful for finding fraudulent
similarities
transactions

Latent variable models are widely


Association mining identifies sets of used for data preprocessing. Like
items which often occur together in reducing the number of features in a
your dataset dataset or decomposing the dataset
into multiple components

72

33
21-03-2022

Customer
Segmentation
• Clustering is commonly used for
determining customer segments in
marketing data.
• Being able to determine different segments
of customers helps marketing teams
approach these customer segments in
unique ways.
• Think of features like gender, location, age,
education, income bracket, and so on.

73

Dimensionality reduction -
Reducing the complexity of a
problem

• Dimensionality reduction is a commonly


used unsupervised learning technique
where the goal is to reduce the number of
random variables under consideration. It
has several practical applications.
• One of the most common uses of
dimensionality reduction is to reduce the
complexity of a problem by projecting the
feature space to a lower-dimensional
space so that less correlated variables are
considered in a machine learning system.

74

34
21-03-2022

Anomaly Detection

• Anomaly detection is the identification of


rare items, events, or observations,
which brings suspicions by differing
significantly from the normal data.

• In this case, the system is trained with a


lot of normal instances. So, when it sees
an unusual instance, it can detect
whether it is an anomaly or not.

• One important example of this is credit


card fraud detection. You might have
heard about a lot of events related to
credit card fraud.

75

AirBnB

• This is a great application which


helps host stays and experiences
connecting people all over the world.
• This application uses unsupervised
Learning where the user queries his
or her requirements and Airbnb
learns these patterns and
recommends stays and experiences
which fall under the same group or
cluster.

76

35
21-03-2022

Amazon

Amazon also uses unsupervised


learning to learn the customer’s
purchase and recommend the
products which are most
frequently bought together
which is an example of
association rule mining.

77

Market basket
analysis
• The algorithm identifies
typical patterns of purchases
and jointly purchased goods.
• The results obtained allow
optimizing the assortment
and its placement in the
sales areas, improving stock
management, increasing
sales volumes by offering
related products to
customers.

78

36
21-03-2022

Applications in
Marketing
• Cross-selling and up-selling. Based
on behavioral patterns, the
algorithm allows you to identify
customers who are inclined to
respond to personalized offers and
cross-selling.
• Direct mail – direct targeted
mailing that promotes offers to
potential and existing customers.
It is a highly effective, simple, and
cheap marketing tool.

79

Summary Unsupervised
Learning

80

37
21-03-2022

To summarize
• Unsupervised learning is a machine learning technique, where you do not need to supervise the
model.
• Unsupervised machine learning helps you to finds all kind of unknown patterns in data.
• Clustering and Association are two types of Unsupervised learning.
• Association rules allow you to establish associations amongst data objects inside large databases.
• In Supervised learning, Algorithms are trained using labelled data while in Unsupervised learning
Algorithms are used against data which is not labelled.
• Anomaly detection can discover important data points in your dataset which is useful for finding
fraudulent transactions.
• The biggest drawback of Unsupervised learning is that you cannot get precise information
regarding data sorting.

81

82

38
21-03-2022

83

Reinforcement
Learning
Approach

84

39
21-03-2022

• ‘Reinforcement Learning’ is a field in artificial


intelligence(s) machine learning.
• Inspired by behaviorist psychology, this field
renders software agents and machines to
ascertain behavior, take actions, accordingly,
ultimately maximizing their performance.
Reinforcement • Put simply, computers can reckon/learn
themselves by experimenting along with
Learning responses from the environment on how
things must be done and keep adapting while
getting better each time leading to
maximization.
• Ex: controlling computers are trained to play
games, schedule jobs such as elevator
scheduling

85

• Reinforcement Learning is defined as a


Machine Learning method that is concerned
with how software agents should take actions
in an environment.
Reinforcement • Reinforcement Learning is a part of the deep
Learning learning method that helps you to maximize
some portion of the cumulative reward.
• This neural network learning method helps
you to learn how to attain a complex objective
or maximize a specific dimension over many
steps.

86

40
21-03-2022

• RL, known as a semi-supervised learning model in machine


learning, is a technique to allow an agent to take actions and
interact with an environment to maximize the total rewards.
RL is usually modeled as a Markov Decision Process (MDP).
• In this, a computer program interacts with a dynamic
environment. In this, it must perform a certain goal, without a
teacher explicit telling it whether it has come close to its goal
Reinforcement or not.
Learning

87

Reinforcement Learning
• Imagine a baby is given a TV remote
control at your home (environment).

• In simple terms, the baby (agent) will


first observe and construct his/her own
representation of the environment
(state).

• Then the curious baby will take certain


actions like hitting the remote control
(action) and observe how would the TV
response (next state).

88

41
21-03-2022

Reinforcement Learning

• As a non-responding TV is dull, the


baby dislike it (receiving a negative
reward) and will take less actions that
will lead to such a result(updating the
policy) and vice versa.

• The baby will repeat the process until


he/she finds a policy (what to do under
different circumstances) that he/she is
happy with (maximizing the total
(discounted) rewards).

89

90

42
21-03-2022

• Let us consider the case of robotic navigation.


• A robot can make very precise movements
to perform a task. Yet, the robot must learn
to perform these movements through
repeated tests.
Reinforcement • It applies the knowledge gained from this to
improve its efficiency. This is the basis of
Learning reinforced learning.
• In robotic navigation, and other similar systems,
such as a self-driving car, sensor doors the
output is not restricted to a single action. It may
contain a sequence of actions.

91

92

43
21-03-2022

How Machines learnt how to walk!

93

Reinforcement Learning
• From self-improving cars which tend to
perform RL with safety and precision, this
technology can also be used for robots
(without using manual programming) and
can figure out the configuration required for
the apparatus in a data center.
• Other players in RL are Mobileye, OpenAI,
Google, and Uber. Google and DeepMind
also worked together to make its center’s
energy efficient.
• This was made possible through an RL
algorithm which can study from assembled
data, experiment through stimulation and
finally suggest when and how the cooling
systems must be operated.

94

44
21-03-2022

Applications in self-
driving cars
• Various papers have proposed Deep Reinforcement Learning for
autonomous driving. In self-driving cars, there are various aspects to
consider, such as speed limits at various places, drivable zones, avoiding
collisions.
• Some of the autonomous driving tasks where reinforcement learning could
be applied include trajectory optimization, motion planning, dynamic
pathing, controller optimization, and scenario-based learning policies for
highways.

• For example
• Parking can be achieved by learning automatic parking policies.
• Lane changing can be achieved using Q-Learning while overtaking can
be implemented by learning an overtaking policy while avoiding
collision and maintaining a steady speed thereafter.

95

Applications in
self-driving cars
• AWS DeepRacer is an
autonomous racing car that has
been designed to test out RL in a
physical track.
• It uses cameras to visualize the
runway and a reinforcement
learning model to control the
throttle and direction.

96

45
21-03-2022

Reinforcement Learning
applications in trading and finance
• Supervised time series models can be used for predicting future sales
as well as predicting stock prices. However, these models don’t
determine the action to take at a particular stock price.
• Enter Reinforcement Learning (RL). An RL agent can decide on such a
task; whether to hold, buy, or sell. The RL model is evaluated using
market benchmark standards in order to ensure that it’s performing
optimally.
• This automation brings consistency into the process, unlike previous
methods where analysts would have to make every single decision.
• IBM for example has a sophisticated reinforcement learning based
platform that has the ability to make financial trades. It computes the
reward function based on the loss or profit of every financial
transaction.

97

Reinforcement Learning in
news recommendation
• User preferences can change frequently, therefore
recommending news to users based on reviews and likes could
become obsolete quickly. With reinforcement learning, the RL
system can track the reader’s return behaviours.
• Construction of such a system would involve obtaining news
features, reader features, context features, and reader news
features. News features include but are not limited to the
content, headline, and publisher.
• Reader features refer to how the reader interacts with the
content e.g clicks and shares. Context features include news
aspects such as timing and freshness of the news. A reward is
then defined based on these user behaviours.

98

46
21-03-2022

99

To Summarize

100

47
21-03-2022

101

48

You might also like