# How can I minimise the false positives?

I have 50,000 samples. Of these 23,000 belong to the desired class $$A$$. I can sacrifice the number of instances that are classified as belonging to the desired class $$A$$. It will be enough for me to get 7000 instances in the desired class $$A$$, provided that most of these instances classified as belonging to $$A$$ really belong to the desired class $$A$$. How can I do this?

The following is the confusion matrix in the case the instances are perfectly classified.

[[23000   0]
[  0 27000]]


But it is unlikely to obtain this confusion matrix, so I'm quite satisfied with the following confusion matrix.

[[7000   16000]
[  500 26500]]


I am currently using the sklearn library. I mainly use algorithms based on decision trees, as they are quite fast in the calculation.

• Hi and welcome to this community! I've reformulated part of your post to make it clearer. Make sure I've not changed the intended meaning. – nbro Dec 2 '19 at 23:44
• I have two classes. I'm only interested in the first one. As a rule the desired class is called positive. It is important to me that in the positive class got as little as possible false negative labels that are predicted. I added two examples with a confusion matrix. – user287629 Dec 2 '19 at 23:50
• That's what I thought. I've provided an answer below. I may edit it later to provide a complete example. – nbro Dec 2 '19 at 23:52

In this answer to the question How can the model be tuned to improve precision, when precision is much more important than recall?, the user suggests performing a grid search (using sklearn.grid_search.GridSearchCV(clf, param_grid, scoring="precision")) to find the parameters of the model that maximize the precision. See also the question Classifier with adjustable precision vs recall.