I am new to machine learning and it might be a bit of a stupid question.

I have implemented my model and its working. I have a question about running it on the testing data. Its a binary classification problem. If I know the proportions of classes in test data how could I use it to improve the performance of my model or prediction made by the model. So lets say 75% belong to class 1 and 25% to class 0

Any help is greatly appreciated


No, your model isn't supposed to know about your test data, if you include clues in your training about what's in your test data, you will do something called Data Leakage.

Data leakage would lead to Over-fitting which will give you good results on that particular test set, but won't generalize to other data.

Lets say, you deploy this model in production and feed into it real-life data that it never encountered before, the predictions will be below the expectations you had in the training/testing phases because of those two phenomenons i mentioned.

I suggest you tweak a bit more your model during the training phase, maybe clean your data more, do something called OverSampling and UnderSampling if the target classes are imbalanced (You have for example 90% / 10% proportions in your training dataset), pick better features etc..

In conclusion: adjusting your model to have good predictions on your test data, in particular, is not good practice and will lead to creating a bad model on unseen data.


If your results differ from expectations, you should look at individual errors and use those to correct the machine learning. If you use the percentage, the algorithm will potentially learn something completely different from what it's supposed to learn.

However, if you really do need to go by such stats (for instance because your machine learning is supposed to learn about it's own mistakes and how to correct them autonomously), I suggest adding another dimension to your learning ability - like 'confidence', which increases in the nodes which were involved in a better result and decreases in the nodes which were involved when things went worse. Nodes with low confidence might change faster or stop their activity completely. Nodes with high confidence would change less easily.

As you didn't detail which learning algorithm you use, node can be anything from a datapoint in a table to a simulated neuron or it's individual connections.

One level higher, your model may include a module which tracks the connections between changes in confidence. This would allow avoiding cycles of one increase always coming with a decrease elsewhere, and vice versa. Or an actually wrong circuit developing false confidence and damaging the learning in the rest of your model... So if 5 increases in confidence in one area lead to 6 decreases in confidence in another area in the next round (i.e., worse longterm results), the confidence changes might be done differently. This module would obviously also learn to chose better what to influence when - in the normal way.

It will require some fine tuning before that module will make learning faster than just the usual approach. Prepare for lots of test sets - or a game where your different models play against one another with similar data, and might be fine tuned using the evolutionary approach.

You should also make sure that you find a way to test the ai with atypical data - and a way for it to see whether the strange results were correct in the same way humans do tests and then get the solutions.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.