Precision measures how often a positive result is correct. In search, it is the proportion of retrieved documents that are relevant; in classification, it is the proportion of items labeled positive that truly belong to the positive class. Precision = true positives / all predicted positives. section 2.3.2 section 4.2.1
Flagging toxic comments
A classifier labels 1,038 test comments as toxic, but only 125 are truly toxic. Its precision is 125 / 1,038, or about 12%. The remaining 913 flags are false positives: nontoxic comments labeled toxic. Low precision can increase moderators’ workload or lead to legitimate comments being hidden. section 4.2.1
>>> from sklearn.metrics import confusion_matrix
>>> confusion_matrix(y_test, lda.predict(X_test))
array([[1261, 913],
[ 201, 125]], dtype=int64)
The confusion matrix shows 125 correctly flagged toxic comments and 913 nontoxic comments incorrectly flagged as toxic. section 4.2.1
Recall asks a different question: of all the items that really are positive, how many were found? The same classifier identifies 125 of 326 toxic comments, for a recall of 38.3%. Labeling every comment toxic would give perfect recall, but precision would suffer because most comments are nontoxic. The preferred balance depends on the application. section 4.2.1
Search normalization
Normalizing capitalization can return documents matching both “Age” and “age,” increasing recall. But it can also return documents the searcher does not want, reducing precision. Quoted queries can request exact matches; supporting both behaviors in a search pipeline requires indexes with normalized and original capitalization. section 2.3.2



















