class_docstr: Linear Rule Regression is a directly interpretable supervised learning
  method that performs linear regression on rule-based features.
class_docstr_tok: ["Linear","Rule","Regression","is","a","directly","interpretable","supervised","learning","method","that","performs","linear","regression","on","rule-based","features","."]
docstr: Return DataFrame holding model features and their coefficients.
  
  Args:
      maxCoeffs (int, optional): Maximum number of rules/numerical features to show
      highDegOnly (bool, optional): Only show higher-degree rules
      prec (int, optional): Number of decimal places to show for floating-value thresholds
  Returns:
      DataFrame: dfExpl -- Rules/numerical features and their coefficients
docstr_tok: ["Return","DataFrame","holding","model","features","and","their","coefficients",".","Args",":","maxCoeffs","(","int",",","optional",")",":","Maximum","number","of","rules\/numerical","features","to","show","highDegOnly","(","bool",",","optional",")",":","Only","show","higher-degree","rules","prec","(","int",",","optional",")",":","Number","of","decimal","places","to","show","for","floating-value","thresholds","Returns",":","DataFrame",":","dfExpl","--","Rules\/numerical","features","and","their","coefficients"]
code: def explain(self, maxCoeffs=None, highDegOnly=False, prec=2):
      """Return DataFrame holding model features and their coefficients.
  
      Args:
          maxCoeffs (int, optional): Maximum number of rules/numerical features to show
          highDegOnly (bool, optional): Only show higher-degree rules
          prec (int, optional): Number of decimal places to show for floating-value thresholds
      Returns:
          DataFrame: dfExpl -- Rules/numerical features and their coefficients
      """
      # Number of ordinal features used
      if self.useOrd:
          nnzOrd = len(self.idxNonzeroOrd)
      else:
          nnzOrd = 0
      if highDegOnly:
          # Restrict to higher-degree rules
          coeffs = self.lr.coef_[nnzOrd:][self.z.sum() > 1]
          nnzOrd = 0
          z = self.z.loc[:, self.z.sum() > 1]
      else:
          coeffs = self.lr.coef_
          z = self.z
      # Initialize DataFrame to be printed
      truncate = (maxCoeffs is not None) and (len(coeffs) > maxCoeffs)
      nRows = maxCoeffs + 1 if truncate else len(coeffs) + 1
      dfExpl = pd.DataFrame(
          index=range(nRows), columns=["rule", "coefficient"]
      )
  
      # Intercept term
      dfExpl.at[0, "rule"] = "(intercept)"
      dfExpl.at[0, "coefficient"] = self.lr.intercept_
      # Sort coefficients from largest to smallest
      idxSort = np.abs(coeffs).argsort()[:-nRows:-1]
      dfExpl.loc[1:, "coefficient"] = coeffs[idxSort]
      # Iterate over sorted coefficients
      for row, i in enumerate(idxSort):
          if i < nnzOrd:
              # Ordinal feature
              dfExpl.at[row + 1, "rule"] = self.namesOrd[
                  self.idxNonzeroOrd[i]
              ]
          else:
              # MultiIndex of features participating in rule i
              idxFeat = z.index[z.iloc[:, i - nnzOrd] > 0]
              # String representations of features
              strFeat = (
                  idxFeat.get_level_values(0)
                  + " "
                  + idxFeat.get_level_values(1)
                  + " "
                  + idxFeat.get_level_values(2)
                  .to_series()
                  .apply(
                      lambda x: ("{:." + str(prec) + "f}").format(x)
                      if type(x) is float
                      else str(x)
                  )
              )
              # String representation of rule
              dfExpl.at[row + 1, "rule"] = strFeat.str.cat(sep=" AND ")
  
      # Return dataframe holding model features and their coefficients
      return dfExpl
  
file_path: AIX360/aix360/algorithms/rbm/linear_regression.py
imports: import numpy
  import pandas
  from sklearn.linear_model import Lasso, Ridge
  from sklearn.base import BaseEstimator, RegressorMixin
  import matplotlib.pyplot
  from .beam_search import beam_search_K1
label_desc: Use image node_id 5 for calling the LinearRuleRegression obj's underlying member method code with example usage: obj.explain(maxCoeffs, highDegOnly, prec) and returns: dfExpl