Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

Module 1

Uploaded by

Anas Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Module 1

Uploaded by

Anas Hassan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

Module 1

TRACE KTU
CST413 Machine Learning
Syllabus

Module-1 (Overview of machine learning)


Machine learning paradigms-supervised, semi-supervised, unsupervised,
reinforcement learning.
Basics of parameter estimation - maximum likelihood estimation(MLE) and maximum
a posteriori estimation(MAP). Introduction to Bayesian formulation.

TRACE KTU

2
▷ Artificial intelligence (AI),ML ,Deep learning, and neural networks represent
incredibly exciting and powerful learning-based techniques used to solve many
real-world problems.

TRACE KTU

3
▷ Artificial intelligence (AI) is the broadest term used to classify
machines that mimic human intelligence.
▷ It is used to predict, automate, and optimize tasks that humans have
historically done, such as speech and facial recognition, decision
making, and translation.
TRACE KTU

4
What is Machine Learning

▷Machine learning is a subset of artificial intelligence in the field


of computer science that often uses statistical techniques to give
computers the ability to "learn" (i.e., progressively improve
performance on a specific task) with data, without being explicitly
programmed.
TRACE KTU - Wikipedia

5
Machine Learning is...

▷ Machine learning is about predicting the future based


on the past.
-- Hal Daume III
TRACE KTU

6
What is Machine Learning Cont..

▷ Machine learning is an application of artificial intelligence


(AI) that provides systems the ability to automatically learn
and improve from experience without being explicitly
programmed.
▷ TRACE KTU
Machine learning focuses on the development of computer
programs that can access data and use it learn for
themselves.

7
Definition of machine learning
▷ Arthur Samuel, an early American leader in the field of computer
gaming and artificial intelligence, coined the term “Machine Learning”
in 1959 while at IBM.
▷ He defined machine learning as “the field of study that gives computers
the ability to learn without being explicitly programmed.”
▷ Different authors define the term differently. We give below two more
TRACE KTU
definitions.
○ Machine learning is programming computers to optimize a
performance criterion using example data or past experience.
■ We have a model defined up to some parameters, and learning is the
execution of a computer program to optimize the parameters of the model
using the training data or past experience.
■ The model may be predictive to make predictions in the future, or
descriptive to gain knowledge from data, or both.
○ The field of study known as machine learning is concerned with
the question of how to construct computer programs that
automatically improve with experience.
8
Why “Learn” ?
▷ There is no need to “learn” to calculate payroll
▷ Learning is used when:
○ Human expertise does not exist (navigating on Mars),
○ Humans are unable to explain their expertise (speech
recognition)
TRACE KTU
○ Solution changes in time (routing on a computer network)
○ Solution needs to be adapted to particular cases (user
biometrics)

Based on slide by E. Alpaydin 9


A classic example of a task that requires machine
learning: It is very hard to say what makes a 2

TRACE KTU

10
Slide credit: Geoffrey Hinton
Definition of learning

▷ Definition:
○ A computer program is said to learn from experience E with
respect to some class of tasks T and performance measure P, if its
performance at tasks T, as measured by P, improves with
experience E.

TRACE KTU
▷ Definition:
○ A computer program which learns from experience is called a
machine learning program or simply a learning program.
○ Such a program is sometimes also referred to as a learner.

11
▷ Examples:
i) Handwriting recognition learning problem
• Task T: Recognising and classifying handwritten words within
images
• Performance P: Percent of words correctly classified
• Training experience E: A dataset of handwritten words with given
TRACE KTU
classifications
ii) A robot driving learning problem
• Task T: Driving on highways using vision sensors
• Performance measure P: Average distance traveled before an error
• Training experience: A sequence of images and steering commands
recorded while observing a human driver.

12
What We Talk About, When We Talk About “Learning”

▷ Learning general models from a data of particular examples .


▷ Data is cheap and abundant (data warehouses, data marts);
knowledge is expensive and scarce.
▷ Build a model that is a good and useful approximation to the
data.
▷ TRACE KTU
Machine learning uses various algorithms for building
mathematical models and making predictions using historical
data or information.
▷ Currently, it is being used for various tasks such as image
recognition, speech recognition, email filtering, Facebook auto-
tagging, recommender system, and many more.

