c17hawke
- Sunny Chandra
In machine learning and statistics, classification is -
the problem of identifying to which of a set of categories (sub-populations) a new observation belongs,
on the basis of a training set of data containing observations (or instances) whose category membership is known.
-Wikipedia
c17hawke
T | N
T | P
F | N
F | P
0 | 0'
1 | 1'
1 | 0'
0 | 1'
0'
0
1
1'
Actual class
Predicted or Guessed
c17hawke
| Actual | Guessed | Interpretation | |
|---|---|---|---|
| TN | T | N | Guessed (-ve) and True |
| FP | F | P | Guessed (+ve) but False |
| FN | F | N | Guessed (-ve) but False |
| TP | T | P | Guessed (+ve) and True |
c17hawke
| x | y | label |
|---|---|---|
| 0 | 0 | - |
| 1 | 0 | - |
| 1 | 1 | - |
| 3 | 3 | + |
| 3 | 2 | + |
| 2 | 3 | + |
x
y
| x | y | label |
|---|---|---|
| 0 | 0 | - |
| 1 | 0 | - |
| 1 | 1 | - |
| 3 | 3 | + |
| 3 | 2 | + |
| 2 | 3 | + |
| - | + | |
|---|---|---|
| - | 3 | 0 |
| + | 0 | 3 |
Confusion
Matrix
y
x
PERFECT CLASSIFIER
y
x
| x | y | label |
|---|---|---|
| 0 | 0 | - |
| 1 | 0 | - |
| 1 | 1 | + |
| 3 | 3 | + |
| 3 | 2 | - |
| 2 | 3 | + |
y
x
| x | y | label |
|---|---|---|
| 0 | 0 | - |
| 1 | 0 | - |
| 1 | 1 | + |
| 3 | 3 | + |
| 3 | 2 | - |
| 2 | 3 | + |
| - | + | |
|---|---|---|
| - | 2 | 1 |
| + | 1 | 2 |
Confusion
Matrix
FN
FP
y
x
| x | y | label |
|---|---|---|
| 0 | 0 | - |
| 1 | 0 | - |
| 1 | 1 | - |
| 3 | 3 | + |
| -3 | -3 | + |
| 3 | -3 | + |
| - | + | |
|---|---|---|
| - | 3 | 0 |
| + | 0 | 3 |
Confusion
Matrix
y
x
y
x
| x | y | z | label |
|---|---|---|---|
| 0 | 0 | 1 | - |
| 1 | 0 | 2 | - |
| 1 | 1 | 1 | - |
| 3 | 3 | 4 | + |
| -3 | -3 | 3 | + |
| 3 | -3 | 2 | + |
In classification, models are nothing but graphs ( line, curve, surface, etc) that separates two or more classes.
x
y
In Regression, models are nothing but graphs ( line, curve, surface, etc) that fits through the datapoints.
x
y
The MNIST database (Modified National Institute of Standards and Technology database)
is a large database of handwritten digits.
c17hawke
let's say we have 10,000 data point (handwritten text) in the Training set
Our task -
detect whether a no. is 5 or not
Note:
Total no. of 5s are 1000 => other digits are 9000 in total
c17hawke
c17hawke
accuracy =
TP + TN
TP + TN + FP + FN
c17hawke
Precision =
How many are actually 5 ?
Out of nos. classified as 5
=
TP
TP + FP
c17hawke
Recall =
How many are classified as 5 ?
Out of nos. that are actually 5
=
TP
TP + FN
c17hawke
when no. of 5s (i.e. P's ) = 1000
no. of other digits are (i.e. N's) = 9000
T | N
T | P
F | N
F | P
0 | 0'
1 | 1'
1 | 0'
0 | 1'
0'
0
1
1'
Actual data
Predicted or Guessed
9000
1000
0
0
Precision = ?
Accuracy = ?
Recall = ?
FIND
c17hawke
Precision =
TP
TP + FP
Recall =
TP
TP + FN
accuracy =
TP + TN
TP + TN + FP + FN
c17hawke
when no. of 5s (i.e. P's ) = 1000
no. of other digits are (i.e. N's) = 9000
T | N
T | P
F | N
F | P
0 | 0'
1 | 1'
1 | 0'
0 | 1'
0'
0
1
1'
Actual data
Predicted or Guessed
0
0
9000
1000
Precision = ?
Accuracy = ?
Recall = ?
FIND
c17hawke
Precision =
TP
TP + FP
Recall =
TP
TP + FN
accuracy =
TP + TN
TP + TN + FP + FN
c17hawke
c17hawke
F1 score =
2
1
Precision
+
Recall
1
c17hawke
We need to choose our Performance measurers as per our Problem statement
Examples ->
c17hawke
Classify safe videos for kids =>
AIM -
(as low as possible) FP =>
(doesn't affect much) FN =>
=>
Precision >
Recall
Preference -
c17hawke
Precision=
TP
TP + FP
Recall =
TP
TP + FN
Shoplifting detection using camera feed at a shopping mall =>
Precision=
TP
TP + FP
Recall =
TP
TP + FN
AIM -
(doesn't affect much) FP =>
(as low as possible) FN =>
=>
Precision <
Recall
Preference -
c17hawke
COVID-19 testing =>
Precision=
TP
TP + FP
Recall =
TP
TP + FN
AIM -
(as low as possible) FP =>
(as low as possible) FN =>
=>
both should be high
Preference -
c17hawke
go for high f1 score
when precision is high => Recall will be low
and vice a versa
This is nothing but Precision-Recall Tradeoff
c17hawke
F =
x
β
x
precision
+
recall
α ∈ [0, 1]
F =
1
1
x
precision
+
1
x
recall
(1 - α)
α
α
precision
recall
(1 + β )
β
2
2
x
β ∈ [0, +∞]
F =
2
1
precision
+
1
recall
1
More Stuff
Precision | Positive Predictive value(PPV)
Recall | Sensitivity |Hit rate |
True Positive rate (TPR)
specificity|selectivity |
True negative rate (TNR)
False negative rate (FNR)
False positive rate (FPR)
P = TP + FN
N = TN + FP
| TN | FP |
| FN | TP |
P(1)
N(0)
Actual
Predicted