How much of neural network overconfidence in predictions can be attributed to modelers optimizing threshold-based metrics? Neural network "classifiers" output probability scores, and when they are optimized via crossentropy loss (common) or another proper scoring rule, they are optimized in expectation by the true probabilities of class membership.
However, I have read on Cross Validated and perhaps elsewhere that neural networks are notorious for being overly confident. That is, they will be happy to predict something like $P(1) = 0.9$ when they should be predicting $P(1) = 0.7$, which still favors class $1$ over class $0$ but by less.
If neural networks are optimizing a proper scoring rule like crossentropy loss, how can this be?
All that comes to mind is that the model development steps optimize improper metrics like accuracy. Sure, the model in cross validation is fitted to the training data using crossentropy loss, but the hyperparameters are tuned to get the highest out-of-sample accuracy, not the lowest crossentropy loss.
(But then I figure that the model would be less confident in its predictions. Why be confident in your prediction when you get the right classification with a low-confidence classification like $0.7$ than a high-confidence classification like $0.9$?)

There are some interesting properties about cross entropy loss (well, even logistic loss).
Not only we want to classify the instance correctly, we want strong options
Please check following example, note, weakly and correctly classifying one data point is almost as bad ad wrongly classifying the point.
  import numpy as np

  def cross_entropy(pred_prob, target): 
      return -np.sum(np.log(pred_prob) * (target))

  target = np.array([1,0,0])

  pred_prob = np.array([1/3,1/3,1/3])
  print('3 classes, even dist\t',cross_entropy(pred_prob, target))

  pred_prob = np.array([0.3334,0.3333,0.3333])
  print('3 classes, weakly right \t',cross_entropy(pred_prob, target))

  pred_prob = np.array([0.3333,0.3333,0.3334])
  print('3 classes, weakly wrong \t',cross_entropy(pred_prob, target))

I also had a related question here
What are the impacts of choosing different loss functions in classification to approximate 0-1 loss
In addition, the as discussed in another answer, one major reason model is confidently wrong is the overfitting.
I recently had some interesting ideas on what may be happening inside DNN. I think essentially the overfitted model is trying to learn some "hash functions" and hardly remember "the has and the target".
In this way, it is easily to get very low loss in training data. And this "hash" is specific to certain training examples, and will very likely to be over confident and have very strong option on one class.
