class_docstr: Create Aspect
  
  Explanation methods that do not take into account dependencies between variables
  can produce misleading results. This class creates a representation of a model based
  on an Explainer object. In addition, it calculates the relationships between
  the variables that can be used to create explanations. Methods of this class produce
  explanation objects, that contain the main result attribute, and can be visualised
  using the plot method.
  
  The `explainer` is the only required parameter.
  
  Parameters
  ----------
  explainer : Explainer object
      Model wrapper created using the Explainer class.
  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 based on Pearson's chi-squared statistic 
      and eta-quared based on Kruskal-Wallis H-statistic);
      `'pps'` stands for Power Predictive Score.
      NOTE: When a function is passed, it is called with the `explainer.data` and it
      must return a symmetric dependency matrix (`pd.DataFrame` with variable names as
      columns and rows).
  clust_method : {'complete', 'single', 'average', 'weighted', 'centroid', 'median', 'ward'}, optional
      The linkage algorithm to use for variables hierarchical clustering
      (default is `'complete'`).
  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'`.
  
  Attributes
  --------
  explainer : Explainer object
      Model wrapper created using the Explainer class.
  depend_method : {'assoc', 'pps'} or function
      The method of calculating the dependencies between variables.
  clust_method : {'complete', 'single', 'average', 'weighted', 'centroid', 'median', 'ward'}
      The linkage algorithm to use for variables hierarchical clustering.
  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.
  depend_matrix : pd.DataFrame
      The dependency matrix (with variable names as columns and rows).
  linkage_matrix :
      The hierarchical clustering of variables encoded as a `scipy` linkage matrix.
  
  Notes
  -----
  - assoc, eta-squared: http://tss.awf.poznan.pl/files/3_Trends_Vol21_2014__no1_20.pdf
  - assoc, Cramér's V: http://stats.lse.ac.uk/bergsma/pdf/cramerV3.pdf
  - PPS: https://github.com/8080labs/ppscore
  - triplot: https://arxiv.org/abs/2104.03403
class_docstr_tok: ["Create","Aspect","Explanation","methods","that","do","not","take","into","account","dependencies","between","variables","can","produce","misleading","results",".","This","class","creates","a","representation","of","a","model","based","on","an","Explainer","object",".","In","addition",",","it","calculates","the","relationships","between","the","variables","that","can","be","used","to","create","explanations",".","Methods","of","this","class","produce","explanation","objects",",","that","contain","the","main","result","attribute",",","and","can","be","visualised","using","the","plot","method",".","The","`","explainer","`","is","the","only","required","parameter",".","Parameters","--","--","--","--","--","explainer",":","Explainer","object","Model","wrapper","created","using","the","Explainer","class",".","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","based","on","Pearson","'s","chi-squared","statistic","and","eta-quared","based","on","Kruskal-Wallis","H-statistic",")",";","`","'pps","'","`","stands","for","Power","Predictive","Score",".","NOTE",":","When","a","function","is","passed",",","it","is","called","with","the","`","explainer.data","`","and","it","must","return","a","symmetric","dependency","matrix","(","`","pd.DataFrame","`","with","variable","names","as","columns","and","rows",")",".","clust_method",":","{","'complete","'",",","'single","'",",","'average","'",",","'weighted","'",",","'centroid","'",",","'median","'",",","'ward","'","}",",","optional","The","linkage","algorithm","to","use","for","variables","hierarchical","clustering","(","default","is","`","'complete","'","`",")",".","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","'","`",".","Attributes","--","--","--","--","explainer",":","Explainer","object","Model","wrapper","created","using","the","Explainer","class",".","depend_method",":","{","'assoc","'",",","'pps","'","}","or","function","The","method","of","calculating","the","dependencies","between","variables",".","clust_method",":","{","'complete","'",",","'single","'",",","'average","'",",","'weighted","'",",","'centroid","'",",","'median","'",",","'ward","'","}","The","linkage","algorithm","to","use","for","variables","hierarchical","clustering",".","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",".","depend_matrix",":","pd.DataFrame","The","dependency","matrix","(","with","variable","names","as","columns","and","rows",")",".","linkage_matrix",":","The","hierarchical","clustering","of","variables","encoded","as","a","`","scipy","`","linkage","matrix",".","Notes","--","--","-","-","assoc",",","eta-squared",":","http",":","\/\/tss.awf.poznan.pl\/files\/3_Trends_Vol21_2014__no1_20.pdf","-","assoc",",","Cram\u00e9r","'s","V",":","http",":","\/\/stats.lse.ac.uk\/bergsma\/pdf\/cramerV3.pdf","-","PPS",":","https",":","\/\/github.com\/8080labs\/ppscore","-","triplot",":","https",":","\/\/arxiv.org\/abs\/2104.03403"]
docstr: Calculate predict-level aspect importance
  
  Parameters
  ----------
  new_observation : pd.Series or np.ndarray (1d) or pd.DataFrame (1,p)
      An observation for which a prediction needs to be explained.
  variable_groups : dict of lists or None
      Variables grouped in aspects to calculate their importance (default is `None`).
  type : {'default', 'shap'}, optional
      Type of aspect importance/attributions (default is `'default'`, which means
      the use of simplified LIME method).
  h : float, optional
      Threshold to apply when forming aspects, i.e., the minimum value of the dependency
      between the variables grouped in one aspect (default is `0.5`).
  N : int, optional
      Number of observations that will be sampled from the `explainer.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'`.
  label : str, optional
      Name to appear in result and plots. Overrides default.
  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).
  
  Returns
  -------
  PredictAspectImportance class object
      Explanation object containing the main result attribute and the plot method.
