Laboratory Work Preparation: Lab Work 9: Binary Classification
Laboratory Work Preparation: Lab Work 9: Binary Classification
Laboratory Work Preparation: Lab Work 9: Binary Classification
BINARY CLASSIFICATION
What is binary classification?
Binary or binomial classification is the task of assigning samples into two classes
according to a decision. In medicine, such binary decisions are most frequent, as
we commonly want to know whether the observed subject is diseased or healthy.
Actual condition: Test results:
- positive samples – P - positive results – RP
Number of diseased subjects. Number of positive subjects.
- negative samples – N - negative results – RN
Number of healthy subjects. Number of negative subjects.
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 3 / 18
BINARY CLASSIFICATION
Classification of the results
The samples can be, according to the actual condition and the test results,
classified into four groups:
- true positives – TP - true negatives – TN
The number of diseased subjects The number of healthy subjects
(P) that are correctly classified (N) that are correctly classified
as diseased (RP). as healthy (RN).
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 4 / 18
BINARY CLASSIFICATION
Classification of the results (2)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 5 / 18
BINARY CLASSIFICATION
Contingency table
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 6 / 18
BINARY CLASSIFICATION
Ideal classification
threshold t threshold t
RP RN RP RN
diseased (P)
Subjects (P, N)
TP TP TN
result
result
healthy (N)
TN
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 7 / 18
BINARY CLASSIFICATION
Real classification
Subjects (P, N)
TP TP TN
FN FP FN
result
result
FP
healthy (N)
TN
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 8 / 18
BINARY CLASSIFICATION
Performance measures
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 9 / 18
BINARY CLASSIFICATION
Performance measures (2)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 10 / 18
BINARY CLASSIFICATION
Performance measures (3)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 11 / 18
BINARY CLASSIFICATION
Performance measures (4)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 12 / 18
BINARY CLASSIFICATION
ROC curve (2)
FNR
FPR TNR
(sensitivity)
TPR
TPR
0
0 FPR 1
(non-specificity)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 13 / 18
BINARY CLASSIFICATION
ROC curve (2)
RP RN
1
subjects
TP TN
1 1
result
2
2
3
TPR
TP TN
FP FN
result
3
0
FP FN 0 FPR 1
result
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 14 / 18
BINARY CLASSIFICATION
ROC curve (3)
The area under the [ROC] curve (AUC) is equal to the probability that
a (diagnostic) test will classify a randomly chosen positive sample better
than a randomly chosen negative sample.
The test (or its success) can be therefore 1
labeled as:
- excellent
1.0 ≥ AUC > 0.9
- good
TPR
0.9 ≥ AUC > 0.8 AUC
- fair
0.8 ≥ AUC > 0.7
- poor
0
0.7 ≥ AUC > 0.6
0 FPR 1
- fail
0.6 ≥ AUC > 0.5
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 15 / 18
BINARY CLASSIFICATION
Example
TP TP 8 TP TP 8
TPR = = = = 40.0% PPV = = = = 66.7%
P TP + FN 8 + 12 RP TP + FP 8 + 4
TN TN 12 TN TN 12
TNR = = = = 75.0% NPV = = = = 50.0%
N TN + FP 12 + 4 RN TN + FN 12 + 12
FP FP 4 FP FP 4
FPR = = = = 25.0% FDR = = = = 33.3%
N TN + FP 12 + 4 RP TP + FP 8 + 4
FN FN 12 TP + TN 8 + 12
FNR = = = = 60.0% ACC = = = 55.6%
P TP + FN 8 + 12 P+N 36
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 16 / 18
LABORATORY WORK
Lab work 9: Binary classification
You will select a classification threshold and assign the subjects into groups
(TP, TN, FP and FN), and then compute the performance measures (TPR,
TNR, FPR, FNR, PPV, NPV, FDR and ACC). According to the obtained
results at different classification thresholds you will display ROC curves
and finally compute the AUC for the ROC curve.
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 17 / 18
LABORATORY WORK
Lab work 9: Binary classification
consecutive
subject
number actual condition
results of four
(0 = healthy,
different tests
1 = diseased)
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course
Lab Work 9: Binary classification 18 / 18
CONCLUSION
Discussion, comments, questions…
University of Ljubljana, Faculty of Electrical Engineering BIOMEDICAL INFORMATICS Electrical Engineering, level 2
Laboratory of Imaging Technologies Assoc. Prof. Tomaž Vrtovec, Ph.D. International course