A common technique is called margin-rescaling and implies to scale the margin with the actual loss that is induced by decodingp instead of p i .
rescaling the margin by the loss implements the intuition that the confidence of rejecting a mistaken output is proportional to its error.