# How can I improve the accuracy of my confusion matrix to 100%? [closed]

Is there a possibility of attaining the above? Can someone share with me how to go about doing it if it is?

• Whether or not this is possible and realistic goal depends heavily on the problem domain and nature of your data. Could you please share some more details by using edit to add this information to the question? Apr 11, 2019 at 8:04

Bayes error

To answer your question, first I should explain Bayes error. Assuming we know the exact joint distribution of feature vectors ($$\mathbf{x}$$) and each class ($${C_k}$$) as $$P(\mathbf{x},{C_k})$$, we build a classifier which assigns label $$k$$ to each feature vector by this criteria $$\mathop {\arg \max }\limits_k P(\left. {{C_k}} \right|\mathbf{x})$$ It can be shown that this is the best possible classifier by calculating the expected classification error on the whole feature space. This expected classification error is called Bayes error and is the minimum achievable classification error for this feature-label space.

Training error

If you evaluate your model on the training data and calculate confusion matrix using the training samples you may achieve 100% accuracy because your model may overfit your training data. It means your training error is 0 even the Bayes error may not be.

Generalization error

If you evaluate your model on the test data and calculate confusion matrix using the test samples you can not achieve 100% accuracy because you are evaluating the generalization capability of your model and its error can not be less than Bayes error.

• This is the most realistic and general answer for the question as written. However, OP might be working on a problem where 100% generalisation accuracy is theoretically possible (i.e. Bayes error is zero). They might also have a data set where it is practical to train for this goal (enough coverage of function domain that a ML approximation can get arbitrarily close to 100% accuracy). These things are highly unlikely for many real world examples, but perhaps OP has some kind of special case. Apr 11, 2019 at 8:10
• @NeilSlater I’m very proud you approved of my answer Neil. Thanks for your comments which led to further clarification. Apr 11, 2019 at 10:29

Achieving such accuracy is hard but not impossible, especially when you test your model in real life to see if the model can achieve the same accuracy or not. Here are some tips that help to improve your model accuracy:

1- Change the algorithm that you used to train your model, for example, if you use a traditional machine learning algorithm like SVM, try using one of the deep learning algorithms such as CNN.

2- Obtain more data, change the quality of your data, do augmentation for your data, do some pre-processing on your data, or try other pre-processing techniques if you did already.

For more, see here, here or here.