docstr: Feature importance in a model inspection technique that can be used for any
  fitted predictor when the data is tablular.
  
  This implementation is also known as permutation importance that is defined to
  be the variation of the model's prediction when a single feature value is
  randomly shuffled. In RLlib it is implemented as a custom OffPolicyEstimator
  which is used to evaluate RLlib policies without performing environment
  interactions.
  
  Example usage: In the example below the feature importance module is used to
  evaluate the policy and the each feature's importance is computed after each
  training iteration. The permutation are repeated `self.repeat` times and the
  results are averages across repeats.
  
  ```python
      config = (
          AlgorithmConfig()
          .offline_data(
              off_policy_estimation_methods=
                  {
                      "feature_importance": {
                          "type": FeatureImportance,
                          "repeat": 10,
                          "limit_fraction": 0.1,
                      }
                  }
          )
      )
  
      algorithm = DQN(config=config)
      results = algorithm.train()
  ```
  
  Args:
      policy: the policy to use for feature importance.
      repeat: number of times to repeat the perturbation.
      perturb_fn: function to perturb the features. By default reshuffle the
          features within the batch.
      limit_fraction: fraction of the dataset to use for feature importance
          This is only used in estimate_on_dataset when the dataset is too large
          to compute feature importance on.
docstr_tok: ["Feature","importance","in","a","model","inspection","technique","that","can","be","used","for","any","fitted","predictor","when","the","data","is","tablular",".","This","implementation","is","also","known","as","permutation","importance","that","is","defined","to","be","the","variation","of","the","model","'s","prediction","when","a","single","feature","value","is","randomly","shuffled",".","In","RLlib","it","is","implemented","as","a","custom","OffPolicyEstimator","which","is","used","to","evaluate","RLlib","policies","without","performing","environment","interactions",".","Example","usage",":","In","the","example","below","the","feature","importance","module","is","used","to","evaluate","the","policy","and","the","each","feature","'s","importance","is","computed","after","each","training","iteration",".","The","permutation","are","repeated","`","self.repeat","`","times","and","the","results","are","averages","across","repeats",".","``","`","python","config","=","(","AlgorithmConfig","(",")",".offline_data","(","off_policy_estimation_methods=","{","``","feature_importance","''",":","{","``","type","''",":","FeatureImportance",",","``","repeat","''",":","10",",","``","limit_fraction","''",":","0.1",",","}","}",")",")","algorithm","=","DQN","(","config=config",")","results","=","algorithm.train","(",")","``","`","Args",":","policy",":","the","policy","to","use","for","feature","importance",".","repeat",":","number","of","times","to","repeat","the","perturbation",".","perturb_fn",":","function","to","perturb","the","features",".","By","default","reshuffle","the","features","within","the","batch",".","limit_fraction",":","fraction","of","the","dataset","to","use","for","feature","importance","This","is","only","used","in","estimate_on_dataset","when","the","dataset","is","too","large","to","compute","feature","importance","on","."]
code: def __init__(
      self,
      policy: Policy,
      repeat: int = 1,
      limit_fraction: float = 1.0,
      perturb_fn: Callable[
          [pd.DataFrame, int], pd.DataFrame
      ] = _perturb_df,
  ):
      """Feature importance in a model inspection technique that can be used for any
      fitted predictor when the data is tablular.
  
      This implementation is also known as permutation importance that is defined to
      be the variation of the model's prediction when a single feature value is
      randomly shuffled. In RLlib it is implemented as a custom OffPolicyEstimator
      which is used to evaluate RLlib policies without performing environment
      interactions.
  
      Example usage: In the example below the feature importance module is used to
      evaluate the policy and the each feature's importance is computed after each
      training iteration. The permutation are repeated `self.repeat` times and the
      results are averages across repeats.
  
      ```python
          config = (
              AlgorithmConfig()
              .offline_data(
                  off_policy_estimation_methods=
                      {
                          "feature_importance": {
                              "type": FeatureImportance,
                              "repeat": 10,
                              "limit_fraction": 0.1,
                          }
                      }
              )
          )
  
          algorithm = DQN(config=config)
          results = algorithm.train()
      ```
  
      Args:
          policy: the policy to use for feature importance.
          repeat: number of times to repeat the perturbation.
          perturb_fn: function to perturb the features. By default reshuffle the
              features within the batch.
          limit_fraction: fraction of the dataset to use for feature importance
              This is only used in estimate_on_dataset when the dataset is too large
              to compute feature importance on.
      """
      super().__init__(policy)
      self.repeat = repeat
      self.perturb_fn = perturb_fn
      self.limit_fraction = limit_fraction
  
file_path: ray/python/ray/rllib/offline/feature_importance.py
imports: import copy
  import numpy
  import pandas
  from typing import Callable, Dict, Any
  import ray
  from ray.data import Dataset
  from ray.rllib.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch, convert_ma_batch_to_sample_batch
  from ray.rllib.utils.annotations import override, DeveloperAPI, ExperimentalAPI
  from ray.rllib.utils.typing import SampleBatchType
  from ray.rllib.offline.offline_evaluator import OfflineEvaluator
label_desc: Use image node_id 1 to create a new FeatureImportance object from inherited base classes: OfflineEvaluator with example: obj = FeatureImportance(policy, repeat, limit_fraction, perturb_fn)