class_docstr: Bayesian or-of-and algorithm.
  Generates patterns that satisfy the minimum support and maximum length and then select the Nrules rules that have the highest entropy.
  In function SA_patternbased, each local maximum is stored in maps and the best BOA is returned.
  Remember here the BOA contains only the index of selected rules from Nrules self.rules_
class_docstr_tok: ["Bayesian","or-of-and","algorithm",".","Generates","patterns","that","satisfy","the","minimum","support","and","maximum","length","and","then","select","the","Nrules","rules","that","have","the","highest","entropy",".","In","function","SA_patternbased",",","each","local","maximum","is","stored","in","maps","and","the","best","BOA","is","returned",".","Remember","here","the","BOA","contains","only","the","index","of","selected","rules","from","Nrules","self.rules_"]
docstr: This function generates rules that satisfy supp and maxlen using fpgrowth, then it selects the top n_rules rules that make data have the biggest decrease in entropy.
  There are two ways to generate rules. fpgrowth can handle cases where the maxlen is small. If maxlen<=3, fpgrowth can generates rules much faster than randomforest.
  If maxlen is big, fpgrowth tends to generate too many rules that overflow the memory.
docstr_tok: ["This","function","generates","rules","that","satisfy","supp","and","maxlen","using","fpgrowth",",","then","it","selects","the","top","n_rules","rules","that","make","data","have","the","biggest","decrease","in","entropy",".","There","are","two","ways","to","generate","rules",".","fpgrowth","can","handle","cases","where","the","maxlen","is","small",".","If","maxlen","<","=3",",","fpgrowth","can","generates","rules","much","faster","than","randomforest",".","If","maxlen","is","big",",","fpgrowth","tends","to","generate","too","many","rules","that","overflow","the","memory","."]
code: def _generate_rules(self, X, y, verbose):
      """This function generates rules that satisfy supp and maxlen using fpgrowth, then it selects the top n_rules rules that make data have the biggest decrease in entropy.
      There are two ways to generate rules. fpgrowth can handle cases where the maxlen is small. If maxlen<=3, fpgrowth can generates rules much faster than randomforest.
      If maxlen is big, fpgrowth tends to generate too many rules that overflow the memory.
      """
  
      df = 1 - X  # df has negative associations
      df.columns = [name.strip() + "_neg" for name in X.columns]
      df = pd.concat([X, df], axis=1)
      if self.discretization_method == "fpgrowth" and self.maxlen <= 3:
          itemMatrix = [
              [item for item in df.columns if row[item] == 1]
              for i, row in df.iterrows()
          ]
          pindex = np.where(y == 1)[0]
          rules = fpgrowth(
              [itemMatrix[i] for i in pindex],
              supp=self.supp,
              zmin=1,
              zmax=self.maxlen,
          )
          rules = [tuple(np.sort(rule[0])) for rule in rules]
          rules = list(set(rules))
      else:
          """todo: replace this with imodels.RFDiscretizer"""
          rules = []
          for length in range(1, self.maxlen + 1, 1):
              n_estimators = min(pow(df.shape[1], length), 4000)
              clf = RandomForestClassifier(
                  n_estimators=n_estimators, max_depth=length
              )
              clf.fit(X, y)
              for n in range(n_estimators):
                  rules.extend(
                      _extract_rules(clf.estimators_[n], df.columns)
                  )
          rules = [list(x) for x in set(tuple(x) for x in rules)]
      self.rules_ = rules
  
      # select the top n_rules rules using secondary criteria, information gain
      self._screen_rules(df, y, verbose)  # updates self.rules_
      self._set_pattern_space()
  
imports: import itertools
  import operator
  import os
  import warnings
  from os.path import join
  from bisect import bisect_left
  from collections import defaultdict
  from copy import deepcopy
  from itertools import combinations
  from random import sample
  import numpy
  import pandas
  from mlxtend.frequent_patterns import fpgrowth
  from numpy.random import random
  from pandas import read_csv
  from scipy.sparse import csc_matrix
  from sklearn.base import BaseEstimator, ClassifierMixin
  from sklearn.ensemble import RandomForestClassifier
  from sklearn.utils.multiclass import check_classification_targets
  from sklearn.utils.validation import check_X_y, check_is_fitted
  from imodels.rule_set.rule_set import RuleSet
  from imodels.util.arguments import check_fit_arguments
label_desc: Use image node_id 7 for calling the BayesianRuleSetClassifier obj's underlying member method code with example usage: obj._generate_rules(X, y, verbose) without return types