class_docstr: Create Model Explainer
  
  Black-box models may have very different structures. This class creates a unified
  representation of a model, which can be further processed by various explanations.
  Methods of this class produce explanation objects, that contain the main result
  attribute, and can be visualised using the plot method.
  
  The `model` is the only required parameter, but most of the explanations require
  that other parameters are provided (See `data`, `y`, `predict_function`, `model_type`).
  
  Parameters
  ----------
  model : object
      Model to be explained.
  data : pd.DataFrame or np.ndarray (2d)
      Data which will be used to calculate the explanations. It shouldn't contain
      the target column (See `y`).
      NOTE: If target variable is present in the data, some of the functionalities may
      not work properly.
  y : pd.Series or pd.DataFrame or np.ndarray (1d)
      Target variable with outputs / scores. It shall have the same length as `data`.
  predict_function : function, optional
      Function that takes two parameters (model, data) and returns a np.ndarray (1d)
      with model predictions (default is predict method extracted from the model).
      NOTE: This function needs to work with `data` as pd.DataFrame.
  residual_function : function, optional
      Function that takes three parameters (model, data, y) and returns a np.ndarray (1d)
      with model residuals (default is a function constructed from `predict_function`).
  weights : pd.Series or np.ndarray (1d), optional
      Sampling weights for observations in `data`. It shall have the same length as
      `data` (default is `None`).
  label : str, optional
      Model name to appear in result and plots
      (default is last element of the class attribute extracted from the model).
  model_class : str, optional
      Class of the model that is used e.g. to choose the `predict_function`
      (default is the class attribute extracted from the model).
      NOTE: Use if your model is wrapped with Pipeline.
  verbose : bool
      Print diagnostic messages during the Explainer initialization (default is `True`).
  precalculate : bool
      Calculate y_hat (predicted values) and residuals during the Explainer
      initialization (default is `True`).
  model_type : {'regression', 'classification', None}
      Model task type that is used e.g. in `model_performance()` and `model_parts()`
      (default is try to extract the information from the model, else `None`).
  model_info: dict, optional
      Dict `{'model_package', 'model_package_version', ...}` containing additional
      information to be stored.
  
  Attributes
  --------
  model : object
      A model to be explained.
  data : pd.DataFrame
      Data which will be used to calculate the explanations.
  y : np.ndarray (1d)
      Target variable with outputs / scores.
  predict_function : function
      Function that takes two arguments (model, data) and returns np.ndarray (1d)
      with model predictions.
  y_hat : np.ndarray (1d)
      Model predictions for `data`.
  residual_function : function
      Function that takes three arguments (model, data, y) and returns np.ndarray (1d)
      with model residuals.
  residuals : np.ndarray (1d)
      Model residuals for `data`.
  weights : np.ndarray (1d)
      Sampling weights for observations in `data`.
  label : str
      Name to appear in result and plots.
  model_class : str
      Class of the model.
  model_type : {'regression', 'classification', `None`}
      Model task type.
  model_info: dict
      Dict `{'model_package', 'model_package_version', ...}` containing additional
      information.
  
  Notes
  --------
  - https://pbiecek.github.io/ema/dataSetsIntro.html#ExplainersTitanicPythonCode
