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 optimization step for RIPPER
  
  Parameters
  ----------
      pos: np.ndarray
          Positive instances
      neg: np.ndarray
          Negative instances
      rules_input : list
          Rules that needs to be optimized
      ratio : float
          The percentage of pruning data
  
  Returns
  -------
  list
      Optimized rule list
docstr_tok: ["The","optimization","step","for","RIPPER","Parameters","--","--","--","--","--","pos",":","np.ndarray","Positive","instances","neg",":","np.ndarray","Negative","instances","rules_input",":","list","Rules","that","needs","to","be","optimized","ratio",":","float","The","percentage","of","pruning","data","Returns","--","--","--","-","list","Optimized","rule","list"]
code: def _optimize(
      self,
      pos: np.ndarray,
      neg: np.ndarray,
      rules_input,
      ratio: float = 2 / 3,
  ):
      """
      The optimization step for RIPPER
  
      Parameters
      ----------
          pos: np.ndarray
              Positive instances
          neg: np.ndarray
              Negative instances
          rules_input : list
              Rules that needs to be optimized
          ratio : float
              The percentage of pruning data
  
      Returns
      -------
      list
          Optimized rule list
      """
      rules = rules_input.copy()
  
      i = 0
      while i < len(rules):
          # ====================== origin ============================================================================
          dl_origin = _mdl(pos, neg, rules, self._gain_n)
  
          # ====================== replacement =======================================================================
          replacement_rule = self._replacement(
              pos=pos, neg=neg, rules=rules, ratio=ratio, index=i
          )
          if len(replacement_rule) != 0:
              dl_replacement = _mdl(
                  pos,
                  neg,
                  rules[:i] + [replacement_rule] + rules[i + 1 :],
                  self._gain_n,
              )
          else:
              dl_replacement = _mdl(
                  pos, neg, rules[:i] + rules[i + 1 :], self._gain_n
              )
  
          # ====================== revision ==========================================================================
          revision_rule = self._revision(
              pos=pos, neg=neg, rules=rules, ratio=ratio, index=i
          )
  
          dl_revision = _mdl(
              pos,
              neg,
              rules[:i] + [revision_rule] + rules[i + 1 :],
              self._gain_n,
          )
  
          # ====================== result ============================================================================
          if dl_origin <= dl_replacement and dl_origin <= dl_revision:
              # if no improvement is made, then the original rule is chosen
              pass
          # secondly, replacement rule is tested
          elif (
              dl_replacement <= dl_origin
              and dl_replacement <= dl_revision
          ):
              if len(replacement_rule) != 0:
                  rules[i] = replacement_rule
              else:
                  del rules[i]
                  continue
          # finally, if the origin rule and the replacement rule are not satisfied, the revision rule is chosen
          else:
              rules[i] = revision_rule
          i += 1
      return rules
  
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 11 for calling the RipperExplainer obj's underlying member method code with example usage: obj._optimize(pos, neg, rules_input, ratio) and returns: rules