code: def get_worst_fairness(self):
      # We have fairness metrics per sensitive feature.
      # The worst fairness metric is:
      # - for ratio metrics, the lowest fairness value from all sensitive features
      # - for difference metrics, the highest fairness value from all sensitive features
      # It is needed as bias mitigation stop criteria.
  
      metrics = self.get_additional_metrics()
  
      fm = metrics.get("fairness_metrics", {})
      worst_value = None
      for col_name, values in fm.items():
          if col_name == "fairness_optimization":
              continue
          if "ratio" in self._fairness_metric.lower():
              if worst_value is None:
                  worst_value = values.get("fairness_metric_value", 0)
              else:
                  worst_value = min(
                      worst_value,
                      values.get("fairness_metric_value", 0),
                  )
          else:
              if worst_value is None:
                  worst_value = values.get("fairness_metric_value", 1)
              else:
                  worst_value = max(
                      worst_value,
                      values.get("fairness_metric_value", 1),
                  )
  
      return worst_value
  
imports: import copy
  import gc
  import json
  import logging
  import os
  import sys
  import time
  import uuid
  import zipfile
  import numpy
  import pandas
  from supervised.algorithms.factory import AlgorithmFactory
  from supervised.algorithms.registry import BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, REGRESSION, AlgorithmsRegistry
  from supervised.callbacks.callback_list import CallbackList
  from supervised.exceptions import AutoMLException
  from supervised.preprocessing.exclude_missing_target import ExcludeRowsMissingTarget
  from supervised.preprocessing.preprocessing import Preprocessing
  from supervised.utils.additional_metrics import AdditionalMetrics
  from supervised.utils.config import LOG_LEVEL
  from supervised.utils.metric import Metric
  from supervised.validation.validation_step import ValidationStep
  from supervised.utils.jsonencoder import MLJSONEncoder
  import joblib
  import optuna
  from supervised.tuner.optuna.tuner import OptunaTuner
  from supervised.utils.config import mem
  from supervised.utils.learning_curves import LearningCurves
label_desc: Use image node_id 20 for calling the ModelFramework obj's underlying member method code with example usage: obj.get_worst_fairness() and returns: worst_value