code: def score_precision_recall(
      X,
      y,
      rules: List[List[str]],
      samples: List[List[int]],
      features: List[List[int]],
      feature_names: List[str],
      oob: bool = True,
  ) -> List[Rule]:
      scored_rules = []
  
      for curr_rules, curr_samples, curr_features in zip(
          rules, samples, features
      ):
          # Create mask for OOB samples
          mask = ~indices_to_mask(curr_samples, X.shape[0])
          if sum(mask) == 0:
              if oob:
                  warn(
                      "OOB evaluation not possible: doing it in-bag. Performance evaluation is "
                      "likely to be wrong (overfitting) and selected rules are likely to not "
                      "perform well! Please use max_samples < 1."
                  )
              mask = curr_samples
  
          # XXX todo: idem without dataframe
  
          X_oob = pd.DataFrame(
              (X[mask, :])[:, curr_features],
              columns=np.array(feature_names)[curr_features],
          )
  
          if (
              X_oob.shape[1] <= 1
          ):  # otherwise pandas bug (cf. issue #16363)
              return []
  
          y_oob = y[mask]
          y_oob = np.array((y_oob != 0))
  
          # Add OOB performances to rules:
          scored_rules += [
              Rule(r, args=_eval_rule_perf(r, X_oob, y_oob))
              for r in set(curr_rules)
          ]
  
      return scored_rules
  
file_path: imodels/imodels/util/score.py
imports: from typing import List, Tuple
  from warnings import warn
  import pandas
  import numpy
  from sklearn.utils import indices_to_mask
  from sklearn.linear_model import Lasso, LogisticRegression
  from sklearn.linear_model._coordinate_descent import _alpha_grid
  from sklearn.model_selection import cross_val_score
  from imodels.util.rule import Rule
label_desc: Use image node_id 1 for calling a global function with example usage: score_precision_recall(X, y, rules, samples, features, feature_names, oob) and returns: scored_rules, list