I have a trained model and with this I can classify faces, if I test the classifier by entering the same negative samples (not faces) with which I train, is it possible to know if my model is overfitted from the classification results I will get?
2 Answers
You seem to have an incomplete understanding of what overfitting is. Let's take your example with face recognition: you want the model you are training to distinguish between images showing a face and those that do not.
To do that you present your model with a selection of images, some of which show a face and others that do not, and explicitly pass this information to the model - this is the supervision in supervised learning.
Note that I wrote 'a selection of images', because it is unfeasible to show your model all possible forms a face could take and everything that is not a face. With larger selections of images, we can get more confident that a model can learn the pattern 'face' well enough - that is, in an abstract sense, 'what is it that makes a face look like a face?'
Returning to the question at hand: overfitting in this example would mean that the model's notion of the pattern 'face' ends up too narrowly constrained to the particular images we showed it. This means it poorly generalizes the pattern 'face', an extreme case of overfitting could be summarized from the model's perspective as 'does this picture match any face-picture I've been trained on? -> Y/N'
And now we can understand why the suggestion in your question is somewhat odd: your model's predictions for the negative training samples don't really tell us much about this at all. However if we have more data previously unseen by the model, we can investigate whether the model might be overfitted. If for example all or most of the positive images in the new data are predicted to be negative, one should get suspicious, since this could be caused by the model overfitting the training data.
-
$\begingroup$ I mentioned in a comment above that I understand the concept of overfitting, but I asked this question due to a recommendation made to me. My model is correctly classifying new positive samples that were not used during training. $\endgroup$– SRGCommented Sep 12, 2019 at 20:19
To get you into the concept of overfitting and underfitting, here is a small approach for you:
In Machine Learning you need to split your data in Train and test data:
1. Train Part
X_Train, y_train
where X_train
are your futures and y_train
is your target variable (in your case a binary target:
1: it is a face, 0 it is not a face)
Then with this training data you are training your data.
classifier_train(X_train, y_train
)`
Your classifier is trained. You can also measure your classifier now with the training data, where you do: y_train_predict = classifier_prediction(X_train)
, so you will get an score between: (y_train, y_train_predict)
, this is your training score/accuracy
2. Test Part
Now the other part of your data comes in, your test data: Now you do not train your algorithm again, you only use the trained classifier, and run a prediction for your test data:
y_test_predict = classifier_prediciton(X_test)
with this you can also get an score (y_test, y_test_predict)
this will be your test score.
3. Comparing train and test results
If you have an train accuracy now from 0,99% and a test accurarcy from 0,2% your training is overfitting, which means that it is only good for known data and not for unknown data, this two scores should be balanced.
-
$\begingroup$ I understand the concept of sub-adjustment and the over-adjustment, I know that when performing a cross-validation, in the validation phase I get an accuracy of 94% for example and then in the test phase I get an accuracy of 100% so my model is not overfitted Because these values are not very different. However, one person told me to re-enter all the negative samples (not faces) of the training phase to the model that I have already trained and with that I could see if it is overtrained but I cannot know in what way I can conclude that from Negative samples $\endgroup$– SRGCommented Sep 12, 2019 at 20:12