13
How machines learn
▷ Basic components of learning process:
○ The learning process, whether by a human or a machine, can be
divided into four components, namely, data storage, abstraction,
generalization and evaluation.

○ Figure 1.1 illustrates the various components and the steps


involved in the learning process
TRACE KTU

14
▷ Data storage:
○ Facilities for storing and retrieving huge amounts of data are an
important component of the learning process.
○ Humans and computers alike utilize data storage as a foundation
for advanced reasoning.


TRACE KTU
In a human being, the data is stored in the brain and data is
retrieved using electrochemical signals.

• Computers use hard disk drives, flash memory, random access


memory and similar devices to store data and use cables and other
technology to retrieve data.

15
▷ Abstraction:
○ The second component of the learning process is known as
abstraction. Abstraction is the process of extracting knowledge
about stored data.
○ This involves creating general concepts about the data as a whole.
TRACE KTU
○ The creation of knowledge involves application of known models
and creation of new models.
○ The process of fitting a model to a dataset is known as training.
○ When the model has been trained, the data is transformed into an
abstract form that summarizes the original information.

16
▷ Generalization :
○ The third component of the learning process is known as
generalisation.
○ The term generalization describes the process of turning the
knowledge about stored data into a form that can be utilized for
future action.

TRACE KTU
○ These actions are to be carried out on tasks that are similar, but not
identical, to those what have been seen before.
○ In generalization, the goal is to discover those properties of the
data that will be most relevant to future tasks.

17
➢ Evaluation :
○ Evaluation is the last component of the learning process.
○ It is the process of giving feedback to the user to measure the
utility of the learned knowledge.
○ This feedback is then utilised to effect improvements in the whole
TRACE KTU
learning process.

18
Applications of machine learning
▪ Application of machine learning methods to large databases is called
data mining.
▪ In data mining, a large volume of data is processed to construct a
simple model with valuable use, for example, having high predictive
accuracy. The following is a list of some of the typical applications of
machine learning.

TRACE KTU
1. In retail business, machine learning is used to study consumer
behaviour. Eg: Market basket analysis, Customer relationship
management (CRM)
2. In finance, banks analyze their past data to build models to use in
credit applications, fraud detection, and the stock market.
3. In manufacturing, learning models are used for optimization,
control, and troubleshooting.
4. In medicine, learning programs are used for medical diagnosis.
5. In telecommunications, call patterns are analyzed for network
optimization and maximizing the quality of service.

19
6. In science, large amounts of data in physics, astronomy, and biology can only be analyzed fast

enough by computers.

7. In artificial intelligence, it is used to teach a system to learn and adapt to changes so that the

system designer need not foresee and provide solutions for all possible situations.

TRACE KTU
8. It is used to find solutions to many problems in vision, speech recognition, and robotics.

9. Machine learning methods are applied in the design of computer-controlled vehicles to steer

correctly when driving on a variety of roads.

10. Machine learning methods have been used to develop programmes for playing games such as

chess, backgammon ..
11. Web mining: Search engines

20
Understanding data
▷ An important component of the machine learning process is data
storage,
▷ The different types and forms of data that are encountered in the
machine learning process.
▷ Unit of observation
○ By a unit of observation ,mean the smallest entity with measured

▷ Examples
TRACE KTU
properties of interest for a study.

○ • A person, an object or a thing


○ • A time point
○ • A geographic region
○ • A measurement

21
▷ Examples and features :
○ Datasets that store the units of observation and their properties can
be imagined as collections of data consisting of the following:

○ Examples: An “example” is an instance of the unit of observation


for which properties have been recorded.

TRACE KTU
○ An “example” is also referred to as an “instance”, or “case” or
“record.”

○ • Features: A “feature” is a recorded property or a characteristic of


examples. It is also referred to as “attribute”, or “variable” or
“feature.”

22
Examples for “examples” and “features”

