class_docstr: Calibrator calibrates the output probabilities of a model.
class_docstr_tok: ["Calibrator","calibrates","the","output","probabilities","of","a","model","."]
docstr: Calibrates model output probabilities on validation set after training.
  
  This works well for most datasets, though it may fail for some difficult or extremely imbalanced datasets.
docstr_tok: ["Calibrates","model","output","probabilities","on","validation","set","after","training",".","This","works","well","for","most","datasets",",","though","it","may","fail","for","some","difficult","or","extremely","imbalanced","datasets","."]
code: def train_calibration(self, dataset, dataset_name: str):
      """Calibrates model output probabilities on validation set after training.
  
      This works well for most datasets, though it may fail for some difficult or extremely imbalanced datasets.
      """
      if not self.calibration_enabled():
          # Early out if no output features have calibration enabled.
          return
      with self.backend.create_predictor(
          self.model, batch_size=self.batch_size
      ) as predictor:
          metrics, predictions = predictor.batch_evaluation(
              dataset,
              collect_predictions=True,
              collect_logits=True,
              dataset_name=dataset_name,
          )
  
      dataset_df = dataset.to_df()
      for output_feature in self.model.output_features.values():
          if output_feature.calibration_module is not None:
              feature_logits_key = (
                  f"{output_feature.feature_name}_logits"
              )
              if feature_logits_key in predictions:
                  feature_logits = self.backend.df_engine.compute(
                      predictions[feature_logits_key]
                  )
                  feature_labels = self.backend.df_engine.compute(
                      dataset_df[output_feature.proc_column]
                  )
                  output_feature.calibration_module.train_calibration(
                      np.stack(feature_logits.values, axis=0),
                      np.stack(feature_labels.values, axis=0),
                  )
  
imports: import numpy
  from ludwig.backend import Backend
  from ludwig.models.ecd import ECD
label_desc: Use image node_id 3 for calling the Calibrator obj's underlying member method code with example usage: obj.train_calibration(dataset, dataset_name) without return types