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.