▷ 1. Cancer detection:
○ Consider the problem of developing an algorithm for detecting
cancer.
○ (a) The units of observation are the patients.
○ (b) The examples are members of a sample of cancer patients.
TRACE KTU
○ (c) The following attributes of the patients may be chosen as the
features:
■ • gender • age • blood pressure • the findings of the pathology
report after a biopsy

23
▷ Pet selection:
○ Suppose we want to predict the type of pet a person will choose.
(a) The units are the persons.
(b) The examples are members of a sample of persons who own pets
(c) The features might include age, home region, family income, etc. of persons who
own pets.

TRACE KTU

24
Different forms of data
▷ 1. Numeric data:
○ If a feature represents a characteristic measured in numbers, it is
called a numeric feature.
▷ 2. Categorical or nominal:
○ A categorical feature is an attribute that can take on one of a
limited, and usually fixed, number of possible values on the basis

TRACE KTU
of some qualitative property. A categorical feature is also called a
nominal feature.eg:model-SEL,SE,SES

▷ 3. Ordinal data :
○ This denotes a nominal variable with categories falling in an
ordered list.
○ Examples include clothing sizes such as small, medium, and large,
or a measurement of customer satisfaction on a scale from “not at
all happy” to “very happy.”

25
TRACE KTU

26
TRACE KTU

27
TRACE KTU

28
TRACE KTU

29
Kinds of Machine Learning

▷ Supervised Learning
○ Classification (Logistic Regression, SVM, Naïve bayes, Decision
Trees,)
○ Regression (Linear regression, multi variate regression,
polynomial regression)

▷ TRACE KTU
○ Association learning
Unsupervised Learning
▷ Reinforcement Learning

30
Supervised Learning

▷ A majority of practical machine learning uses supervised


learning.

▷ In supervised learning, the system tries to learn from the


TRACE KTU
previous examples that are given.
Supervised learning is the machine learning task of
learning a function that maps an input to an output based
on example input-output pairs.(training data)

31
Supervised Learning

▷ Train the machine using data which is well labeled


▷ A machine is provided with new set of examples(data)
▷ supervised learning algorithm analyses the training data(set
of training examples) and produces an correct outcome from

TRACE KTU
labeled data.

32
TRACE KTU

33
• Consider the following data regarding patients entering a clinic. The
data consists of the gender and age of the patients and each patient
is labeled as “healthy” or “sick”.

TRACE KTU
Based on this data, when a new patient enters the clinic, how
can one predict whether he/she is healthy or sick?

34
Supervised Learning

TRACE KTU
▷ If shape of object is rounded and depression at top
having color Red then it will be labelled as –Apple.
▷ If shape of object is long curving cylinder having color
Green-Yellow then it will be labelled as –Banana.

35
TRACE KTU

36
Supervised Learning

▷ Supervised learning classified into two categories of


algorithms:

○ Classification: A classification problem is when the output variable


TRACE KTU
is a category, such as “Red” or “blue” or “disease” and “no
disease”.(sunny,rainy),
○ Regression: A regression problem is when the output variable is a
real value, such as “dollars” or “weight”.

37
▷ pricr

TRACE KTU
Predicting actual price of

38
▷ Define supervised learning? Name special cases of
supervised learning depending on whether the
inputs/outputs are categorical, or continuous

TRACE KTU

39
GENERAL CLASSES OF MACHINE LEARNING PROBLEMS

▷ Types of Supervised Learning


▷ Classification
○ The problem of identifying to which of a set of categories a new
observation belongs, based on a training set of data containing
observations (or instances) whose category membership is known.

○ TRACE KTU
Image belongs to cat /Dog

40
Classification
Score1 29 22 10 31 17 33 32 20
Score2 43 29 47 55 18 54 40 41
Result Pass Fail Fail Pass Fail Pass Pass Pass

TRACE KTU
▷ If we have some new data, say “Score1 = 25” and “Score2
= 36”, what value should be assigned to “Result”
corresponding to the new data?

41
▷ Discriminant:
○ A discriminant of a classification problem is a rule or a function
that is used to assign labels to new observations.
○ Examples i) Consider the data given and the associated

