class_docstr: TSICEExplainer extends the Individual Conditional Expectation for correlated
  timeseries data (higher dimensions). It uses TSFeatures to derive time series
  structural features, and uses data perturber(TSPerturber) for generating simulated
  data. TSICEExplainer explains the trend in the model forecast change with time series
  derived features.
  
  References:
      .. [#0] `Goldstein et al. 'Peeking Inside the Black Box: Visualizing Statistical
          Learning with Plots of Individual Conditional Expectation'
          <https://arxiv.org/abs/1309.6392>`_
class_docstr_tok: ["TSICEExplainer","extends","the","Individual","Conditional","Expectation","for","correlated","timeseries","data","(","higher","dimensions",")",".","It","uses","TSFeatures","to","derive","time","series","structural","features",",","and","uses","data","perturber","(","TSPerturber",")","for","generating","simulated","data",".","TSICEExplainer","explains","the","trend","in","the","model","forecast","change","with","time","series","derived","features",".","References",":","..","[","#","0","]","`","Goldstein","et","al",".","'Peeking","Inside","the","Black","Box",":","Visualizing","Statistical","Learning","with","Plots","of","Individual","Conditional","Expectation'","<","https",":","\/\/arxiv.org\/abs\/1309.6392",">","`","_"]
docstr: Initializer for TSICEExplainer
  
  Args:
      forecaster (Callable): Callable object produces a forecast as numpy array
          for a given input as numpy array.
      input_length (int): Input length for the forecaster.
      forecast_lookahead (int): Lookahead length of the forecaster prediction.
      n_variables (int): Number of variables in the forecaster input. Defaults to 1.
      n_exogs (int): Number of exogenous variable required for the forecaster. Defaults to 0.
      n_perturbations (int): Number of perturbed instance for TSExplanation. Defaults to 25.
      features_to_analyze (List[str]): List of features used to analyze the perturbed timeseries
          during TSICE explanation. As the observing timeseries is complicated, these
          set of features can be used to observe the perturbations closer. Allowed
          values are "median", "mean", "min", "max", "std", "range", "intercept",
          "trend", "rsquared", "max_variation". If None, "mean" is used by default.
          Defaults to None.
      perturbers (List[TSPerturber, dict]): data perturbation algorithm specification by TSPerturber
          instance or dict. Allowed values for "type" key in dictionary are block-bootstrap, frequency,
          moving-average, shift. Block-bootstrap split the time series into contiguous
          chunks called blocks, for each block noise is estimated and noise is exchanged
          and added to the signal between randomly selected blocks. Moving-average perturbation
          maintains the moving mean of the time series data with the specified window length,
          but add perturbed noise with similar distribution as the data. Frequency
          perturber performs FFT on the noise, and removes random high frequency
          components from the noise estimates. Number of frequencies to be removed
          is specified by the truncate_frequencies argument. Shift perturber adds
          random upward or downward shift in the data value over time continuous
          blocks. If not provided default perturber is combination of block-bootstrap,
          moving-average, and frequency. Defaults to None.
      explanation_window_start (int): Explanation window is selected from the input timeseries
          starting explanation_window_start. This window is used to select the part of the timeseries
          for TSICE analysis. Perturbations are computed over this explanation window. If
          explanation_window_start is None, explanation_window is selected from recent upto
          explanation_window_length. Defaults to None.
      explanation_window_length (int): Explanation window of length: explanation_window_length is
          selected from the input timeseries. This window is used to select the part of the timeseries
          for TSICE analysis. Perturbations are computed over this explanation window. Defaults to 10.
docstr_tok: ["Initializer","for","TSICEExplainer","Args",":","forecaster","(","Callable",")",":","Callable","object","produces","a","forecast","as","numpy","array","for","a","given","input","as","numpy","array",".","input_length","(","int",")",":","Input","length","for","the","forecaster",".","forecast_lookahead","(","int",")",":","Lookahead","length","of","the","forecaster","prediction",".","n_variables","(","int",")",":","Number","of","variables","in","the","forecaster","input",".","Defaults","to","1.","n_exogs","(","int",")",":","Number","of","exogenous","variable","required","for","the","forecaster",".","Defaults","to","0.","n_perturbations","(","int",")",":","Number","of","perturbed","instance","for","TSExplanation",".","Defaults","to","25.","features_to_analyze","(","List","[","str","]",")",":","List","of","features","used","to","analyze","the","perturbed","timeseries","during","TSICE","explanation",".","As","the","observing","timeseries","is","complicated",",","these","set","of","features","can","be","used","to","observe","the","perturbations","closer",".","Allowed","values","are","``","median","''",",","``","mean","''",",","``","min","''",",","``","max","''",",","``","std","''",",","``","range","''",",","``","intercept","''",",","``","trend","''",",","``","rsquared","''",",","``","max_variation","''",".","If","None",",","``","mean","''","is","used","by","default",".","Defaults","to","None",".","perturbers","(","List","[","TSPerturber",",","dict","]",")",":","data","perturbation","algorithm","specification","by","TSPerturber","instance","or","dict",".","Allowed","values","for","``","type","''","key","in","dictionary","are","block-bootstrap",",","frequency",",","moving-average",",","shift",".","Block-bootstrap","split","the","time","series","into","contiguous","chunks","called","blocks",",","for","each","block","noise","is","estimated","and","noise","is","exchanged","and","added","to","the","signal","between","randomly","selected","blocks",".","Moving-average","perturbation","maintains","the","moving","mean","of","the","time","series","data","with","the","specified","window","length",",","but","add","perturbed","noise","with","similar","distribution","as","the","data",".","Frequency","perturber","performs","FFT","on","the","noise",",","and","removes","random","high","frequency","components","from","the","noise","estimates",".","Number","of","frequencies","to","be","removed","is","specified","by","the","truncate_frequencies","argument",".","Shift","perturber","adds","random","upward","or","downward","shift","in","the","data","value","over","time","continuous","blocks",".","If","not","provided","default","perturber","is","combination","of","block-bootstrap",",","moving-average",",","and","frequency",".","Defaults","to","None",".","explanation_window_start","(","int",")",":","Explanation","window","is","selected","from","the","input","timeseries","starting","explanation_window_start",".","This","window","is","used","to","select","the","part","of","the","timeseries","for","TSICE","analysis",".","Perturbations","are","computed","over","this","explanation","window",".","If","explanation_window_start","is","None",",","explanation_window","is","selected","from","recent","upto","explanation_window_length",".","Defaults","to","None",".","explanation_window_length","(","int",")",":","Explanation","window","of","length",":","explanation_window_length","is","selected","from","the","input","timeseries",".","This","window","is","used","to","select","the","part","of","the","timeseries","for","TSICE","analysis",".","Perturbations","are","computed","over","this","explanation","window",".","Defaults","to","10","."]
code: def __init__(
      self,
      forecaster: Callable,
      input_length: int,
      forecast_lookahead: int,
      n_variables: int = 1,
      n_exogs: int = 0,
      n_perturbations: int = 25,
      features_to_analyze: List[str] = None,
      perturbers: List[Union[TSPerturber, dict]] = None,
      explanation_window_start: int = None,
      explanation_window_length: int = 10,
  ):
      """Initializer for TSICEExplainer
  
      Args:
          forecaster (Callable): Callable object produces a forecast as numpy array
              for a given input as numpy array.
          input_length (int): Input length for the forecaster.
          forecast_lookahead (int): Lookahead length of the forecaster prediction.
          n_variables (int): Number of variables in the forecaster input. Defaults to 1.
          n_exogs (int): Number of exogenous variable required for the forecaster. Defaults to 0.
          n_perturbations (int): Number of perturbed instance for TSExplanation. Defaults to 25.
          features_to_analyze (List[str]): List of features used to analyze the perturbed timeseries
              during TSICE explanation. As the observing timeseries is complicated, these
              set of features can be used to observe the perturbations closer. Allowed
              values are "median", "mean", "min", "max", "std", "range", "intercept",
              "trend", "rsquared", "max_variation". If None, "mean" is used by default.
              Defaults to None.
          perturbers (List[TSPerturber, dict]): data perturbation algorithm specification by TSPerturber
              instance or dict. Allowed values for "type" key in dictionary are block-bootstrap, frequency,
              moving-average, shift. Block-bootstrap split the time series into contiguous
              chunks called blocks, for each block noise is estimated and noise is exchanged
              and added to the signal between randomly selected blocks. Moving-average perturbation
              maintains the moving mean of the time series data with the specified window length,
              but add perturbed noise with similar distribution as the data. Frequency
              perturber performs FFT on the noise, and removes random high frequency
              components from the noise estimates. Number of frequencies to be removed
              is specified by the truncate_frequencies argument. Shift perturber adds
              random upward or downward shift in the data value over time continuous
              blocks. If not provided default perturber is combination of block-bootstrap,
              moving-average, and frequency. Defaults to None.
          explanation_window_start (int): Explanation window is selected from the input timeseries
              starting explanation_window_start. This window is used to select the part of the timeseries
              for TSICE analysis. Perturbations are computed over this explanation window. If
              explanation_window_start is None, explanation_window is selected from recent upto
              explanation_window_length. Defaults to None.
          explanation_window_length (int): Explanation window of length: explanation_window_length is
              selected from the input timeseries. This window is used to select the part of the timeseries
              for TSICE analysis. Perturbations are computed over this explanation window. Defaults to 10.
      """
      self.model = forecaster
      if features_to_analyze is None:
          features_to_analyze = ["mean"]
  
      feature_class = LatestFeature
      feature_class_args = {}
      if explanation_window_length > input_length:
          raise Exception(
              "explanation_window_length must be positive integer and lesser than or equal to input_length"
          )
  
      if explanation_window_start is None:  # recent window
          self.explanation_window_start = -explanation_window_length
          self.explanation_window_length = None
          feature_class = LatestFeature
          feature_class_args["length"] = explanation_window_length
      else:  # range
          if explanation_window_start >= input_length:
              raise Exception(
                  "explanation_window_start must be positive integer and lesser than input_length"
              )
          self.explanation_window_start = explanation_window_start
          self.explanation_window_length = (
              explanation_window_start + explanation_window_length
          )
          feature_class = RangeFeature
          feature_class_args["start"] = explanation_window_start
          feature_class_args["length"] = explanation_window_length
  
      self.feat_extractors = []
  
      for stat in features_to_analyze:
          feature_class_args["stat"] = stat
          self.feat_extractors.append(
              feature_class(**feature_class_args)
          )
  
      block_selector = BlockSelector(
          start=self.explanation_window_start,
          end=self.explanation_window_length,
      )
  
      if perturbers is None:
          perturbers = [
              dict(type="block-bootstrap"),
          ]
  
      self._parameters = {
          "input_length": input_length,
          "forecast_lookahead": forecast_lookahead,
          "n_variables": n_variables,
          "n_exogs": n_exogs,
          "n_perturbations": n_perturbations,
          "pertubers": perturbers,
          "explanation_window_start": explanation_window_start,
          "explanation_window_length": explanation_window_length,
      }
  
      self.perturber = PerturbedDataGenerator(
          perturber_engines=perturbers,
          block_selector=block_selector,
      )
      self.tensor_model = False
      super(TSICEExplainer, self).__init__()
      self._is_fitted = True
  
file_path: AIX360/aix360/algorithms/tsice/tsice.py
imports: import warnings
  import numpy
  import pandas
  from typing import List, Union, Callable
  from aix360.algorithms.tslbbe import TSLocalBBExplainer
  from aix360.algorithms.tsutils.tsframe import tsFrame, to_np_array
  from aix360.algorithms.tsutils.tsperturbers.tsperturber import TSPerturber, BlockSelector
  from aix360.algorithms.tsutils.tsperturbers.perturbed_data_generator import PerturbedDataGenerator
  from aix360.algorithms.tsutils.tsfeatures.latest_features import LatestFeature
  from aix360.algorithms.tsutils.tsfeatures.range_features import RangeFeature
label_desc: Use image node_id 1 to create a new TSICEExplainer object from inherited base classes: TSLocalBBExplainer with example: obj = TSICEExplainer(forecaster, input_length, forecast_lookahead, n_variables, n_exogs, n_perturbations, features_to_analyze, perturbers, explanation_window_start, explanation_window_length)