Answers.Body: <blockquote>
  <p>From the loss graph I would conclude, that at approx 2k steps overfitting starts, so using the model at approx 2k steps would be the best choice. But looking at the precision graph, training e.g. until 24k steps would be a much better model. Which one is the best model?</p>
  </blockquote>
  <p>Different metrics will lead you to different conclusions. To detect overfitting under any metric you do need to plot training and validation/dev of the same metric, so it is harder to spot on your second graph.</p>
  <p>The reason why loss/cost functions and other metrics can disagree on what the best model is, is due to sensitivity to different types of error. Often loss functions will be sensitive to outliers - large differences in predictions versus ground truth in the training or validation data. So it is common to see loss diverging between validation and train first - probably due to a very few bad predictions caused by difficult edge cases that the model is not coping well with - whilst metrics such as accuracy may continue to improve on validation and test sets.</p>
  <p>The way to resolve this is to pick the metric that is important to you for business reasons (ideally ahead of the training, so you are not biased in your own decision about what to do), and use that to make judgement calls. This is easier to rely on the larger and cleaner your dataset is.</p>
  <p>One other thing you can do is to some error analysis - find the worst cases for loss function, and check that they are labelled correctly.</p>
  <p>If things still look inconclusive to you, and dataset size is small enough that results are noisy, then consider using k-fold cross validation to reduce effects of sample bias. This takes more time, but may improve your confidence in your model selection process.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-05-23T14:38:15.367Z
Answers.LastActivityDate: 2022-05-23T14:52:02.283Z
Answers.LastEditDate: 2022-05-23T14:52:02.283Z
Answers.UserDisplayName: Neil Slater
Answers.Body: <p>Generally, a model is considered to be overfitted when there's a huge gap between training and test/validation performances.</p>
  <p>So during the training, you monitor the loss on validation data, and training data, and stop training if validation loss stagnates/increases given the training loss keeps decreasing.</p>
  <p>In your scenario, I'm not sure what the total loss metric corresponds to. As I said, you've to measure loss on a held-out data other than training data to detect, and prevent overfitting.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-01T19:50:48.423Z
Answers.Text: Thank you @SpiderRico. According to your statement, I would stop training at around 2k steps. My question is: why should I stop training if validation based (held-out data) mean average precision (mAP) further increases?
Answers.UserDisplayName: user1091141
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-28T07:59:54.060Z
Answers.LastActivityDate: 2021-04-28T07:59:54.060Z
Answers.UserDisplayName: SpiderRico
Body: <p>I am training an object detection machine learning pipeline. Among the many metrics provided out of the box by tensorflow object detection API, I look at <em>total_loss</em> and <em>DetectionBoxes_Precision/mAP@.75IOU</em>:</p>
  <p><a href="https://i.sstatic.net/oEsLQ.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/oEsLQ.png" alt="enter image description here" /></a><a href="https://i.sstatic.net/2eygc.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2eygc.png" alt="enter image description here" /></a></p>
  <p>Here the x-axis is the number of steps i.e. model experience. The orange line is for the training data and the blue line is for the validation data.</p>
  <p>From the loss graph I would conclude, that at approx 2k steps overfitting starts, so using the model at approx 2k steps would be the best choice. But looking at the precision graph, training e.g. until 24k steps would be a much better model.
  Which one is the best model?</p>
  <p>Here, loss and the precision metric where picked just for illustrating the dilemma, there are many more metrics available, leading to multiple conclusions about when overfitting actually starts.</p>
  
Tags: <machine-learning><object-detection><overfitting><generalization>
Title: When exactly am I overfitting -- contradicting metrics
UserDisplayName: user1091141
ThreadText: # When exactly am I overfitting -- contradicting metrics
  
  (Asked by: username_0 on 2021-04-26)
  
  I am training an object detection machine learning pipeline. Among the many metrics provided out of the box by tensorflow object detection API, I look at *total\_loss* and *DetectionBoxes\_Precision/mAP@.75IOU*:
  
  [![enter image description here](https://i.sstatic.net/oEsLQ.png)](https://i.sstatic.net/oEsLQ.png)[![enter image description here](https://i.sstatic.net/2eygc.png)](https://i.sstatic.net/2eygc.png)
  
  Here the x-axis is the number of steps i.e. model experience. The orange line is for the training data and the blue line is for the validation data.
  
  From the loss graph I would conclude, that at approx 2k steps overfitting starts, so using the model at approx 2k steps would be the best choice. But looking at the precision graph, training e.g. until 24k steps would be a much better model.
  Which one is the best model?
  
  Here, loss and the precision metric where picked just for illustrating the dilemma, there are many more metrics available, leading to multiple conclusions about when overfitting actually starts.
  
  **Tags:** machine-learning, object-detection, overfitting, generalization
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-05-23. Score: 1 | Accepted answer
  
  > From the loss graph I would conclude, that at approx 2k steps overfitting starts, so using the model at approx 2k steps would be the best choice. But looking at the precision graph, training e.g. until 24k steps would be a much better model. Which one is the best model?
  
  Different metrics will lead you to different conclusions. To detect overfitting under any metric you do need to plot training and validation/dev of the same metric, so it is harder to spot on your second graph.
  
  The reason why loss/cost functions and other metrics can disagree on what the best model is, is due to sensitivity to different types of error. Often loss functions will be sensitive to outliers - large differences in predictions versus ground truth in the training or validation data. So it is common to see loss diverging between validation and train first - probably due to a very few bad predictions caused by difficult edge cases that the model is not coping well with - whilst metrics such as accuracy may continue to improve on validation and test sets.
  
  The way to resolve this is to pick the metric that is important to you for business reasons (ideally ahead of the training, so you are not biased in your own decision about what to do), and use that to make judgement calls. This is easier to rely on the larger and cleaner your dataset is.
  
  One other thing you can do is to some error analysis - find the worst cases for loss function, and check that they are labelled correctly.
  
  If things still look inconclusive to you, and dataset size is small enough that results are noisy, then consider using k-fold cross validation to reduce effects of sample bias. This takes more time, but may improve your confidence in your model selection process.
  
  
  ---
  
  ### Answer by username_2 on 2021-04-28. Score: 0
  
  Generally, a model is considered to be overfitted when there's a huge gap between training and test/validation performances.
  
  So during the training, you monitor the loss on validation data, and training data, and stop training if validation loss stagnates/increases given the training loss keeps decreasing.
  
  In your scenario, I'm not sure what the total loss metric corresponds to. As I said, you've to measure loss on a held-out data other than training data to detect, and prevent overfitting.
  
  > **Comments:**
  > **username_0**: Thank you @username_2. According to your statement, I would stop training at around 2k steps. My question is: why should I stop training if validation based (held-out data) mean average precision (mAP) further increases?  
  
  ---
  
  