docstr_tok: ["Calculate","predict-level","aspect","importance","Parameters","--","--","--","--","--","new_observation",":","pd.Series","or","np.ndarray","(","1d",")","or","pd.DataFrame","(","1",",","p",")","An","observation","for","which","a","prediction","needs","to","be","explained",".","variable_groups",":","dict","of","lists","or","None","Variables","grouped","in","aspects","to","calculate","their","importance","(","default","is","`","None","`",")",".","type",":","{","'default","'",",","'shap","'","}",",","optional","Type","of","aspect","importance\/attributions","(","default","is","`","'default","'","`",",","which","means","the","use","of","simplified","LIME","method",")",".","h",":","float",",","optional","Threshold","to","apply","when","forming","aspects",",","i.e.",",","the","minimum","value","of","the","dependency","between","the","variables","grouped","in","one","aspect","(","default","is","`","0.5","`",")",".","N",":","int",",","optional","Number","of","observations","that","will","be","sampled","from","the","`","explainer.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","'","`",".","label",":","str",",","optional","Name","to","appear","in","result","and","plots",".","Overrides","default",".","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",")",".","Returns","--","--","--","-","PredictAspectImportance","class","object","Explanation","object","containing","the","main","result","attribute","and","the","plot","method","."]
code: def predict_parts(
      self,
      new_observation,
      variable_groups=None,
      type="default",
      h=0.5,
      N=2000,
      B=25,
      n_aspects=None,
      sample_method="default",
      f=2,
      label=None,
      processes=1,
      random_state=None,
  ):
      """Calculate predict-level aspect importance
  
      Parameters
      ----------
      new_observation : pd.Series or np.ndarray (1d) or pd.DataFrame (1,p)
          An observation for which a prediction needs to be explained.
      variable_groups : dict of lists or None
          Variables grouped in aspects to calculate their importance (default is `None`).
      type : {'default', 'shap'}, optional
          Type of aspect importance/attributions (default is `'default'`, which means
          the use of simplified LIME method).
      h : float, optional
          Threshold to apply when forming aspects, i.e., the minimum value of the dependency
          between the variables grouped in one aspect (default is `0.5`).
      N : int, optional
          Number of observations that will be sampled from the `explainer.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'`.
      label : str, optional
          Name to appear in result and plots. Overrides default.
      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).
  
      Returns
      -------
      PredictAspectImportance class object
          Explanation object containing the main result attribute and the plot method.
      """
  
      if variable_groups is None:
          variable_groups = self.get_aspects(h)
  
      pai = PredictAspectImportance(
          variable_groups,
          type,
          N,
          B,
          n_aspects,
          sample_method,
          f,
          self.depend_method,
          self.corr_method,
          self.agg_method,
          processes,
          random_state,
          _depend_matrix=self.depend_matrix,
      )
  
      pai.fit(self.explainer, new_observation)
  
      if label is not None:
          pai.result["label"] = label
  
      return pai
  
file_path: DALEX/python/dalex/dalex/aspect/object.py
imports: import numpy
  import pandas
  from dalex.aspect._model_aspect_importance.object import ModelAspectImportance
  from dalex.aspect._predict_aspect_importance.object import PredictAspectImportance
  from dalex.aspect._model_triplot.object import ModelTriplot
  from dalex.aspect._predict_triplot.object import PredictTriplot
  from .None import utils, checks, plot
  from ..None import _theme
label_desc: Use image node_id 4 for calling the Aspect obj's underlying member method code with example usage: obj.predict_parts(new_observation, variable_groups, type, h, N, B, n_aspects, sample_method, f, label, processes, random_state) and returns: pai