○ TRACE KTU
classification problem.
We may consider the following rules for the classification of the
new data:
○ IF Score1 + Score2 ≥ 60, THEN “Pass” ELSE “Fail”.
○ IF Score1 ≥ 20 AND Score2 ≥ 40 THEN “Pass” ELSE “Fail”

42
Classification
▷ There are several machine-learning algorithms for
classification. The following are some of the well-known
algorithms.
○ Logistic regression
○ Naive Bayes algorithm
○ k-NN algorithm
○ Decision tree algorithm
○ Support vector machine algorithm
TRACE KTU
○ Random forest algorithm
○ Examples:
○ Remarks
■ A classification problem requires that examples be classified into one of two or
more classes.
■ classification can have real-valued or discrete input variables.
■ A problem with two classes is often called a two-class or binary classification
problem.
■ A problem with more than two classes is often called a multi-class classification
problem.

43
Multi Class Classification

TRACE KTU

44
Multi Class Classification

▷ In general we can have K classes denoted as Ci , i = 1, . . . ,


K, and an input instance belongs to one and exactly one of
them.
▷ Example: here there are three classes: family car, sports car,
and luxury sedan.

TRACE KTU
There are three hypotheses induced, each one covering the
instances of one class and leaving outside the instances of
the other two classes.
▷ ‘?’ are reject regions where no, or more than one, class is
chosen
▷ Aim of K Class classification ;is to learn the boundary
separating the instances of one class from the instances of
all other classes.
▷ We view a K-class classification problem as K two-class
problems
45
TRACE KTU

46
Regression
○ the problem of predicting the value of a numeric variable based on
observed values of the variable.
○ The value of the output variable-number such as integer,floating point
value.

TRACE KTU Suppose we are required to estimate the


price of a car aged 25 years with distance
53240 KM and weight 1200 pounds.

47
Regression

TRACE KTU
▷ The function f(x, θ) is called the regression function.
▷ Let X denote the car attributes and Y be the price of the car.
▷ The machine learning algorithm optimizes the parameters in the set θ
such that the approximation error is minimized our estimates are as
close as possible to the correct values given in the training set.
48
Different Regression models:
▷ There are various types of regression techniques available to make predictions.
○ Simple linear regression: There is only one continuous independent
variable x and the assumed relation between the independent variable and
the dependent variable y is
y = a + bx.

○ TRACE KTU
Multivariate linear regression: There are more than one independent
variable, say x1, . . . , xn, and the assumed relation between the
independent variables and the dependent variable is
y = a0 + a1x1 + ⋯ + an xn.

○ Polynomial regression: There is only one continuous independent


variable x and the assumed model is
y = a0 + a1x + ⋯ + anxn

○ The assumed model involves certain probability distributions.

49
Regression

For example, if the input variables are “Age”, “Distance” and


“Weight” and the output variable is “Price”, the model may be
y = f(x,𝜃)
Price = a0 + a1 × (Age) + a2 × (Distance) + a3 × (Weight)
TRACE KTU
where x = (Age, Distance, Weight) denotes the set of input
variables and 𝜃 = (a0,a1,a2, a3) denotes the set of parameters
of the model.

50
TRACE KTU

51
TRACE KTU

52
▷ Learning associations
○ Association rule learning:
■ is a machine learning method for discovering interesting
relations, called “association rules”, between variables in
large databases using some measures of “interestingness”.

TRACE KTU
○ Example Consider a supermarket chain.
○ The management of the chain is interested in knowing
whether there are any patterns in the purchases of products
by customers like the following:
■ “If a customer buys onions and potatoes together, then
he/she is likely to also buy hamburger.”

53
▷ Customer behaviour,
○ this defines an association between the set of products
{onion, potato} and the set {burger}.
○ This association is represented in the form of a rule as
follows:
○ {onion, potato} ⇒ {burger}
TRACE KTU
○ The measure of how likely a customer, who has bought
onion and potato, to buy burger also is given by the
conditional probability
■ P({onion, potato}∣{burger}).
○ If this conditional probability is 0.8,

