In the last segment, you learnt the importance of having evaluation metrics other than accuracy. Thus, you were introduced to two new metrics – **sensitivity** and **specificity**. You learnt the theory of sensitivity and specificity and how to calculate them using a confusion matrix. Now, let’s learn how to calculate these metrics in Python as well.

As you saw in the code, you can access the different elements in the matrix using the following indexing –

PowerShell

```
TP = confusion[1,1] # true positive
TN = confusion[0,0] # true negatives
FP = confusion[0,1] # false positives
FN = confusion[1,0] # false negatives
```

And now, let’s rewrite the formulas of sensitivity and specificity using the labels of the confusion matrix.

Sensitivity=True Positives\True Positives+False Negatives

Specificity=True Negatives\True Negatives+False Positives