class_docstr: The class object for the Random Forest Plus (RF+) estimator, which can
  be used as a prediction model or interpreted via generalized
  mean decrease in impurity (MDI+). For more details, refer to [paper].
  
  Parameters
  ----------
  rf_model: scikit-learn random forest object or None
      The RF model to be used to build RF+. If None, then a new
      RandomForestRegressor() or RandomForestClassifier() is instantiated.
  prediction_model: A PartialPredictionModelBase object, scikit-learn type estimator, or "auto"
      The prediction model to be used for making (full and partial) predictions
      using the block transformed data.
      If value is set to "auto", then a default is chosen as follows:
       - For RandomForestPlusRegressor, RidgeRegressorPPM is used.
       - For RandomForestPlusClassifier, LogisticClassifierPPM is used.
  sample_split: string in {"loo", "oob", "inbag"} or None
      The sample splitting strategy to be used for fitting RF+. If "oob",
      RF+ is trained on the out-of-bag data. If "inbag", RF+ is trained on the
      in-bag data. Otherwise, RF+ is trained on the full training data.
  include_raw: bool
      Flag for whether to augment the local decision stump features extracted
      from the RF model with the original features.
  drop_features: bool
      Flag for whether to use an intercept model for the partial predictions
      on a given feature if a tree does not have any nodes that split on it,
      or to use a model on the raw feature (if include_raw is True).
  add_transformers: list of BlockTransformerBase objects or None
      Additional block transformers (if any) to include in the RF+ model.
  center: bool
      Flag for whether to center the transformed data in the transformers.
  normalize: bool
      Flag for whether to rescale the transformed data to have unit
      variance in the transformers.
docstr: Obtain MDI+ feature importances. Generalized mean decrease in impurity (MDI+)
  is a flexible framework for computing RF feature importances. For more
  details, refer to [paper].
  
  Parameters
  ----------
  X: ndarray of shape (n_samples, n_features)
      The covariate matrix. Generally should be the same X as that used for
      fitting the RF+ prediction model. If a pd.DataFrame object is supplied, then
      the column names are used in the output.
  y: ndarray of shape (n_samples, n_targets)
      The observed responses. Generally should be the same y as that used for
      fitting the RF+ prediction model.
  scoring_fns: a function or dict with functions as value and function name (str) as key or "auto"
      The scoring functions used for evaluating the partial predictions.
      If "auto", then a default is chosen as follows:
       - For RandomForestPlusRegressor, then r-squared (_fast_r2_score) is used.
       - For RandomForestPlusClassifier, then the negative log-loss (_neg_log_loss) is used.
  sample_split: string in {"loo", "oob", "inbag", "inherit"} or None
      The sample splitting strategy to be used when evaluating the partial
      model predictions in MDI+. If "inherit" (default), uses the same sample splitting
      strategy as used when fitting the RF+ prediction model. Assuming None or "loo" were used
      as the sample splitting scheme for fitting the RF+ prediction model,
      "loo" (leave-one-out) is strongly recommended here in MDI+ as it overcomes
      the known correlation and entropy biases suffered by MDI. "oob" (out-of-bag) can
      also be used to overcome these biases. "inbag" is the sample splitting
      strategy used by MDI. If None, no sample splitting is performed and the
      full data set is used to evaluate the partial model predictions.
  mode: string in {"keep_k", "keep_rest"}
      Mode for the method. "keep_k" imputes the mean of each feature not
      in block k when making a partial model prediction, while "keep_rest"
      imputes the mean of each feature in block k. "keep_k" is strongly
      recommended for computational considerations.
  
  Returns
  -------
  scores: pd.DataFrame of shape (n_features, n_scoring_fns)
      The MDI+ feature importances.
