Professional Documents
Culture Documents
Chapter 5 - Classification
Chapter 5 - Classification
Chapter 5 -
Classification
1
150
Target Output
q Data: In
the label y(n) should tell us which class x(n) belongs to.
q There is a number of ways to encode y numerically.
q Binary classification: y ∊ {0, 1} or y ∊ {-1, 1}.
q Multiclass classification: Classification among K classes
y ∊ {1, 2, …, K}.
Target Output
q Data: In
the label y(n) should tell us which class x(n) belongs to.
q There is a number of ways to encode y numerically.
q Binary classification: y ∊ {0, 1} or y ∊ {-1, 1}.
Spam detection: Spam (1) or Not Spam (0), or (1) for True and (-1) for
False.
q Multiclass classification: Classification among K classes y ∊ {1, 2, …, K}.
Classify text documents from the news: class 1 could be Sport, class 2
could be Political news, class 3 could be Weather, …
Petal Leaf
Sepal Leaf
Iris dataset
To simplify we can plot
just two of the features
Iris dataset
q When I pick a flower with sepal length of 6 and sepal width
of 4:
In real world:
x - more dimensions,
- more noisy data,
- more overlap between the calsses
Generative vs.Discriminative
q Most learning algorithms categorize into two classes:
Generative vs.Discriminative
q Generative learning algorithms may work better if we have very
few training examples.
q They are very simple and very quick to implement and also very
quick to run.
q Because they are so efficient, they often scale very easily even
to massive datasets.
q The best thing to do sometimes isn’t to overthink or to
overdesign the algorithm but rather to implement something
quick and then to iterate to improve it.
q We take the example of the generative learning algorithm Naive
Bayes which is often a good candidate for a quick
implementation.
Generative vs Discriminative
Given a training set ...
Discriminative Model
q For example:
§ Logistic Regression
§ (which we may fit with Gradient Descent)
q After some iterations, one after one innovation, we get a decision boundary.
Discriminative model
Discriminative model
We are basically looking
at all of our data and Malignant Tumors
trying to find a straight
line that separates the
Malignant Tumors from
the benign Tumors
Benign Tumors
Generative Model
q Let’s focus on the Benign Tumors to start (look at blue
circles).
q You see that the most Benign Tumors tend to lie in the blue
region of space.
Generative Model
Benign
Generative Model
q We will then turn our attention to the Malignant Tumors, we
focus our attention on them.
q You see that the most Malignant Tumors tend to lie in the
red region of space.
Generative Model
Malignant
Generative Model
Generative Model
If a New Patient
comes in with
features x1 and x2 …
Generative Model
q What Generative Algorithm does is to build a model of each
of the two classes and then mix classification predictions
based on:
« looking at your example and comparing it to your two
models to see whether it looks like more Benign or Malignant
Tumor »
Example
Let’s compute
! "#=% !(#$%)
p(y=1|x) = ! "#=% ! #$% (! "#=5 !(#$))
).)+
= ).)+().)%
= 0.75