○ then the rule may be stated more precisely as follows:


“80% of customers who buy onion and potato also buy
burger.”
54
Learning associations

○ How association rules are made use of:


○ Consider an association rule of the form
X => Y,
that is, if people buy X then they are also likely to buy Y .

TRACE KTU
○Suppose there is a customer who buys X and does not buy Y .
○Then that customer is a potential Y customer.
○Once we find such customers, we can target them for cross-selling.
A knowledge of such rules can be used for promotional pricing or
product placements.

55
Learning associations

▷ General case
▷ We are interested in learning a conditional probability of the form
P(Y|X) where Y is the product the customer may buy and X is the

TRACE KTU
product or the set of products the customer has already purchased.

○ If we may want to make a distinction among customers, we may


estimate P(Y|X,D) where D is a set of customer attributes, like
gender, age, and so on,

56
Learning associations

▷ There are several algorithms for generating association


rules. Some of the well-known algorithms are listed
below:
○ Apriori algorithm
TRACE KTU
○ Eclat algorithm
○ FP-Growth Algorithm (FP stands for Frequency
Pattern)

57
TRACE KTU

58
Unsupervised Learning

▷ Training of machine using information that is neither


classified nor labeled and allowing the algorithm to act on
that information without guidance.
▷ Here the task of machine is to group unsorted information
TRACE KTU
according to similarities, patterns and differences without
any prior training of data.(cluster Analysis)
▷ Unsupervised Learning is a type of machine learning
algorithm used to draw inferences from datasets consisting
of input data without labelled responses.

59
Unsupervised Learning

TRACE KTU

60
Exercise 1

TRACE KTU

61
Supervised Learning

FRUIT
No. SIZE COLOR SHAPE
NAME

TRACE KTU

62
Supervised Learning

FRUIT
No. SIZE COLOR SHAPE
NAME
Rounded shape with
1 Big Red Apple
depression at the top

2 TRACE KTU
Small Red
Heart-shaped to nearly
globular
Cherry

3 Big Green Long curving cylinder Banana


Round to oval,Bunch shape
4 Small Green Grape
Cylindrical

63
Unsupervised Learning

▷ Suppose you have a basket and it is filled with some


different types of fruits and your task is to arrange them as
groups.
▷ This time, you don’t know anything about the fruits, You

▷ TRACE KTU
have no clue about those.
So, how will you arrange them?
▷ What will you do first???
▷ You will take a fruit and you will arrange them by
considering the physical character of that particular fruit.

64
Unsupervised Learning

▷ Suppose you have considered color.


○ Then you will arrange them on considering base
condition as color.
○ Then the groups will be something like this.
TRACE KTU
■ RED COLOR GROUP: apples & cherry fruits.
■ GREEN COLOR GROUP: bananas & grapes.
▷ So now you will take another physical character such as size.
○ RED COLOR AND BIG SIZE: apple.
○ RED COLOR AND SMALL SIZE: cherry fruits.
○ GREEN COLOR AND BIG SIZE: bananas.
○ GREEN COLOR AND SMALL SIZE: grapes.

65
Unsupervised Learning

▷ Suppose you have considered color.


○ Then you will arrange them on considering base
condition as color.
○ Then the groups will be something like this.
TRACE KTU
■ RED COLOR GROUP: apples & cherry fruits.
■ GREEN COLOR GROUP: bananas & grapes.
▷ So now you will take another physical character such as size.
○ RED COLOR AND BIG SIZE: apple.
○ RED COLOR AND SMALL SIZE: cherry fruits.
○ GREEN COLOR AND BIG SIZE: bananas.
○ GREEN COLOR AND SMALL SIZE: grapes.

66
TRACE KTU

67
▷ Clustering has a large no. of applications spread across
various domains.
Some of the most popular applications of clustering are:
○ Recommendation engines
○ Market segmentation
TRACE KTU
○ Social network analysis
○ Search result grouping
○ Medical imaging
○ Image segmentation
○ Anomaly detection

