class_docstr: Determines optimal thresholds for classifiers given constraints.
class_docstr_tok: ["Determines","optimal","thresholds","for","classifiers","given","constraints","."]
code: def __init__(self):
      self.metrics_gen = metrics.BinaryConfusionMetrics()
  
      # Set up the fairness measure calculators, which take confusion matrix
      # metrics and calculates a score from them.
      def demo_parity_metric(stats):
          return (stats["TP"] + stats["FP"]) / (
              stats["TP"] + stats["FP"] + stats["TN"] + stats["FN"]
          )
  
      def equal_acc_metric(stats):
          return (stats["TP"] + stats["TN"]) / (
              stats["TP"] + stats["FP"] + stats["TN"] + stats["FN"]
          )
  
      def equal_opp_metric(stats):
          return stats["TP"] / (stats["TP"] + stats["FN"])
  
      self.fairness_measures = {
          "Demographic parity": demo_parity_metric,
          "Equal accuracy": equal_acc_metric,
          "Equal opporitunity": equal_opp_metric,
      }
  
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 1 to create a new Thresholder object from inherited base classes: lit_components with example: obj = Thresholder()