class_docstr: Rulefit class. Rather than using this class directly, should use RuleFitRegressor or RuleFitClassifier
  
  
  Parameters
  ----------
  tree_size:      Number of terminal nodes in generated trees. If exp_rand_tree_size=True, 
                  this will be the mean number of terminal nodes.
  sample_fract:   fraction of randomly chosen training observations used to produce each tree. 
                  FP 2004 (Sec. 2)
  max_rules:      total number of terms included in the final model (both linear and rules)
                  approximate total number of candidate rules generated for fitting also is based on this
                  Note that actual number of candidate rules will usually be lower than this due to duplicates.
  memory_par:     scale multiplier (shrinkage factor) applied to each new tree when 
                  sequentially induced. FP 2004 (Sec. 2)
  lin_standardise: If True, the linear terms will be standardised as per Friedman Sec 3.2
                  by multiplying the winsorised variable by 0.4/stdev.
  lin_trim_quantile: If lin_standardise is True, this quantile will be used to trim linear 
                  terms before standardisation.
  exp_rand_tree_size: If True, each boosted tree will have a different maximum number of 
                  terminal nodes based on an exponential distribution about tree_size. 
                  (Friedman Sec 3.3)
  include_linear: Include linear terms as opposed to only rules
  alpha:          Regularization strength, will override max_rules parameter
  cv:             Whether to use cross-validation scores to select the regularization strength 
                  the final regularization value out of all that satisfy max_rules. If False, the
                  least regularization possible is used.
  random_state:   Integer to initialise random objects and provide repeatability.
  tree_generator: Optional: this object will be used as provided to generate the rules. 
                  This will override almost all the other properties above. 
                  Must be GradientBoostingRegressor(), GradientBoostingClassifier(), or RandomForestRegressor()
  
  Attributes
  ----------
  rule_ensemble: RuleEnsemble
      The rule ensemble
  
  feature_names: list of strings, optional (default=None)
      The names of the features (columns)
code: def _score_rules(
      self, X, y, rules
  ) -> Tuple[List[Rule], List[float], float]:
      X_concat = np.zeros([X.shape[0], 0])
  
      # standardise linear variables if requested (for regression model only)
      if self.include_linear:
          # standard deviation and mean of winsorized features
          self.winsorizer.train(X)
          winsorized_X = self.winsorizer.trim(X)
          self.stddev = np.std(winsorized_X, axis=0)
          self.mean = np.mean(winsorized_X, axis=0)
  
          if self.lin_standardise:
              self.friedscale.train(X)
              X_regn = self.friedscale.scale(X)
          else:
              X_regn = X.copy()
          X_concat = np.concatenate((X_concat, X_regn), axis=1)
  
      X_rules = self.transform(X, rules)
      if X_rules.shape[0] > 0:
          X_concat = np.concatenate((X_concat, X_rules), axis=1)
  
      # no rules fit and self.include_linear == False
      if X_concat.shape[1] == 0:
          return [], [], 0
      prediction_task = (
          "regression"
          if isinstance(self, RegressorMixin)
          else "classification"
      )
      return score_linear(
          X_concat,
          y,
          rules,
          prediction_task=prediction_task,
          max_rules=self.max_rules,
          alpha=self.alpha,
          cv=self.cv,
          random_state=self.random_state,
      )
  
imports: from typing import List, Tuple
  import numpy
  import pandas
  import scipy
  from scipy.special import softmax
  from sklearn.base import BaseEstimator, ClassifierMixin, RegressorMixin
  from sklearn.base import TransformerMixin
  from sklearn.utils.multiclass import unique_labels
  from sklearn.utils.validation import check_X_y, check_array, check_is_fitted
  from imodels.rule_set.rule_set import RuleSet
  from imodels.util.arguments import check_fit_arguments
  from imodels.util.extract import extract_rulefit
  from imodels.util.rule import get_feature_dict, replace_feature_name, Rule
  from imodels.util.score import score_linear
  from imodels.util.transforms import Winsorizer, FriedScale
label_desc: Use image node_id 11 for calling the RuleFit obj's underlying member method code with example usage: obj._score_rules(X, y, rules) and returns: score_linear, list,  list,  int