68
TRACE KTU

69
Reinforcement Learning

▷A type of Machine Learning algorithms which allows an agents/


machines learns how to behave in an environment by performing
certain actions and by observing the rewards it gets from those
actions.
○ automatically determine the ideal behavior within a specific

▷ TRACE KTU
context, to maximize its performance.
A reinforcement learning algorithm, or agent, learns by interacting
with its environment.
▷ The agent receives rewards by performing correctly and penalties
for performing incorrectly.
▷ The agent learns without intervention from a human by maximizing
its reward and minimizing its penalty.

70
TRACE KTU

71
Reinforcement Learning

▷ Consider an example of a child learning to walk.


○ child will observe how you are walking.
○ Soon he/she will understand that before walking,
the child has to stand up
TRACE KTU
○ now the child attempts to get up, staggering and
slipping
○ Standing up was easy, but to remain still is another
task
○ Now the real task for the child is to start walking.
○ But it’s easy to say than actually do it.
○ There are so many things to keep in mind, like
balancing the body weight, deciding which foot to
put next and where to put it.
72
Reinforcement Learning Cont..

▷ the “problem statement” of the example is to walk,


where the child is an agent trying to manipulate the
environment (which is the surface on which it walks) by
taking actions (viz walking) and he/she tries to go from
TRACE KTU
one state (viz each step he/she takes) to another.

▷ The child gets a reward (let’s say chocolate) when he/she


accomplishes a submodule of the task (viz taking couple
of steps) and will not receive any chocolate (negative
reward) when he/she is not able to walk.
▷ Robotics and Game

73
▷ A good example is game playing where a single move by itself is not
that important; it is the sequence of right moves that is good.
○ A move is good if it is part of a good game playing policy.
▷ A robot navigating in an environment in search of a goal location is
another application area of reinforcement learning.
TRACE KTU
○ At any time, the robot can move in one of a number of directions.
○ After a number of trial runs, it should learn the correct sequence of
actions to reach to the goal state from an initial state, doing this as
quickly as possible and without hitting any of the obstacles.
▷ Other examples include
○ Adaptive Traffic signal optimization
○ Adaptive power grid

74
▷ The mathematical framework for defining a solution in reinforcement
learning scenario is called Markov Decision Process.
▷ This can be designed as:
○ • Set of states, S
○ • Set of actions, A
TRACE KTU
○ • Reward function, R
○ • Policy, π
○ • Value, V
▷ We have to take an action (A) to transition from our start state to our
end state (S).
▷ In return getting rewards (R) for each action we take.
▷ Our actions can lead to a positive reward or negative reward. The set of
actions we took define our policy (π) and the rewards we get in return
defines our value (V). Our task here is to maximize our rewards by
choosing the correct policy.
75
Semi-supervised learning
▷ Its an approach to machine learning that combines a small amount of
labeled data with a large amount of unlabeled data during training.
▷ Semi-supervised learning falls between unsupervised learning (with no
labeled training data) and supervised learning (with only labeled
training data).
▷ It is a special instance of weak supervision.
▷ TRACE KTU
Unlabeled data, when used in conjunction with a small amount of
labeled data, can produce considerable improvement in learning
accuracy.
▷ The acquisition of labeled data for a learning problem often requires a
skilled human agent (e.g. to transcribe an audio segment) or a physical
experiment (e.g. determining the 3D structure of a protein or
determining whether there is oil at a particular location).

76
▷ Practical applications of Semi-Supervised Learning
1. Speech Analysis: Since labeling of audio files is a very intensive
task, Semi Supervised learning is a very natural approach to solve this
problem.

TRACE KTU
2. Internet Content Classification: Labeling each webpage is an
impractical and unfeasible process and thus uses Semi-Supervised
learning algorithms.
Even the Google search algorithm uses a variant of Semi-Supervised
learning to rank the relevance of a webpage for a given query

77
Fruit Example:Supervised
Label/Target
○ Label/target

TRACE KTU

78
TRACE KTU

79
Introduction to Bayesian formulation.

TRACE KTU

80

You might also like