















































Studia grazie alle numerose risorse presenti su Docsity
Guadagna punti aiutando altri studenti oppure acquistali con un piano Premium
Questa pagina non è visibile nell’anteprima
Non perderti parti importanti!
















































Machine learning is an application of AI that provides systems the ability to automatically learn and
improve from experience without being explicitly programmed. The goal is to improve performance
over time, based on experience. ML is a tool for generating knowledge from data.
Model approach is based on modeling a problem and finding a math formulation, instead ML will not
require any model : it just uses data and information extracted from the system and then build a
solution from these. This approach in many cases is more effective and improves the performance.
In this period, we have an exploit of ML. The huge availability of data and the increasing of the
computational power made possible to use specific algorithms to find solutions for several problems
that were not effective when they were theorized. Data and computational power are not enough by
themselves; we must understand how to design a system.
Learning : Improving with experience at some task.
▪ Improve over task T , that is the task that we want to learn.
▪ With respect to performance measure P , that is the performance metrics.
▪ Based on experience E , these are the data user for experience.
If you do not specify these 3 elements the learning problems is not well defined, and the solution as
well. In a learning problem we must define:
Collecting the experience is the most difficult part; in many cases the data are already available. The
function sometimes is quite easy to define. The first thing is to choose the function that you want to
learn, then you choose a representation of the function and depending on the other choices you will
choose an algorithm and get the solution.
A generic Machine Learning (ML) problem is learning a function f : X → Y , given a dataset D containing
sampled information about f (D is a set of samples of this function ). Learning a function f means
computing an approximated function f ’ that returns values as close to f also on samples x not in the
dataset.
What is different in the ML problems categories is how data is represented.
There are 3 main categories for ML problems:
▪ Classification
▪ Regression
𝑖
1
𝑖
𝑛
𝑖
evaluating 𝑐(𝑥
𝑖
𝑖
) for every 𝑥
𝑖
Inductive learning hypothesis: if a hypothesis does well inside the dataset, it will do well also outside
the dataset.
The dataset must be representative for the problem that we are considering (large dataset).
We call Version Space the subset of 𝐻 that is consistent with the dataset 𝐷. Each of these hypotheses
is mapped to a subset of 𝑋 that is also consistent with 𝐷, and this means that h(x) = the values of X.
𝐻,𝐷
We call list-then-eliminate algorithm an algorithm that compute the version space by iterating on all
the hypothesis and checking for any if they are consistent. Most of the time it is impracticable (we can
have infinite hypothesis).
If any subset of the instances can be represented in a Version Space and all the solution are computed
(search is completed), then the system is not able to classify new instances. In fact, different
hypotheses in a version space may return different values for a new instance.
Collecting data is difficult and it’s easy to make some mistakes. Noisy data can be into the dataset and
so the output is different from the true value of the target function. In this case we can have no
consistent hypothesis. We then need statistical methods to remove the noise.
To introduce the notion of performance metrics in ML, we must define a probability distribution of all
the possible inputs. Let 𝑍 be the probability distribution over 𝑋, and 𝑆 are a set of 𝑛 instances of 𝑋
sampled with 𝑍. The performance evaluations are based on accuracy and error rate.
We can have two definitions of error/accuracy (remembering that 𝑎𝑐𝑐𝑢𝑟𝑎𝑐𝑦
▪ The true error of hypothesis ℎ with respect to target function 𝑐 and distribution 𝑍 is the
probability that ℎ will misclassify an instance according to 𝑍.
The true error represents the probability of making a mistake given an input taken from the
entire distribution , and this is the error that the system will make at run time. The problem is
that this error cannot be computed because we don’t know c(x).
𝑧
𝑥∈𝑍
▪ The sample error of hypothesis h with respect to target function c and data sample S is the
number of mistakes that h makes on S.
The sample error is the number of mistakes that h makes on a data sample. It can be computed
because for the samples of S we know the values of the target function. The problem is that this
is not enough because we cannot be sure that this will be the “resulting error” of the entire
distribution.
𝑠
The true error can be just estimated while sample error can be computed. We need to remember that
the goal of a learning system is to be accurate in predicting outside the dataset: ℎ(𝑥), ∀𝑥 ∉ 𝑆
We call bias the difference between the expected value of the sample error and the true error.
We want to obtain a bias of 0, with this value in fact we can approximate the true error with the
expected value of the sample error.
For unbiased estimate we must have a ℎ and a 𝑆 chosen independently: 𝐸
𝑠
𝑧
In order to calculate the true error, we need to calculate the expected value of the sample error by
using an unbiased estimator. This is done as follow:
▪ Split the dataset D and train on T:
2
3
▪ Compute a hypothesis h using training set T.
▪ Evaluate the sample error to obtain an unbiased estimator for the true error.
With some probability the true error is in an interval defined by the sample error , where these 2 values
are defined by a coefficient 𝑧
𝑁
𝑠
𝑁
𝑠
𝑠
When we are comparing two different hypotheses on a sample S, we have no guarantee that if a
hypothesis is better than the other in S, the same will be also for the entire distribution. In the
overfitting we have that the sample error of h is lower than the sample error of h’ but the true error is
greater.
Given a training set D for a target function c, we need to compute a consistent hypothesis respecting
D. Resolving approach: define an hypotheses space 𝐻 and implement an algorithm to search an ℎ ∈ 𝐻
that is consistent with 𝐷.
We are going to consider an hypotheses space made by the set of decision tree. This means that every
hypothesis is a decision tree. Each decision tree is formed in this way:
▪ each internal node represents an attribute.
▪ each branch (arc towards an internal node) represents a
value of an attribute.
▪ each leaf assigns a classification value.
A decision tree can be transformed in a set of rules.
It represents the disjunction of conjunction of all the paths to
the positive leaf nodes. We have an OR for each edge from the
root, and we have an AND for each internal node in the path.
If we have for example the decision tree in figure, we obtain these rules:
(𝑂𝑢𝑡𝑙𝑜𝑜𝑘 = 𝑆𝑢𝑛𝑛𝑦 ∧ 𝐻𝑢𝑚𝑖𝑑𝑖𝑡𝑦 = 𝑁𝑜𝑟𝑚𝑎𝑙) ∨ (𝑂𝑢𝑡𝑙𝑜𝑜𝑘 = 𝑂𝑣𝑒𝑟𝑐𝑎𝑠𝑡) ∨ (𝑂𝑢𝑡𝑙𝑜𝑜𝑘 = 𝑅𝑎𝑖𝑛 ∧ 𝑊𝑖𝑛𝑑 = 𝑊𝑒𝑎𝑘)
If we want to create a decision tree from a dataset D, we must choose a target attribute.
We will use the ID3 algorithm (Iterative Dichotomiser 3).
This algorithm takes in input:
▪ Examples: data instances.
▪ Target attribute: what we want to learn.
▪ Attributes: the set that form the domain of the function.
The tree is built in a recursive way. In the first step it creates the Root node for the tree. Then we can
have 3 different steps (all final cases) and a 4
th
recursive. The firsts two steps check if every element in
the subset belongs to the same class, in which case the node is turned into a leaf node and labeled
with the class of the examples.
▪ If all Examples are positive ( + , true , 1 , … ), then return the node Root with a label +. This
means that we will generate a tree that contains only one leaf node that is labelled with +.
▪ If all Examples are negative ( - , false , 0 , … ) then return the node Root with a label -. This means
that we will generate a tree that contains only one leaf node that is labeled with -.
▪ If Attributes is empty , then return the node Root with a label = most common value of Target
attribute in Examples. This will happen because at some point the recursive will reduce the set
of attributes. If it is empty, we are going to create a leaf. This is an important feature of decision
tree because it is using statistic, and this happens when we have a noisy dataset.
▪ Recursive case : first, we choose the “ best ” attribute in Examples and we generate all branches
associated. We then take the subset of Examples that contains the branches of the best
attribute. If this subset is empty like before we generate a leaf node with a label = most common
value of Target attribute in Examples. Else we call the recursive algorithm by passing it, the new
subset of Examples and the list of the Attributes without the best attribute used.
If the dataset is consistent , the choice based on most common value will never happen, in fact there will
never be any conflict. This algorithm will produce consistent data set whatever is the choice of the
attribute.
The algorithm can be written as follow:
ID3 does not guarantee an optimal solution. It can converge upon local optima. It uses a greedy
strategy by selecting the locally best attribute to split the dataset on each iteration. The tree is built
top-down, splitting the problem in smaller parts (“ dividi et impera ” approach).
ID3 considers as best attribute the one with the highest information gain , which measures how well
a given attribute separates the training examples according to their target classification.
Let’s call p
the proportion of positive examples in S and 𝑝
−
the proportion of negative examples in S.
| 𝑝𝑜𝑠𝑖𝑡𝑖𝑣𝑒 𝑒𝑥𝑎𝑚𝑝𝑙𝑒𝑠
|
| 𝑒𝑥𝑎𝑚𝑝𝑙𝑒𝑠
|
−
Entropy is defined as:
log
2
−
log
2
−
Entropy is max when the dataset contains exactly half positive and half negative (𝑝
−
minimum when 𝑝
= 0 or 1.
The information gain is defined as the expected reduction in entropy of the examples caused by
knowing the value of attribute A (reduction of the entropy if we use A to partition the examples/S).
One way to define the best attribute for this step it to compute the gain of each attribute with this
method and select the one with the maximum gain.
𝑣
𝑣∈𝐴
𝑣
Sample space
Probability space (or probability model )
o 0 ≤ 𝑃
ω
o
ω
ω→Ω
An event 𝐴 is any subset of Ω. Probability of an event 𝐴 is a function assigning to 𝐴 a value in
𝜔∈𝐴
Prior probability is the probability of an event without knowing any other information (e.g.
= 0. 5 ). A random variable (outcome of a random phenomenon) is a function from
the sample space Ω to some range (e.g., the reals or Booleans) 𝑋: Ω → ℜ.
A probability distribution is the set of probability values for all the possible assignment of a random
variable (the sum of all values must be 1). For continuous variables, the probability distribution is a
continuous function.
Joint probability distribution for a set of random variables gives the probability of every atomic joint
event on those random variables.
Conditional probability 𝑃
is the probability of an event given another event happened.
if 𝑃
and in general
𝑦∈𝑣𝑎𝑙𝑢𝑒𝑠
( 𝑌
)
𝑃(𝑌 = 𝑦) when 𝑦 are mutually exclusive.
Given a set of random variables we can generate a graph in which
random variables are nodes while the edges represent dependencies.
This graph is called Bayesian Network.
We can interpret a classification problem as a probabilistic estimation.
Given a target function 𝑓: 𝑋 → 𝑉, a dataset 𝐷 and a new instance 𝑥
′
, the best prediction 𝑓’(𝑥’) = 𝑣
∗
∗
= argmax
𝑦∈𝑌
The function argmax returns the value of y for which the function P is maximum (while 𝑚𝑎𝑥𝑓(𝑦)
returns the max value of 𝑓
). We compute the full distribution (over the whole codomain 𝑌,
𝑃(𝑦|𝑥’, 𝐷) and we want to apply a decision over a classification result. The output of a probabilistic
estimation is the prediction (of the class that we want to assign to a new instance) and the probability
of this classification.
Learning can be seen as a probabilistic estimation. In fact, given a dataset D, and a hypothesis space
H, we can compute a probability distribution over 𝐻 given 𝐷.
From the Bayes rules we have that:
represent the probability a priori ( prior probability ) of a hypothesis h before I get any
dataset.
represent the prior probability of extracting this dataset from the entire distribution,
independently from how the dataset is used in ML.
represent the probability that h has been generated from the dataset D.
represent the probability that, given one particular h, I generate the dataset D.
This is the main theorem we will use. We have a typical situation in which we define a hypothesis
space, but now we don’t want to compute only the best hypothesis, we want a probability distribution
over the hypotheses; we want to assign to each of this hypothesis a probability value that say how
good is the hypothesis.
In general, we want the most probable hypothesis given D, called maximum a posteriori hypothesis :
𝑀𝐴𝑃
= argmax
ℎ∈𝐻
𝑃(ℎ|𝐷) = argmax
ℎ∈𝐻
= argmax
ℎ∈𝐻
It is defined as the argmax over all possible hypothesis in the hypothesis space , so it’s the value of h
for which the probability is maximized. We have eliminated the probability of extracting the database
𝑃(𝐷) because it doesn’t depend on h.
If we assume that all the hypotheses have the same probability we can simplify and choose the
Maximum likelihood ( ML ) hypothesis:
𝑀𝐿
= argmax
ℎ∈𝐻
We can consider also the log-likelihood: ℎ
𝑀𝐿
= argmax
ℎ∈𝐻
𝑃(𝐷|ℎ) = argmax
ℎ∈𝐻
log (𝑃
We can differentiate it to get the max.
To generate a MAP hypothesis, we can iterate all over the possible hypotheses , and for each of this we
can compute the posteriori probability. We then take the hypothesis ℎ
𝑀𝐴𝑃
with the highest posteriori
probability. The problem is that we can have infinite hypothesis. If the space is limited and small,it can
be computed, and the learning process can be the brute force of all h ∈ H returning ℎ
𝑀𝐴𝑃
after
computing all posteriori probability.
If ℎ
𝑀𝐴𝑃
is the most probable hypothesis given dataset 𝐷, given a new instance 𝑥
′
𝑀𝐴𝑃
′
) may
not be the most probable classification. We need to take the weighted average, and then return as
value the class for which you have the highest weighted average.
Here we need to introduce the Bayes Optimal Classifier.
For a target function 𝑓: 𝑋 → 𝑌, dataset 𝐷 and a new instance 𝑥
′
∉ 𝐷, we have that:
′
′
ℎ∈𝐻
Usually a good way to make estimations is to consider the number of times in which the event happens
divided by the total number of events. 𝑃(𝑣
𝑗
|𝐷) can be estimate as numbers of elements that v j
as
output divided by the total number of the elements in the dataset:
𝑗
𝑗
In the same way, the probability of a particular attribute given classification value and dataset is given
by the number of samples for which the attribute happens divided the number of samples for that
category in the dataset:
𝑖
𝑗
𝑖
𝑗
𝑗
Note that if there is a missing element (if none of the training instances with target value 𝑣
𝑗
have an
attribute 𝑎
𝑖
), we have 𝑃
𝑖
𝑗
, 𝐷) = 0 and 𝑃
𝑗
𝑖
𝑗
𝑖
This is not good. We can use a prior estimate (virtual samples) so there is always non-zero probability:
𝑖
𝑗
𝑖
𝑗
𝑗
Where:
𝑖
𝑗
For example, Bayes Classifiers can be used to classify text.
The vocabulary is the set of all the words appearing in any document of the data set (its dimension is n).
A text is represented as a n-dimensional feature vector in the Bag of Words representation (but we loose
the information about the order of the words). Different options are available for representing features:
▪ Boolean features: 1 if word appears in the text, 0 otherwise (multivariate Bernoulli distribution).
▪ Ordinal feature: number of occurrences of the words in the text (multinomial distribution).
In a probabilistic classification problem, we want to estimate the posterior probability distribution of
an instance belonging to some class. Our task in classification problems is to predict the class to which
a new instance belongs, and we can formulate this problem as an estimation.
There are two probabilistic models for classification:
𝑖
|𝑥) through 𝑃(𝑥|𝐶
𝑖
) and Bayes theorem.
𝑖
directly from a model.
These methods are similar, in fact both are based on the idea of maximizing the likelihood.
The idea is to compute the probability of a class given an instance by using Bayes theorem.
We turn to a probabilistic view of classification and show how models with linear decision boundaries
arise from simple assumptions about the distribution of the data.
Consider first of all the case of two classes (but all the methods can be extended to multiple classes) ,
the posterior probability (conditional probability) for class 𝐶
1
can be written as:
1
1
1
1
1
2
2
−𝛼
With 𝛼 = ln
1
)𝑃(𝐶
1
)
2
)𝑃(𝐶
2
)
and 𝜎 the logistic sigmoid.
Let us assume that the class-conditional densities are Gaussian (Gaussian Naïve Bayes) and then
explore the resulting form for the posterior probabilities. To start with, we shall assume that all classes
share the same covariance matrix 𝚺.
𝛼 = ln
1
1
2
2
= 𝛼 = ln
1
1
2
2
𝑻
0
The quadratic terms in x from the exponents of the Gaussian densities have cancelled (due to the
assumption of common covariance matrices), leading to a linear function of 𝑥 in the argument of the
logistic sigmoid.
1
𝑻
0
We need to find the maximum likelihood solution. Our goal is then to find the parameters of this
model (prior probabilities, means and covariance of the two gaussian distributions). We just compute
likelihood and then we solve the optimization problem for finding max likelihood.
We denote the prior class probability 𝑝(𝐶
1
) = 𝜋, so that 𝑝(𝐶
2
) = 1 − 𝜋. For a data point 𝑥
𝑛
from class
1
, we have 𝑡
𝑛
= 0 and hence
𝑛
1
1
𝑛
1
𝑛
1
Similarly, for class 𝐶
2
, we have 𝑡
𝑛
= 1 and hence
𝑛
2
2
𝑛
2
𝑛
2
Thus, the likelihood function is given by
1
2
𝑛
1
𝑡
𝑛
𝑁
𝑛= 1
𝑛
2
1 −𝑡
𝑛
The goal in classification is to take an input vector 𝒙 and to assign it to one of 𝐾 discrete classes 𝐶
𝑘
where 𝑘 = 1 ,... , 𝐾. In the most common scenario, the classes are taken to be disjoint, so that each
input is assigned to one and only one class. The input space is thereby divided into decision regions
whose boundaries are called decision boundaries or decision surfaces. In this chapter, we consider
linear models for classification, by which we mean that the decision surfaces are linear functions of
the input vector x and hence are defined by (D −1)-dimensional hyperplanes within the D-dimensional
input space. Data sets whose classes can be separated exactly by linear decision surfaces are said to
be linearly separable.
We have a classification problem with a continuous input space (while in the previous examples the
input was formed by finite set of attributes). Output of our target is a set of classes. This is a
classification problem where input are real numbers and we assume that data have a special format
so they can be separated by a linear function.
We must learn a function 𝑓: 𝑋 → 𝑌 with 𝑋 ⊂ 𝑅
𝑑
and 𝑌 = {𝐶
1
𝑘
} with linearly separable data.
Instances in a dataset ( binary ) are linearly separable if it exists a linear function (hyperplane) that
divide the instance space into two regions, such that differently classified instances are separated.
a) Dataset instances are denoted with a symbol. In this case we a two-dimensions space as input
and two classes as output ( + , − ). This dataset is linearly separable, in fact there exist at least
one line that separates the space in 2 regions, one with only positive samples and the other
with only negative ones. The line that separates data is used to predict classes of new instances.
b) Dataset is not linearly separable. It’s not possible to find any line that divides the space in 2
regions, one with only + and the other with only −.
Now we are going to focus on learning a classification function under the assumption that the dataset
is linearly separable. We call Linear Discriminant function 𝑦: 𝑋 → {𝐶
1
𝑘
𝑇
0
𝑘
𝒌
𝑻
𝑘
0
In the first case we have 2 classes, then the discriminant function can be given just by a linear function ,
where x is the input, w and w 0
are the coefficient of this function.
In the second case, we must classify more than 2 classes, so we need to define a set of functions. The
model in this case is given by k-1 functions, where k is the number of classes of our classification
problem.
The geometrical interpretation of a binary classification problem is: the red line is the function and
represents the set of point x 1
,x 2
for which y=0, w is the vector perpendicular to the line, and the
distance from any point x in the space and the line is: 𝑦(𝑥)/||𝑤||. The classification is made for 𝑦(𝑥) >
0 or 𝑦(𝑥) < 0.
When we have k-classes we can’t use combination of binary linear models.
The One-versus-the-rest classifier (Ovr) strategy involves training a single classifier per class, with the
samples of that class as positive samples and all other samples as negatives. This strategy requires the
base classifiers to produce a real-valued confidence score for its decision, rather than just a class label;
discrete class labels alone can lead to ambiguities, where multiple classes are predicted for a single
sample. We have K-1 binary classifiers: C K
vs not-C K
In the One-versus-one (OvO) classifier , one trains K ( K − 1) / 2 binary classifiers C K
vs C j
for a K - way
multiclass problem; each receives the samples of a pair of classes from the original training set, and
must learn to distinguish these two classes. At prediction time, a voting scheme is applied: all K ( K −
1 )/ 2 classifiers are applied to an unseen sample and the class that got the highest number of "+1"
predictions gets predicted by the combined classifier.
Attempting to construct a K class discriminant from a set of two class discriminants leads to ambiguous
regions, in green. On the left there is an example involving the use of two discriminants designed to
distinguish points in class 𝐶
𝑘
from points not in class 𝐶
𝑘
(OvR classifier). On the right an example
involving three discriminant functions used to separate a pair of classes 𝐶 𝑘
and 𝐶
𝑖
(OvO classifier).
For multiple classes , we need to define a set of linear functions. In order to classify a new instance x,
we compute all these functions and we classify the instance with the function K that returns the
highest value.
𝑘
𝒌
𝑻
𝑘 0
assigning 𝒙 to 𝐶
𝑘
if 𝑦
𝑘
𝑗
(𝒙) for all 𝑗 ≠ 𝑘
The output of the model is a partition of the space. Using a compact notation with vectors:
𝑻
1 0
1
2 0
2
𝑘 0
𝑘
Considering a two classes case, we must determine 𝑦 = 𝑤
𝑇
𝑥 in order to
classify 𝑥 ∈ 𝐶 1
if 𝑦 ≥ −𝑤
0
2
otherwise.
We want to adjust 𝑊 in order to find a direction that maximizes class
separation.
Consider a data set with 𝑁 1
points in 𝐶
1
and 𝑁
2
points in 𝐶
2
, so that the
mean vectors of the two classes are given by:
1
1
𝑁 1
𝑛∈𝐶 𝒏
1
2
1
𝑁 2
𝑛∈𝐶 𝒏
2
The simplest measure of the separation of the classes, when projected onto
w, is the separation of the projected class means. This suggests that we might
choose 𝑤 so as to maximize:
2
1
𝑻
2
1
Finding a line that minimizes the overlap of two projections means choosing 𝒘 that maximizes
𝑻
2
1
, constraining 𝒘 to have unit length |
| = 1 (or we could just increase the
magnitude of w ).
There is still a problem with this approach, as illustrated in the first figure. This shows two classes that
are well separated in the original two-dimensional space
1
2
but that have considerable overlap
when projected onto the line joining their means. This difficulty arises from the strongly nondiagonal
covariances of the class distributions. The idea proposed by Fisher is to maximize a function that will
give a large separation between the projected class means while also giving a small variance within
each class, thereby minimizing the class overlap.
The projection formula 𝑦 = 𝒘
𝑻
𝒙 transforms the set of labelled data points in x into a labelled set in
the one-dimensional space y.
The within-class variance of the transformed data from class 𝐶 𝑘
is therefore given by:
𝑘
2
𝑛∈𝐶
𝑘
𝑛
𝑘
2
Where 𝑦
𝑛
𝑻
𝒏
and 𝑚
𝑘
𝑻
𝒌
We can define the total within-class variance for the whole data set to be simply 𝑠
1
2
2
2
The Fisher criterion is defined to be the ratio of the between-class variance to the within-class variance
and is given by:
2
1
2
1
2
2
2
Maximizing this error function, we get a solution based on maximum separation between projections
of the means of the 2 distributions rotated by a proper rotation matrix.
We can make the dependence on w explicit to rewrite the Fisher criterion in the form:
𝑻
𝑩
𝑻
𝑾
Where 𝑺
𝑩
is the between-class covariance matrix and is given by:
𝑩
2
1
2
1
𝑻
And 𝑺
𝑾
is the total within-class covariance matrix, given by:
𝑾
𝒏
1
𝒏
1
𝑻
𝑛∈𝐶
1
𝒏
2
𝒏
2
𝑻
𝑛∈𝐶
2
Differentiating 𝐽(𝒘) with respect to 𝒘, we find that 𝐽(𝒘) is maximized when:
𝑻
𝑩
𝒘
𝑻
𝒘
𝑩
Considering that 𝑚 2
1
𝑻
2
1
is a scalar, the term 𝑺
𝑩
2
1
2
1
𝑻
on the right-hand side of the equation is always in the direction of ( m2 − m1 ). Furthermore, we do not
care about the magnitude of 𝒘, only its direction, and so we can drop the scalar factors (𝒘
𝑻
𝑩
𝒘) and
𝑻
𝒘
𝒘). Multiplying both sides by 𝑺
𝒘
− 1
, we then obtain the solution:
∗
𝒘
− 1
2
1
The perceptron is a simplified model of a biological
neuron. While the complexity of biological neuron
models is often required to fully understand neural
behavior, research suggests a perceptron-like linear
model can produce some behavior seen in real neurons.
We have a linear combination of input dimensions with some weights, plus a constant value w 0
In the modern sense, the perceptron is an algorithm for learning a binary classifier called a threshold
function. The output will be a function that depends on the sign of the linear combination:
𝑜(𝒙) = sign(𝒘
𝑻
Considering the unthresholded linear unit : 𝑜(𝒙) = 𝑤 0
1
1
𝑑
𝑑
𝑻
Let’s learn 𝑤 𝑖
from training examples 𝐷 =
𝑛
𝑛
𝑛= 1
𝑁
that minimize the squared error (loss
function). The derivate of the error function is done with
respect to each 𝑤
𝑖
𝑖
𝑖
𝑛
𝒏
𝑻
𝒏
2
𝑁
𝑛= 1
𝑖
𝑛
𝒏
𝑻
𝒏
2
𝑛
𝒏
𝑻
𝒏
𝑖,𝑛
𝑁
𝑛= 1
𝑁
𝑛= 1
It is an iterative method (learn iteratively) with a gradient checking. The algorithm will just start to
move to the negative gradient in order to minimize the error. The algorithm can update weights in order
to adjust the classifier and this is done in an iterative way until we divide all the samples of the dataset.
𝑖
𝑖
𝑛
(𝒙,𝑡)𝜖𝐷
𝑖
Batch mode : Consider all dataset D
Incremental (choose one sample) and mini-batch modes (considers a small subset) speed up
convergence and are less sensitive to local minima.
The perceptron convergence theorem states that if there exists an exact solution (in other words, if
the training data set is linearly separable), then the perceptron learning algorithm is guaranteed to
find an exact solution in a finite number of steps.