5
$\begingroup$

I am using a deep neural network model to make predictions. My problem is a classification(binary) problem. I wish to calculate the confidence score of each prediction. As of now, I use predict_proba of sklearn to get probability of a class and consider it as the model confidence for that prediction. Is it the right approach? What could be a better way to calculate the confidence score? Kindly add relevant literature to support your approach.

$\endgroup$
4
$\begingroup$

One way to estimate the level of confidence we have about an ANN prediction is to use dropout perturbations. The idea was proposed in this paper: Dropout as a Bayesian Approximation. Representing Model Uncertainty in Deep Learning. The core idea is to use dropout as a perturbation method, and check how predictions change with varying levels of dropout. Once you sampled a sufficient number of "distorted predictions", you can estimate something analogous to a confidence interval around the initial model prediction. This technique works either for classifiers and regressors.

You can read an explanation of this approach here.


EDIT:

To be more precise:

In order to implement this technique, use Dropout() layers, they can be used in prediction phase too (not just during training). You can train your Neural Network, then transfer its weights into another ANN with the same architecture + dropout layers. Something like:

new_model.set_weights(original_model.get_weights())

Once the new ANN with Dropout() has its weights, run it and vary its dropout hyperparams, get the predictions and calculate the CIs. I know it's time consuming so do it only if you think it's really worth it. Another possible way to implement can be done with custom layers like:

model.add(Lambda(lambda x: K.dropout(x, level=0.5)))

| improve this answer | |
$\endgroup$
  • $\begingroup$ this seems interesting... Btw what do you think about using probabilities as confidence score for each prediction? $\endgroup$ – yamini goel Jan 21 at 11:39
  • 1
    $\begingroup$ According to this technique, you would generate many predictions using varying level of dropout (as many as possible). Then you look at the distribution of these predictions (for each dropout level) and you build a confidence interval around them. Of course this is very time consuming $\endgroup$ – Leevo Jan 21 at 14:26
  • 1
    $\begingroup$ the sole reason I am not working on this technique is the enormous time consumption. Also, by confidence I understand probability that the class assigns to object x by the classifier. So I am pretty much confused that why can't I simply use the values from predict_proba as confidence in prediction. Kindly help me here. $\endgroup$ – yamini goel Jan 21 at 14:55
  • 1
    $\begingroup$ yeah, computation is the problem. The reason is that predict_proba makes sense only if a model allows you to calculate confidence intervals around its predictions. ANNs don't allow that, that's why tricks (such as the dropout perturbation) have been invented. With classifiers, when you softmax the output you can interpret values as the probability of belonging to each specific class. You can use their distribution as a rough measure of how confident you are that an observation belongs to that class. It's simplistic but it can work, and it comes with no additional computational costs. $\endgroup$ – Leevo Jan 21 at 15:50
  • $\begingroup$ Could you share a demo version of the distribution approach you suggested? $\endgroup$ – yamini goel Jan 21 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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