class_docstr_tok: ["Create","Model","Explainer","Black-box","models","may","have","very","different","structures",".","This","class","creates","a","unified","representation","of","a","model",",","which","can","be","further","processed","by","various","explanations",".","Methods","of","this","class","produce","explanation","objects",",","that","contain","the","main","result","attribute",",","and","can","be","visualised","using","the","plot","method",".","The","`","model","`","is","the","only","required","parameter",",","but","most","of","the","explanations","require","that","other","parameters","are","provided","(","See","`","data","`",",","`","y","`",",","`","predict_function","`",",","`","model_type","`",")",".","Parameters","--","--","--","--","--","model",":","object","Model","to","be","explained",".","data",":","pd.DataFrame","or","np.ndarray","(","2d",")","Data","which","will","be","used","to","calculate","the","explanations",".","It","should","n't","contain","the","target","column","(","See","`","y","`",")",".","NOTE",":","If","target","variable","is","present","in","the","data",",","some","of","the","functionalities","may","not","work","properly",".","y",":","pd.Series","or","pd.DataFrame","or","np.ndarray","(","1d",")","Target","variable","with","outputs","\/","scores",".","It","shall","have","the","same","length","as","`","data","`",".","predict_function",":","function",",","optional","Function","that","takes","two","parameters","(","model",",","data",")","and","returns","a","np.ndarray","(","1d",")","with","model","predictions","(","default","is","predict","method","extracted","from","the","model",")",".","NOTE",":","This","function","needs","to","work","with","`","data","`","as","pd.DataFrame",".","residual_function",":","function",",","optional","Function","that","takes","three","parameters","(","model",",","data",",","y",")","and","returns","a","np.ndarray","(","1d",")","with","model","residuals","(","default","is","a","function","constructed","from","`","predict_function","`",")",".","weights",":","pd.Series","or","np.ndarray","(","1d",")",",","optional","Sampling","weights","for","observations","in","`","data","`",".","It","shall","have","the","same","length","as","`","data","`","(","default","is","`","None","`",")",".","label",":","str",",","optional","Model","name","to","appear","in","result","and","plots","(","default","is","last","element","of","the","class","attribute","extracted","from","the","model",")",".","model_class",":","str",",","optional","Class","of","the","model","that","is","used","e.g",".","to","choose","the","`","predict_function","`","(","default","is","the","class","attribute","extracted","from","the","model",")",".","NOTE",":","Use","if","your","model","is","wrapped","with","Pipeline",".","verbose",":","bool","Print","diagnostic","messages","during","the","Explainer","initialization","(","default","is","`","True","`",")",".","precalculate",":","bool","Calculate","y_hat","(","predicted","values",")","and","residuals","during","the","Explainer","initialization","(","default","is","`","True","`",")",".","model_type",":","{","'regression","'",",","'classification","'",",","None","}","Model","task","type","that","is","used","e.g",".","in","`","model_performance","(",")","`","and","`","model_parts","(",")","`","(","default","is","try","to","extract","the","information","from","the","model",",","else","`","None","`",")",".","model_info",":","dict",",","optional","Dict","`","{","'model_package","'",",","'model_package_version","'",",","...","}","`","containing","additional","information","to","be","stored",".","Attributes","--","--","--","--","model",":","object","A","model","to","be","explained",".","data",":","pd.DataFrame","Data","which","will","be","used","to","calculate","the","explanations",".","y",":","np.ndarray","(","1d",")","Target","variable","with","outputs","\/","scores",".","predict_function",":","function","Function","that","takes","two","arguments","(","model",",","data",")","and","returns","np.ndarray","(","1d",")","with","model","predictions",".","y_hat",":","np.ndarray","(","1d",")","Model","predictions","for","`","data","`",".","residual_function",":","function","Function","that","takes","three","arguments","(","model",",","data",",","y",")","and","returns","np.ndarray","(","1d",")","with","model","residuals",".","residuals",":","np.ndarray","(","1d",")","Model","residuals","for","`","data","`",".","weights",":","np.ndarray","(","1d",")","Sampling","weights","for","observations","in","`","data","`",".","label",":","str","Name","to","appear","in","result","and","plots",".","model_class",":","str","Class","of","the","model",".","model_type",":","{","'regression","'",",","'classification","'",",","`","None","`","}","Model","task","type",".","model_info",":","dict","Dict","`","{","'model_package","'",",","'model_package_version","'",",","...","}","`","containing","additional","information",".","Notes","--","--","--","--","-","https",":","\/\/pbiecek.github.io\/ema\/dataSetsIntro.html","#","ExplainersTitanicPythonCode"]
docstr: Calculate model-level variable profiles as Partial or Accumulated Dependence
  
  Parameters
  -----------
  type : {'partial', 'accumulated', 'conditional'}
      Type of model profiles
      (default is `'partial'` for Partial Dependence Profiles).
  N : int, optional
      Number of observations that will be sampled from the `data` attribute before
      the calculation of variable profiles. `None` means all `data` (default is `300`).
  variables : str or array_like of str, optional
      Variables for which the profiles will be calculated
      (default is `None`, which means all of the variables).
  variable_type : {'numerical', 'categorical'}
      Calculate the profiles for numerical or categorical variables
      (default is `'numerical'`).
  groups : str or array_like of str, optional
      Names of categorical variables that will be used for profile grouping
      (default is `None`, which means no grouping).
  span : float, optional
      Smoothing coefficient used as sd for gaussian kernel (default is `0.25`).
  grid_points : int, optional
      Maximum number of points for profile calculations (default is `101`).
      NOTE: The final number of points may be lower than `grid_points`,
      e.g. if there is not enough unique values for a given variable.
  variable_splits : dict of lists, optional
      Split points for variables e.g. `{'x': [0, 0.2, 0.5, 0.8, 1], 'y': ['a', 'b']}`
      (default is `None`, which means that they will be distributed uniformly).
  variable_splits_type : {'uniform', 'quantiles'}, optional
      Way of calculating `variable_splits`. Set 'quantiles' for percentiles.
      (default is `'uniform'`, which means uniform grid of points).
  center : bool, optional
      Theoretically Accumulated Profiles start at `0`, but are centered to compare
      them with Partial Dependence Profiles (default is `True`, which means center
      around the average `y_hat` calculated on the data sample).
  label : str, optional
      Name to appear in result and plots. Overrides default.
  processes : int, optional
      Number of parallel processes to use in calculations. Iterated over `variables`
      (default is `1`, which means no parallel computation).
  random_state : int, optional
      Set seed for random number generator (default is random seed).
  verbose : bool, optional
      Print tqdm progress bar (default is `True`).
  
  Returns
  -----------
  AggregatedProfiles class object
      Explanation object containing the main result attribute and the plot method.
  
  Notes
  --------
  - https://pbiecek.github.io/ema/partialDependenceProfiles.html
  - https://pbiecek.github.io/ema/accumulatedLocalProfiles.html
