class_docstr: Determines optimal thresholds for classifiers given constraints.
class_docstr_tok: ["Determines","optimal","thresholds","for","classifiers","given","constraints","."]
code: def threshold_to_margin(self, thresh):
      # Convert between margin and classification threshold when displaying
      # margin as a threshold, as is done for binary classifiers.
      # Threshold is between 0 and 1 and represents the minimum score of the
      # positive (non-null) class before a datapoint is classified as positive.
      # A margin of 0 is the same as a threshold of .5 - meaning we take the
      # argmax class. A negative margin is a threshold below .5. Margin ranges
      # from -5 to 5, and can be converted the threshold through the equation
      # margin = ln(threshold / (1 - threshold)).
      if thresh == 0:
          return -5
      if thresh == 1:
          return 5
      return math.log(thresh / (1 - thresh))
  
imports: from collections.abc import Mapping, Sequence
  import math
  from typing import Optional
  import attr
  from lit_nlp.api import components
  from lit_nlp.api import dataset
  from lit_nlp.api import model
  from lit_nlp.api import types
  from lit_nlp.components import metrics
  from lit_nlp.lib import utils
  import numpy
label_desc: Use image node_id 3 for calling the Thresholder obj's underlying member method code with example usage: obj.threshold_to_margin(thresh) and returns: math, unknown, int