# Supervised Learning 2 – Classification

Thu Apr 05 2018

Let us say we have a group a houses and want to group in 2 groups. Houses that are over-valued in value and houses that are under-valued and buy the under-valued houses.

f([X1, X2, X3, X4]) = Y [1|0]

So f(x) will output a number between 0,1. Then we can create a threshold to either set it to 0 or 1 where 0 is under-valued house and 1 is over-valued house

```TP (true positive) = when we predict 1 and it is 1 (over-valued)
TN (true negative) = when we predict 0 and it is 0 (under-valued)
FP (false positive) = when we predict 1 and it is 0
FN (false negative) = when we predict 0 and it is 1```

[TN, TN, TN, FN, | FP, TP, TP]
0——————0.5————1

The threshold can be 0.5, 0.3 e.t.c. So we may lower the threshold to reduce the false positives and not buy houses that are over-valued.

[TN, TN, TN, | TP, FP, TP, TP]
0———–0.3——-0.5————1

Confusion matrix

 1 0 1 3 1 0 3

Threshold = 0.3

```Accuracy = (TP + TN) / (TP + FP + TN + FN) = 6 / 7 = 0.86

Precision = TP / (TP + FP) = 3 / 3+1 = 3 / 4 = 0.75

Recall or True Positive Rate = TP / (TP + FN) = 3 / 3+0 = 1

False positive rate = FP / (FP + TN) = 3 / 3+1 = 3/4```

Full Stack Weekly Newsletter

A free weekly newsletter for full stack web developers!