class_docstr: Calculate predict-level aspect importance
  
  Parameters
  -----------
  variable_groups : dict of lists 
      Variables grouped in aspects to calculate their importance. 
  type : {'default', 'shap'}, optional
      Type of aspect importance/attributions (default is `'default'`, which means 
      the use of simplified LIME method).
  N : int, optional
      Number of observations that will be sampled from the `data` attribute
      before the calculation of aspect importance (default is `2000`).
  B : int, optional
      Parameter specific for `type == 'shap'`. Number of random paths to calculate aspect
      attributions (default is `25`).
      NOTE: Ignored if `type` is not `'shap'`.
  n_aspects : int, optional
      Parameter specific for `type == 'default'`. Maximum number of non-zero importances, i.e.
      coefficients after lasso fitting (default is `None`, which means the linear regression is used).
      NOTE: Ignored if `type` is not `'default'`.
  sample_method : {'default', 'binom'}, optional
      Parameter specific for `type == 'default'`. Sampling method for creating binary matrix 
      used as mask for replacing aspects in sampled data (default is `'default'`, which means 
      it randomly replaces one or two zeros per row; `'binom'` replaces random number of zeros 
      per row).
      NOTE: Ignored if `type` is not `'default'`.
  f : int, optional
      Parameter specific for `type == 'default'` and `sample_method == 'binom'`. Parameter 
      controlling average number of replaced zeros for binomial sampling (default is `2`). 
      NOTE: Ignored if `type` is not `'default'` or `sample_method` is not `'binom'`.
  depend_method: {'assoc', 'pps'} or function, optional
      The method of calculating the dependencies between variables (i.e. the dependency 
      matrix). Default is `'assoc'`, which means the use of statistical association 
      (correlation coefficient, Cramér's V and eta-quared); 
      `'pps'` stands for Power Predictive Score.
      NOTE: When a function is passed, it is called with the `data` and it 
      must return a symmetric dependency matrix (`pd.DataFrame` with variable names as 
      columns and rows).
  corr_method : {'spearman', 'pearson', 'kendall'}, optional
      The method of calculating correlation between numerical variables 
      (default is `'spearman'`).
      NOTE: Ignored if `depend_method` is not `'assoc'`.
  agg_method : {'max', 'min', 'avg'}, optional
      The method of aggregating the PPS values for pairs of variables 
      (default is `'max'`).
      NOTE: Ignored if `depend_method` is not `'pps'`. 
  processes : int, optional
      Parameter specific for `type == 'shap'`. Number of parallel processes to use in calculations.
      Iterated over `B` (default is `1`, which means no parallel computation).
  random_state : int, optional
      Set seed for random number generator (default is random seed).
  
  Attributes
  -----------
  result : pd.DataFrame
      Main result attribute of an explanation.
  prediction : float
      Prediction for `new_observation`.
  intercept : float
      Average prediction for `data`.
  variable_groups : dict of lists 
      Variables grouped in aspects to calculate their importance. 
  type : {'default', 'shap'}
      Type of aspect importance/attributions to calculate.
  N : int
      Number of observations that will be sampled from the `data` attribute
      before the calculation of aspect importance.
  B : int
      Number of random paths to calculate aspect attributions.
  n_aspects : int
      Maximum number of non-zero importances.
  sample_method : {'default', 'binom'}
      Sampling method for creating binary matrix used as mask for replacing aspects in sampled data.
  f : int
      Average number of replaced zeros for binomial sampling.
  depend_method : {'assoc', 'pps'}
      The method of calculating the dependencies between variables.
  corr_method : {'spearman', 'pearson', 'kendall'}
      The method of calculating correlation between numerical variables.
  agg_method : {'max', 'min', 'avg'}
      The method of aggregating the PPS values for pairs of variables.
  processes : int
      Number of parallel processes to use in calculations. Iterated over `B`.
  random_state : int
      Set seed for random number generator.
  
  Notes
  -----
  - https://arxiv.org/abs/2104.03403
class_docstr_tok: ["Calculate","predict-level","aspect","importance","Parameters","--","--","--","--","--","-","variable_groups",":","dict","of","lists","Variables","grouped","in","aspects","to","calculate","their","importance",".","type",":","{","'default","'",",","'shap","'","}",",","optional","Type","of","aspect","importance\/attributions","(","default","is","`","'default","'","`",",","which","means","the","use","of","simplified","LIME","method",")",".","N",":","int",",","optional","Number","of","observations","that","will","be","sampled","from","the","`","data","`","attribute","before","the","calculation","of","aspect","importance","(","default","is","`","2000","`",")",".","B",":","int",",","optional","Parameter","specific","for","`","type","==","'shap","'","`",".","Number","of","random","paths","to","calculate","aspect","attributions","(","default","is","`","25","`",")",".","NOTE",":","Ignored","if","`","type","`","is","not","`","'shap","'","`",".","n_aspects",":","int",",","optional","Parameter","specific","for","`","type","==","'default","'","`",".","Maximum","number","of","non-zero","importances",",","i.e",".","coefficients","after","lasso","fitting","(","default","is","`","None","`",",","which","means","the","linear","regression","is","used",")",".","NOTE",":","Ignored","if","`","type","`","is","not","`","'default","'","`",".","sample_method",":","{","'default","'",",","'binom","'","}",",","optional","Parameter","specific","for","`","type","==","'default","'","`",".","Sampling","method","for","creating","binary","matrix","used","as","mask","for","replacing","aspects","in","sampled","data","(","default","is","`","'default","'","`",",","which","means","it","randomly","replaces","one","or","two","zeros","per","row",";","`","'binom","'","`","replaces","random","number","of","zeros","per","row",")",".","NOTE",":","Ignored","if","`","type","`","is","not","`","'default","'","`",".","f",":","int",",","optional","Parameter","specific","for","`","type","==","'default","'","`","and","`","sample_method","==","'binom","'","`",".","Parameter","controlling","average","number","of","replaced","zeros","for","binomial","sampling","(","default","is","`","2","`",")",".","NOTE",":","Ignored","if","`","type","`","is","not","`","'default","'","`","or","`","sample_method","`","is","not","`","'binom","'","`",".","depend_method",":","{","'assoc","'",",","'pps","'","}","or","function",",","optional","The","method","of","calculating","the","dependencies","between","variables","(","i.e",".","the","dependency","matrix",")",".","Default","is","`","'assoc","'","`",",","which","means","the","use","of","statistical","association","(","correlation","coefficient",",","Cram\u00e9r","'s","V","and","eta-quared",")",";","`","'pps","'","`","stands","for","Power","Predictive","Score",".","NOTE",":","When","a","function","is","passed",",","it","is","called","with","the","`","data","`","and","it","must","return","a","symmetric","dependency","matrix","(","`","pd.DataFrame","`","with","variable","names","as","columns","and","rows",")",".","corr_method",":","{","'spearman","'",",","'pearson","'",",","'kendall","'","}",",","optional","The","method","of","calculating","correlation","between","numerical","variables","(","default","is","`","'spearman","'","`",")",".","NOTE",":","Ignored","if","`","depend_method","`","is","not","`","'assoc","'","`",".","agg_method",":","{","'max","'",",","'min","'",",","'avg","'","}",",","optional","The","method","of","aggregating","the","PPS","values","for","pairs","of","variables","(","default","is","`","'max","'","`",")",".","NOTE",":","Ignored","if","`","depend_method","`","is","not","`","'pps","'","`",".","processes",":","int",",","optional","Parameter","specific","for","`","type","==","'shap","'","`",".","Number","of","parallel","processes","to","use","in","calculations",".","Iterated","over","`","B","`","(","default","is","`","1","`",",","which","means","no","parallel","computation",")",".","random_state",":","int",",","optional","Set","seed","for","random","number","generator","(","default","is","random","seed",")",".","Attributes","--","--","--","--","--","-","result",":","pd.DataFrame","Main","result","attribute","of","an","explanation",".","prediction",":","float","Prediction","for","`","new_observation","`",".","intercept",":","float","Average","prediction","for","`","data","`",".","variable_groups",":","dict","of","lists","Variables","grouped","in","aspects","to","calculate","their","importance",".","type",":","{","'default","'",",","'shap","'","}","Type","of","aspect","importance\/attributions","to","calculate",".","N",":","int","Number","of","observations","that","will","be","sampled","from","the","`","data","`","attribute","before","the","calculation","of","aspect","importance",".","B",":","int","Number","of","random","paths","to","calculate","aspect","attributions",".","n_aspects",":","int","Maximum","number","of","non-zero","importances",".","sample_method",":","{","'default","'",",","'binom","'","}","Sampling","method","for","creating","binary","matrix","used","as","mask","for","replacing","aspects","in","sampled","data",".","f",":","int","Average","number","of","replaced","zeros","for","binomial","sampling",".","depend_method",":","{","'assoc","'",",","'pps","'","}","The","method","of","calculating","the","dependencies","between","variables",".","corr_method",":","{","'spearman","'",",","'pearson","'",",","'kendall","'","}","The","method","of","calculating","correlation","between","numerical","variables",".","agg_method",":","{","'max","'",",","'min","'",",","'avg","'","}","The","method","of","aggregating","the","PPS","values","for","pairs","of","variables",".","processes",":","int","Number","of","parallel","processes","to","use","in","calculations",".","Iterated","over","`","B","`",".","random_state",":","int","Set","seed","for","random","number","generator",".","Notes","--","--","-","-","https",":","\/\/arxiv.org\/abs\/2104.03403"]
docstr: Calculate the result of explanation
  Fit method makes calculations in place and changes the attributes.
  
  Parameters
  ----------
  explainer : Explainer object
      Model wrapper created using the Explainer class.
  new_observation : pd.Series or np.ndarray (1d) or pd.DataFrame (1,p)
      An observation for which a prediction needs to be explained.
  
  Returns
  -----------
  None
docstr_tok: ["Calculate","the","result","of","explanation","Fit","method","makes","calculations","in","place","and","changes","the","attributes",".","Parameters","--","--","--","--","--","explainer",":","Explainer","object","Model","wrapper","created","using","the","Explainer","class",".","new_observation",":","pd.Series","or","np.ndarray","(","1d",")","or","pd.DataFrame","(","1",",","p",")","An","observation","for","which","a","prediction","needs","to","be","explained",".","Returns","--","--","--","--","--","-","None"]
code: def fit(self, explainer, new_observation):
      """Calculate the result of explanation
      Fit method makes calculations in place and changes the attributes.
  
      Parameters
      ----------
      explainer : Explainer object
          Model wrapper created using the Explainer class.
      new_observation : pd.Series or np.ndarray (1d) or pd.DataFrame (1,p)
          An observation for which a prediction needs to be explained.
  
      Returns
      -----------
      None
      """
      _new_observation = checks.check_new_observation(
          new_observation, explainer
      )
      checks.check_columns_in_new_observation(
          _new_observation, explainer
      )
      _variable_groups = checks.check_variable_groups(
          self.variable_groups, explainer
      )
  
      self.prediction = explainer.predict(_new_observation)[0]
      self.intercept = explainer.y_hat.mean()
  
      if self.type == "default":
          self.result = utils.calculate_predict_aspect_importance(
              explainer,
              _new_observation,
              _variable_groups,
              self.N,
              self.n_aspects,
              self.sample_method,
              self.f,
              self.random_state,
          )
      else:
          self.result = utils.calculate_shap_predict_aspect_importance(
              explainer,
              _new_observation,
              _variable_groups,
              self.N,
              self.B,
              self.processes,
              self.random_state,
          )
  
      self.result.insert(4, "min_depend", None)
      self.result.insert(5, "vars_min_depend", None)
  
      # if there is _depend_matrix in kwargs (called from Aspect object)
      if self._depend_matrix is not None:
          vars_min_depend, min_depend = get_min_depend_from_matrix(
              self._depend_matrix, self.result.variable_names
          )
      else:
          vars_min_depend, min_depend = calculate_min_depend(
              self.result.variable_names,
              explainer.data,
              self.depend_method,
              self.corr_method,
              self.agg_method,
          )
  
      self.result["min_depend"] = min_depend
      self.result["vars_min_depend"] = vars_min_depend
  
file_path: DALEX/python/dalex/dalex/aspect/_predict_aspect_importance/object.py
imports: import numpy
  import pandas
  from plotly.subplots import make_subplots
  from dalex import _theme, _global_checks, _global_utils
  from dalex._explanation import Explanation
  from dalex.aspect.utils import calculate_min_depend, get_min_depend_from_matrix
  from .None import checks, utils, plot
label_desc: Use image node_id 3 for calling the PredictAspectImportance obj's underlying member method code with example usage: obj.fit(explainer, new_observation) without return types