docstr_tok: ["Calculate","model-level","variable","profiles","as","Partial","or","Accumulated","Dependence","Parameters","--","--","--","--","--","-","type",":","{","'partial","'",",","'accumulated","'",",","'conditional","'","}","Type","of","model","profiles","(","default","is","`","'partial","'","`","for","Partial","Dependence","Profiles",")",".","N",":","int",",","optional","Number","of","observations","that","will","be","sampled","from","the","`","data","`","attribute","before","the","calculation","of","variable","profiles",".","`","None","`","means","all","`","data","`","(","default","is","`","300","`",")",".","variables",":","str","or","array_like","of","str",",","optional","Variables","for","which","the","profiles","will","be","calculated","(","default","is","`","None","`",",","which","means","all","of","the","variables",")",".","variable_type",":","{","'numerical","'",",","'categorical","'","}","Calculate","the","profiles","for","numerical","or","categorical","variables","(","default","is","`","'numerical","'","`",")",".","groups",":","str","or","array_like","of","str",",","optional","Names","of","categorical","variables","that","will","be","used","for","profile","grouping","(","default","is","`","None","`",",","which","means","no","grouping",")",".","span",":","float",",","optional","Smoothing","coefficient","used","as","sd","for","gaussian","kernel","(","default","is","`","0.25","`",")",".","grid_points",":","int",",","optional","Maximum","number","of","points","for","profile","calculations","(","default","is","`","101","`",")",".","NOTE",":","The","final","number","of","points","may","be","lower","than","`","grid_points","`",",","e.g",".","if","there","is","not","enough","unique","values","for","a","given","variable",".","variable_splits",":","dict","of","lists",",","optional","Split","points","for","variables","e.g",".","`","{","'","x","'",":","[","0",",","0.2",",","0.5",",","0.8",",","1","]",",","'","y","'",":","[","'","a","'",",","'","b","'","]","}","`","(","default","is","`","None","`",",","which","means","that","they","will","be","distributed","uniformly",")",".","variable_splits_type",":","{","'uniform","'",",","'quantiles","'","}",",","optional","Way","of","calculating","`","variable_splits","`",".","Set","'quantiles","'","for","percentiles",".","(","default","is","`","'uniform","'","`",",","which","means","uniform","grid","of","points",")",".","center",":","bool",",","optional","Theoretically","Accumulated","Profiles","start","at","`","0","`",",","but","are","centered","to","compare","them","with","Partial","Dependence","Profiles","(","default","is","`","True","`",",","which","means","center","around","the","average","`","y_hat","`","calculated","on","the","data","sample",")",".","label",":","str",",","optional","Name","to","appear","in","result","and","plots",".","Overrides","default",".","processes",":","int",",","optional","Number","of","parallel","processes","to","use","in","calculations",".","Iterated","over","`","variables","`","(","default","is","`","1","`",",","which","means","no","parallel","computation",")",".","random_state",":","int",",","optional","Set","seed","for","random","number","generator","(","default","is","random","seed",")",".","verbose",":","bool",",","optional","Print","tqdm","progress","bar","(","default","is","`","True","`",")",".","Returns","--","--","--","--","--","-","AggregatedProfiles","class","object","Explanation","object","containing","the","main","result","attribute","and","the","plot","method",".","Notes","--","--","--","--","-","https",":","\/\/pbiecek.github.io\/ema\/partialDependenceProfiles.html","-","https",":","\/\/pbiecek.github.io\/ema\/accumulatedLocalProfiles.html"]
code: def model_profile(
      self,
      type=("partial", "accumulated", "conditional"),
      N=300,
      variables=None,
      variable_type="numerical",
      groups=None,
      span=0.25,
      grid_points=101,
      variable_splits=None,
      variable_splits_type="uniform",
      center=True,
      label=None,
      processes=1,
      random_state=None,
      verbose=True,
  ):
      """Calculate model-level variable profiles as Partial or Accumulated Dependence
  
      Parameters
      -----------
      type : {'partial', 'accumulated', 'conditional'}
          Type of model profiles
          (default is `'partial'` for Partial Dependence Profiles).
      N : int, optional
          Number of observations that will be sampled from the `data` attribute before
          the calculation of variable profiles. `None` means all `data` (default is `300`).
      variables : str or array_like of str, optional
          Variables for which the profiles will be calculated
          (default is `None`, which means all of the variables).
      variable_type : {'numerical', 'categorical'}
          Calculate the profiles for numerical or categorical variables
          (default is `'numerical'`).
      groups : str or array_like of str, optional
          Names of categorical variables that will be used for profile grouping
          (default is `None`, which means no grouping).
      span : float, optional
          Smoothing coefficient used as sd for gaussian kernel (default is `0.25`).
      grid_points : int, optional
          Maximum number of points for profile calculations (default is `101`).
          NOTE: The final number of points may be lower than `grid_points`,
          e.g. if there is not enough unique values for a given variable.
      variable_splits : dict of lists, optional
          Split points for variables e.g. `{'x': [0, 0.2, 0.5, 0.8, 1], 'y': ['a', 'b']}`
          (default is `None`, which means that they will be distributed uniformly).
      variable_splits_type : {'uniform', 'quantiles'}, optional
          Way of calculating `variable_splits`. Set 'quantiles' for percentiles.
          (default is `'uniform'`, which means uniform grid of points).
      center : bool, optional
          Theoretically Accumulated Profiles start at `0`, but are centered to compare
          them with Partial Dependence Profiles (default is `True`, which means center
          around the average `y_hat` calculated on the data sample).
      label : str, optional
          Name to appear in result and plots. Overrides default.
      processes : int, optional
          Number of parallel processes to use in calculations. Iterated over `variables`
          (default is `1`, which means no parallel computation).
      random_state : int, optional
          Set seed for random number generator (default is random seed).
      verbose : bool, optional
          Print tqdm progress bar (default is `True`).
  
      Returns
      -----------
      AggregatedProfiles class object
          Explanation object containing the main result attribute and the plot method.
  
      Notes
      --------
      - https://pbiecek.github.io/ema/partialDependenceProfiles.html
      - https://pbiecek.github.io/ema/accumulatedLocalProfiles.html
      """
  
      checks.check_data_again(self.data)
  
      types = ("partial", "accumulated", "conditional")
      aliases = {"pdp": "partial", "ale": "accumulated"}
      _type = checks.check_method_type(type, types, aliases)
  
      _ceteris_paribus = CeterisParibus(
          grid_points=grid_points,
          variables=variables,
          variable_splits=variable_splits,
          variable_splits_type=variable_splits_type,
          processes=processes,
      )
  
      if isinstance(N, int):
          if isinstance(random_state, int):
              np.random.seed(random_state)
          N = min(N, self.data.shape[0])
          I = np.random.choice(
              np.arange(self.data.shape[0]), N, replace=False
          )
          _y = self.y[I] if self.y is not None else self.y
          _new_observation = self.data.iloc[I, :]
      else:
          _y = self.y
          _new_observation = self.data
  
      _ceteris_paribus.fit(self, _new_observation, _y, verbose=verbose)
  
      _model_profile = AggregatedProfiles(
          type=_type,
          variables=variables,
          variable_type=variable_type,
          groups=groups,
          span=span,
          center=center,
          random_state=random_state,
      )
  
      _model_profile.fit(_ceteris_paribus, verbose)
  
      if label:
          _model_profile.result["_label_"] = label
  
      return _model_profile
  
imports: import numpy
  from dalex.model_explanations import ModelPerformance, VariableImportance, AggregatedProfiles, ResidualDiagnostics
  from dalex.predict_explanations import BreakDown, Shap, CeterisParibus
  from dalex.wrappers import ShapWrapper
  from dalex.fairness import GroupFairnessClassification, GroupFairnessRegression
  from .None import checks
  from .None import utils
  from .None import helper
  from ..None import _global_checks
label_desc: Use image node_id 9 for calling the Explainer obj's underlying member method code with example usage: obj.model_profile(type, N, variables, variable_type, groups, span, grid_points, variable_splits, variable_splits_type, center, label, processes, random_state, verbose) and returns: _model_profile