# I can't explain this precision score

I am printing out the precision score and confusion matrix using sklearn.

print("Confusion matrix:")
print(confusion_matrix(test_y, predict_y))
print("Precision:", precision_score(test_y, predict_y))


The output is:

Confusion matrix:
[[910  16]
[ 47 177]]
Precision: 0.917098445595855


According to the confusion matrix:

True positive = 177 False positive = 47

Precision should be 177/(177+47) or about 0.79. This doesn't match what sklearn is showing as precision. What am I doing wrong here?

$$177/(177+16) = 0.9170984$$, so it looks like the top right cell ($$16$$) is the False Positives, rather than the bottom left one ($$47$$). Looks like a simple mismatch between your understanding and the actual code.