class_docstr: Abstract class with common methods to be inherited by WeakSegmentsPerformance checks.
class_docstr_tok: ["Abstract","class","with","common","methods","to","be","inherited","by","WeakSegmentsPerformance","checks","."]
docstr: Add condition - check that the score of the weakest segment is greater than supplied relative threshold.
  
  Parameters
  ----------
  max_ratio_change : float , default: 0.20
      maximal ratio of change allowed between the average score and the score of the weakest segment.
docstr_tok: ["Add","condition","-","check","that","the","score","of","the","weakest","segment","is","greater","than","supplied","relative","threshold",".","Parameters","--","--","--","--","--","max_ratio_change",":","float",",","default",":","0.20","maximal","ratio","of","change","allowed","between","the","average","score","and","the","score","of","the","weakest","segment","."]
code: def add_condition_segments_relative_performance_greater_than(
      self, max_ratio_change: float = 0.20
  ):
      """Add condition - check that the score of the weakest segment is greater than supplied relative threshold.
  
      Parameters
      ----------
      max_ratio_change : float , default: 0.20
          maximal ratio of change allowed between the average score and the score of the weakest segment.
      """
  
      def condition(result: Dict) -> ConditionResult:
          if "message" in result:
              return ConditionResult(
                  ConditionCategory.PASS, result["message"]
              )
  
          weakest_segment_score = result["weak_segments_list"].iloc[
              0, 0
          ]
          scorer_name = result["weak_segments_list"].columns[0].lower()
          msg = (
              f"Found a segment with {scorer_name} of {format_number(weakest_segment_score, 3)} "
              f'in comparison to an average score of {format_number(result["avg_score"], 3)} in sampled data.'
          )
          if (
              result["avg_score"] > 0
              and weakest_segment_score
              > (1 - max_ratio_change) * result["avg_score"]
          ):
              return ConditionResult(ConditionCategory.PASS, msg)
          elif (
              result["avg_score"] < 0
              and weakest_segment_score
              > (1 + max_ratio_change) * result["avg_score"]
          ):
              return ConditionResult(ConditionCategory.PASS, msg)
          else:
              return ConditionResult(ConditionCategory.WARN, msg)
  
      return self.add_condition(
          f"The relative performance of weakest segment is greater than "
          f"{format_percent(1 - max_ratio_change)} of average model performance.",
          condition,
      )
  
imports: import abc
  from collections import defaultdict
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  import pandas
  import plotly.express
  import sklearn
  from category_encoders import TargetEncoder
  from packaging import version
  from sklearn.model_selection import GridSearchCV
  from sklearn.tree import DecisionTreeRegressor
  from deepchecks import ConditionCategory, ConditionResult
  from deepchecks.tabular import Dataset
  from deepchecks.tabular.context import _DummyModel
  from deepchecks.tabular.metric_utils.scorers import DeepcheckScorer
  from deepchecks.utils.dataframes import default_fill_na_per_column_type
  from deepchecks.utils.performance.partition import DeepchecksFilter, convert_tree_leaves_into_filters, partition_numeric_feature_around_segment
  from deepchecks.utils.strings import format_number, format_percent
label_desc: Use image node_id 7 for calling the WeakSegmentAbstract obj's underlying member method code with example usage: obj.add_condition_segments_relative_performance_greater_than(max_ratio_change) and returns: self, ConditionResult, ConditionResult, ConditionResult, ConditionResult