docstr_tok: ["Obtain","MDI+","feature","importances",".","Generalized","mean","decrease","in","impurity","(","MDI+",")","is","a","flexible","framework","for","computing","RF","feature","importances",".","For","more","details",",","refer","to","[","paper","]",".","Parameters","--","--","--","--","--","X",":","ndarray","of","shape","(","n_samples",",","n_features",")","The","covariate","matrix",".","Generally","should","be","the","same","X","as","that","used","for","fitting","the","RF+","prediction","model",".","If","a","pd.DataFrame","object","is","supplied",",","then","the","column","names","are","used","in","the","output",".","y",":","ndarray","of","shape","(","n_samples",",","n_targets",")","The","observed","responses",".","Generally","should","be","the","same","y","as","that","used","for","fitting","the","RF+","prediction","model",".","scoring_fns",":","a","function","or","dict","with","functions","as","value","and","function","name","(","str",")","as","key","or","``","auto","''","The","scoring","functions","used","for","evaluating","the","partial","predictions",".","If","``","auto","''",",","then","a","default","is","chosen","as","follows",":","-","For","RandomForestPlusRegressor",",","then","r-squared","(","_fast_r2_score",")","is","used",".","-","For","RandomForestPlusClassifier",",","then","the","negative","log-loss","(","_neg_log_loss",")","is","used",".","sample_split",":","string","in","{","``","loo","''",",","``","oob","''",",","``","inbag","''",",","``","inherit","''","}","or","None","The","sample","splitting","strategy","to","be","used","when","evaluating","the","partial","model","predictions","in","MDI+",".","If","``","inherit","''","(","default",")",",","uses","the","same","sample","splitting","strategy","as","used","when","fitting","the","RF+","prediction","model",".","Assuming","None","or","``","loo","''","were","used","as","the","sample","splitting","scheme","for","fitting","the","RF+","prediction","model",",","``","loo","''","(","leave-one-out",")","is","strongly","recommended","here","in","MDI+","as","it","overcomes","the","known","correlation","and","entropy","biases","suffered","by","MDI",".","``","oob","''","(","out-of-bag",")","can","also","be","used","to","overcome","these","biases",".","``","inbag","''","is","the","sample","splitting","strategy","used","by","MDI",".","If","None",",","no","sample","splitting","is","performed","and","the","full","data","set","is","used","to","evaluate","the","partial","model","predictions",".","mode",":","string","in","{","``","keep_k","''",",","``","keep_rest","''","}","Mode","for","the","method",".","``","keep_k","''","imputes","the","mean","of","each","feature","not","in","block","k","when","making","a","partial","model","prediction",",","while","``","keep_rest","''","imputes","the","mean","of","each","feature","in","block","k.","``","keep_k","''","is","strongly","recommended","for","computational","considerations",".","Returns","--","--","--","-","scores",":","pd.DataFrame","of","shape","(","n_features",",","n_scoring_fns",")","The","MDI+","feature","importances","."]
code: def get_mdi_plus_scores(
      self,
      X=None,
      y=None,
      scoring_fns="auto",
      sample_split="inherit",
      mode="keep_k",
  ):
      """
      Obtain MDI+ feature importances. Generalized mean decrease in impurity (MDI+)
      is a flexible framework for computing RF feature importances. For more
      details, refer to [paper].
  
      Parameters
      ----------
      X: ndarray of shape (n_samples, n_features)
          The covariate matrix. Generally should be the same X as that used for
          fitting the RF+ prediction model. If a pd.DataFrame object is supplied, then
          the column names are used in the output.
      y: ndarray of shape (n_samples, n_targets)
          The observed responses. Generally should be the same y as that used for
          fitting the RF+ prediction model.
      scoring_fns: a function or dict with functions as value and function name (str) as key or "auto"
          The scoring functions used for evaluating the partial predictions.
          If "auto", then a default is chosen as follows:
           - For RandomForestPlusRegressor, then r-squared (_fast_r2_score) is used.
           - For RandomForestPlusClassifier, then the negative log-loss (_neg_log_loss) is used.
      sample_split: string in {"loo", "oob", "inbag", "inherit"} or None
          The sample splitting strategy to be used when evaluating the partial
          model predictions in MDI+. If "inherit" (default), uses the same sample splitting
          strategy as used when fitting the RF+ prediction model. Assuming None or "loo" were used
          as the sample splitting scheme for fitting the RF+ prediction model,
          "loo" (leave-one-out) is strongly recommended here in MDI+ as it overcomes
          the known correlation and entropy biases suffered by MDI. "oob" (out-of-bag) can
          also be used to overcome these biases. "inbag" is the sample splitting
          strategy used by MDI. If None, no sample splitting is performed and the
          full data set is used to evaluate the partial model predictions.
      mode: string in {"keep_k", "keep_rest"}
          Mode for the method. "keep_k" imputes the mean of each feature not
          in block k when making a partial model prediction, while "keep_rest"
          imputes the mean of each feature in block k. "keep_k" is strongly
          recommended for computational considerations.
  
      Returns
      -------
      scores: pd.DataFrame of shape (n_features, n_scoring_fns)
          The MDI+ feature importances.
      """
      if X is None or y is None:
          if self.mdi_plus_scores_ is None:
              raise ValueError("Need X and y as inputs.")
      else:
          # convert data frame to array
          if isinstance(X, pd.DataFrame):
              if self.feature_names_ is not None:
                  X_array = X.loc[:, self.feature_names_].values
              else:
                  X_array = X.values
          elif isinstance(X, np.ndarray):
              X_array = X
          else:
              raise ValueError(
                  "Input X must be a pandas DataFrame or numpy array."
              )
          if isinstance(y, pd.DataFrame):
              y = y.values.ravel()
          elif not isinstance(y, np.ndarray):
              raise ValueError(
                  "Input y must be a pandas DataFrame or numpy array."
              )
          # get defaults
          if sample_split == "inherit":
              sample_split = self.sample_split
          if (
              X.shape[0] != self._n_samples_train
              and sample_split is not None
          ):
              raise ValueError(
                  "Set sample_split=None to fit MDI+ on non-training X and y. "
                  "To use other sample_split schemes, input the training X and y data."
              )
          if scoring_fns == "auto":
              scoring_fns = (
                  {"importance": _fast_r2_score}
                  if self._task == "regression"
                  else {"importance": _neg_log_loss}
              )
          # onehot encode if multi-class for GlmClassiferPPM
          if isinstance(self.prediction_model, GlmClassifierPPM):
              if self._multi_class:
                  y = self._y_encoder.transform(
                      y.reshape(-1, 1)
                  ).toarray()
          # compute MDI+ for forest
          mdi_plus_obj = ForestMDIPlus(
              estimators=self.estimators_,
              transformers=self.transformers_,
              scoring_fns=scoring_fns,
              sample_split=sample_split,
              tree_random_states=self._tree_random_states,
              mode=mode,
              task=self._task,
              center=self.center,
              normalize=self.normalize,
          )
          self.mdi_plus_ = mdi_plus_obj
          mdi_plus_scores = mdi_plus_obj.get_scores(X_array, y)
          if self.feature_names_ is not None:
              mdi_plus_scores["var"] = self.feature_names_
              self.mdi_plus_.feature_importances_[
                  "var"
              ] = self.feature_names_
          self.mdi_plus_scores_ = mdi_plus_scores
      return self.mdi_plus_scores_
  
imports: import copy
  import numpy
  import pandas
  from sklearn.base import BaseEstimator, RegressorMixin, ClassifierMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from sklearn.metrics import r2_score, roc_auc_score, log_loss
  from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
  from sklearn.preprocessing import OneHotEncoder
  from imodels.importance.block_transformers import MDIPlusDefaultTransformer, TreeTransformer, CompositeTransformer, IdentityTransformer
  from imodels.importance.ppms import PartialPredictionModelBase, GlmClassifierPPM, RidgeRegressorPPM, LogisticClassifierPPM
  from imodels.importance.mdi_plus import ForestMDIPlus, _get_default_sample_split, _validate_sample_split, _get_sample_split_data
label_desc: Use image node_id 5 for calling the _RandomForestPlus obj's underlying member method code with example usage: obj.get_mdi_plus_scores(X, y, scoring_fns, sample_split, mode) and returns: self