Given training loss, training accuracy, validation loss, and validation accuracy, determine whether the model is overfitting, underfitting, or performing well (good fit).
def detect_fitting(train_loss, train_acc, val_loss, val_acc,
loss_threshold=0.1, acc_threshold=0.05):
loss_gap = val_loss - train_loss
acc_gap = train_acc - val_acc
if train_acc < 0.6 and val_acc < 0.6:
return "underfitting"
if loss_gap > loss_threshold or acc_gap > acc_threshold:
return "overfitting"
return "good fit"loss_threshold and acc_threshold control how much gap is tolerable.