class_docstr: RIPPER (Repeated Incremental Pruning to Produce Error Reduction) is a heuristic rule induction algorithm
  based on separate-and-conquer. The explainer outputs a rule set in Disjunctive Normal Form (DNF) for a single
  target concept.
  
  References:
      .. [#ML95] `William W Cohen, "Fast Effective Rule Induction"
          Machine Learning: Proceedings of the Twelfth International Conference, 1995.
          <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.107.2612&rep=rep1&type=pdf>
class_docstr_tok: ["RIPPER","(","Repeated","Incremental","Pruning","to","Produce","Error","Reduction",")","is","a","heuristic","rule","induction","algorithm","based","on","separate-and-conquer",".","The","explainer","outputs","a","rule","set","in","Disjunctive","Normal","Form","(","DNF",")","for","a","single","target","concept",".","References",":","..","[","#","ML95","]","`","William","W","Cohen",",","``","Fast","Effective","Rule","Induction","''","Machine","Learning",":","Proceedings","of","the","Twelfth","International","Conference",",","1995",".","<","http",":","\/\/citeseerx.ist.psu.edu\/viewdoc\/download","?","doi=10.1.1.107.2612","&","rep=rep1","&","type=pdf",">"]
docstr: The fit function for RIPPER algorithm. Its implementation is limited to DataFrame and Series because the RIPPER
  algorithm needs the information of feature name and have to support nominal data type. Only `float` dtypes are
  considered numerical features. All others (including int) are treated as nominal.
  
  If target_label is specified, binary classification is assumed and asserted, and training uses target_label as selection        of positive examples.
  
  The induction of rules is deterministic by default as all random choices are initialized with self.random_state,
  which is 0 by default.
  
  Args:
      train (pd.DataFrame): The features of the training set
      y (pd.Series): The labels of the training set
      target_label (Any): The target label to learn for binary classification, among the unique values of y.             If not provided, Ripper will induce a native ordered ruleset with multiple labels/conclusions.
  
  Returns:
      self
docstr_tok: ["The","fit","function","for","RIPPER","algorithm",".","Its","implementation","is","limited","to","DataFrame","and","Series","because","the","RIPPER","algorithm","needs","the","information","of","feature","name","and","have","to","support","nominal","data","type",".","Only","`","float","`","dtypes","are","considered","numerical","features",".","All","others","(","including","int",")","are","treated","as","nominal",".","If","target_label","is","specified",",","binary","classification","is","assumed","and","asserted",",","and","training","uses","target_label","as","selection","of","positive","examples",".","The","induction","of","rules","is","deterministic","by","default","as","all","random","choices","are","initialized","with","self.random_state",",","which","is","0","by","default",".","Args",":","train","(","pd.DataFrame",")",":","The","features","of","the","training","set","y","(","pd.Series",")",":","The","labels","of","the","training","set","target_label","(","Any",")",":","The","target","label","to","learn","for","binary","classification",",","among","the","unique","values","of","y",".","If","not","provided",",","Ripper","will","induce","a","native","ordered","ruleset","with","multiple","labels\/conclusions",".","Returns",":","self"]
code: def fit(self, train: DataFrame, y: Series, target_label=None):
      """
          The fit function for RIPPER algorithm. Its implementation is limited to DataFrame and Series because the RIPPER
          algorithm needs the information of feature name and have to support nominal data type. Only `float` dtypes are
          considered numerical features. All others (including int) are treated as nominal.
  
          If target_label is specified, binary classification is assumed and asserted, and training uses target_label as selection\
          of positive examples.
  
          The induction of rules is deterministic by default as all random choices are initialized with self.random_state,
          which is 0 by default.
  
          Args:
              train (pd.DataFrame): The features of the training set
              y (pd.Series): The labels of the training set
              target_label (Any): The target label to learn for binary classification, among the unique values of y. \
              If not provided, Ripper will induce a native ordered ruleset with multiple labels/conclusions.
  
          Returns:
              self
          """
      logger = logging.getLogger(__name__)
  
      self._target_label = target_label
  
      self._labels = None
      self._rule_map = None
  
      self._nominal_column_encoders = None
      self._column_name_list = None
      self._column_name_index_map = None
      self._condition_mat = None
  
      self._gain_n = 0
  
      # Check that X and y have correct shape
      assert (
          train.shape[0] == y.shape[0]
      ), "X, y should have same length"
  
      self._nominal_column_encoders = init_encoder(train)
      encode_nominal(self._nominal_column_encoders, train)
      self._column_name_list = train.columns.values
  
      self._column_name_index_map = {
          name: index
          for index, name in enumerate(self._column_name_list)
      }
  
      unique_labels, counts = np.unique(y, return_counts=True)
      label_count_dict = dict(zip(unique_labels, counts))
  
      assert len(unique_labels) > 1, "label has only one value"
  
      # Check whenever target_label is given that label has only two values and target_label is one of them
      assert (target_label is None) or (
          len(unique_labels) == 2
      ), "Positive label value given but label not binary."
      assert (target_label is None) or (
          target_label in unique_labels
      ), "Positive label value given is not a label value."
  
      self._labels = sorted(
          unique_labels,
          key=lambda e: label_count_dict[e],
          reverse=False,
      )  # returns list from ndarray;
      # the label values are sorted according to their occurrence; least frequent value first
      # Set reverse=True for reversing that order
      if (target_label is not None) and (
          self._labels[0] != target_label
      ):
          # reverse value order for binary classification when target_label is not the least frequent
          self._labels.reverse()
      self.default_label = self._labels[
          -1
      ]  # the default value is the last label in the sorting order
      logger.debug("Label value ordering: " + str(self._labels))
  
      self._condition_mat = _encoding_for_parallel(
          train, self._column_name_index_map
      )
      self._gain_n = self._condition_mat[0].shape[0]
  
      train = train.to_numpy(dtype=np.dtype(float))
      y = y.values
  
      x_irep_list = train
      y_irep = y
  
      self._rule_map = OrderedDict()
  
      for i in range(len(self._labels) - 1):
          pos = self._labels[i]
          neg = self._labels[i + 1 :]
  
          indexer_pos = y_irep == pos
          indexer_neg = np.isin(y_irep, neg)
  
          train_pos = x_irep_list[indexer_pos]
          train_neg = x_irep_list[indexer_neg]
  
          irep_res = self._irep_plus_outer_loop(
              train_pos,
              train_neg,
              d=self.d,
              ratio=2 / 3,
              pruning_threshold=self.pruning_threshold,
          )
          if len(irep_res) > 0:
              self._rule_map[pos] = irep_res
              bool_vec_index = unbound_rule_list_index(
                  x_irep_list, self._rule_map[pos]
              )
              x_irep_list = x_irep_list[bool_vec_index]
              y_irep = y_irep[bool_vec_index]
  
      logger.debug("# begin optimization")
  
      for _ in range(self.k):
          x_optimize = train
          y_optimise = y
          for i in range(len(self._labels) - 1):
              if not self._rule_map.get(self._labels[i]):
                  continue
              pos = self._labels[i]
              neg = self._labels[i + 1 :]
  
              indexer_pos = y_optimise == pos
              indexer_neg = np.isin(y_optimise, neg)
  
              train_pos = x_optimize[indexer_pos]
              train_neg = x_optimize[indexer_neg]
  
              self._rule_map[pos] = self._optimize(
                  train_pos,
                  train_neg,
                  ratio=2 / 3,
                  rules_input=self._rule_map[pos],
              )
  
              bool_vec_index = unbound_rule_list_index(
                  x_optimize, self._rule_map[pos]
              )
              x_optimize = x_optimize[bool_vec_index]
              y_optimise = y_optimise[bool_vec_index]
  
      return self
  
imports: import logging
  import logging.config
  from collections import OrderedDict
  import numpy
  from aix360.algorithms.dise import DISExplainer
  from aix360.algorithms.rule_induction.ripper.base import _encoding_for_parallel, init_encoder, encode_nominal, _split_instances
  from aix360.algorithms.rule_induction.ripper.binding import append_literal, _bind_literal, _bind_rule, unbound_rule_list_index, _unbound, _unbound_rule_list, _rule_list_predict, LE, EQ, _find_best_literal, Literal, _filter_contradicted_instances
  from aix360.algorithms.rule_induction.ripper.mdl import _mdl
  from aix360.algorithms.rule_induction.ripper.pruning import _pruning_irep, _minimize_rule_list, _pruning_optimization
  from aix360.algorithms.rule_induction.trxf.core.conjunction import Conjunction
  from aix360.algorithms.rule_induction.trxf.core.dnf_ruleset import DnfRuleSet
  from aix360.algorithms.rule_induction.trxf.core.feature import Feature
  from aix360.algorithms.rule_induction.trxf.core.predicate import Predicate, Relation
  from pandas import DataFrame, Series
label_desc: Use image node_id 4 for calling the RipperExplainer obj's underlying member method code with example usage: obj.fit(train, y, target_label) and returns: self