1
$\begingroup$

Since I have started tinkering with ML, I have been hearing about the dangers of overfitting, and I definitely understand the concern. I also understand that according to many, diagnosing overfitting is an art, not a science.

However, assume that it is a science, and that we have a formal definition of overfitting, such as the one offered in one of the courses I took on ML:

w1 is an overfit model iff there is a w2 such that:

(a) training error(w1) < training error(w2),

(b) test error(w1) > test error(w2)

Here is the code and output (Traning set: 900 samples from 2015-2016; Test set: 227 samples from 2017). :

SCORING3 = accuracy_score
SCORING = roc_auc_score
model_num = 0
for Cs in [10.0, 1.0]:
    model_num += 1
    log_l1_model = LogisticRegression(penalty='l1',tol=0.001, C= Cs,\
                                      fit_intercept=False, intercept_scaling=1,\
                                      class_weight=None, solver='liblinear', n_jobs = -1)

    log_l1_model.fit(Train_X, Train_y)

    y_hat_train = log_l1_model.predict(Train_X)
    y_hat = log_l1_model.predict(Test_X)

    print "model w"+str(model_num), "training ROC_AUC_score :", SCORING(Train_y, y_hat_train)
    print "model w"+str(model_num),"test ROC_AUC_score :",  SCORING(Test_y, y_hat), '\n'

    print "model w"+str(model_num),"training ACCURACY_score :", SCORING3(Train_y, y_hat_train)
    print "model w"+str(model_num),"test ACCURACY_score :",  SCORING3(Test_y, y_hat)
    print '***************************************************' 

model w1 training ROC_AUC_score : 0.556576576577
model w1 test ROC_AUC_score : 0.57170846395 

model w1 training ACCURACY_score : 0.841573033708
model w1 test ACCURACY_score : 0.70625
***************************************************
model w2 training ROC_AUC_score : 0.519954954955
model w2 test ROC_AUC_score : 0.5 

model w2 training ACCURACY_score : 0.833707865169
model w2 test ACCURACY_score : 0.725
***************************************************

Given the evidence of this two-model run, and the "formal" definition above, w1 is overfit relative to the accuracy_score metric, but it is not overfit relative to the roc_auc_score metric.

Question: Is this "hidden" relativity in the formal definition of "overfit" an insurmountable obstacle to any attempt to give a formal definition?

I can see that the answer could be "no" if one could uniquely identify a metric as "the correct metric relevant to one's purpose" (e.g. minimizing false positives), but all I have read and heard also suggests that this is often not possible.

$\endgroup$
1
  • $\begingroup$ The formal definition is fine as a definition, the problem is that it is useless as a practical diagnostic test as you may not be able to find the w2 in question even if it exists. In the end you are searching for the best model you can find, and i in practice the best model you can make is overfit (see "benign overfitting") $\endgroup$ Commented Oct 25 at 7:21

1 Answer 1

0
$\begingroup$

I'm sceptical of your "formal" definition, since there is an infinite set of models for every model accepting reals as input, even if one eliminates irrational reals. For models accepting only finite sets of discrete inputs, there are still a combinatorially large set of models. Since a simple lookup table is a valid model, eg, for three binary features, the following is a model:

x_1 x_2 x_3   y
  0   0   0   0
  0   0   1   0
  0   1   0   1
  0   1   1   0
  1   0   0   1
  1   0   1   1
  1   1   0   1
  1   1   1   0

A lookup table can have any arbitrary inputs and outputs defined. Therefore, if you have access to the training data and test data, you can construct a model $w_2$, such that:

  • for every example on the training set, $w_2$ gives the wrong answer
  • for every example on the test set, that is not in the training set, $w_2$ gives the correct answer

In the general case, $w_2$ thus constructed will thus meet the conditions of overfit you have proposed. And since the formal definition you are proposing only requires the existence of such a $w_2$, it is perfectly legitimate to look at the training and testing data to construct such a $w_2$.

Therefore, I am sceptical that the proposed formal definition of overfit is a valid test for overfitting?

$\endgroup$
6
  • $\begingroup$ Not my formal definition :) Also, I am not defending the existence of a formal definition. My question has the form: "Given fact X, isn't any attempt at a formal definition doomed?" $\endgroup$ Commented Mar 15, 2017 at 15:47
  • $\begingroup$ Well, then, I tentatively agree with your tentative conclusion :-) But, just out of curiosity, what are your ideas on a more robust formal definition? $\endgroup$ Commented Mar 15, 2017 at 22:37
  • $\begingroup$ If my life depended on it, I would try cheating like Captain Kirk. I would relativize to sample size and metric, and try convincing people that defining a four-place predicate, x is more (less) overfit than y for sample s and metric m might be much healthier. I believe that Hume had it right: "Every pattern-projection from the unobserved to the observed is overfit" (my paraphrasing of the "problem of induction"). $\endgroup$ Commented Mar 16, 2017 at 4:51
  • $\begingroup$ I dont think formal definitions tend to be statistical in nature, on the whole, though I suspect it might involve an expectation somewhere. But, forgetting about formal definitions temporarily, normally the way one detects overfitting is that test error is higher than training error. But ... isnt that pretty much systematically the case? As I write, I'm thinking that the best you can expect to do is quantify how much overfit, rather than give some binary overfit/not overfit result? $\endgroup$ Commented Mar 16, 2017 at 9:06
  • $\begingroup$ If you can have a "how much overfit" measure, you can get from that to the ranking-relation I mention above (still relative to a metric). $\endgroup$ Commented Mar 16, 2017 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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