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 model performance measures
  
  Parameters
  -----------
  model_type : {'regression', 'classification', None}
      Model task type that is used to choose the proper performance measures
      (default is `None`, which means try to extract from the `model_type` attribute).
  cutoff : float, optional
      Cutoff for predictions in classification models. Needed for measures like
      recall, precision, acc, f1 (default is `0.5`).
  label : str, optional
      Name to appear in result and plots. Overrides default.
  
  Returns
  -----------
  ModelPerformance class object
      Explanation object containing the main result attribute and the plot method.
  
  Notes
  --------
  - https://pbiecek.github.io/ema/modelPerformance.html
docstr_tok: ["Calculate","model-level","model","performance","measures","Parameters","--","--","--","--","--","-","model_type",":","{","'regression","'",",","'classification","'",",","None","}","Model","task","type","that","is","used","to","choose","the","proper","performance","measures","(","default","is","`","None","`",",","which","means","try","to","extract","from","the","`","model_type","`","attribute",")",".","cutoff",":","float",",","optional","Cutoff","for","predictions","in","classification","models",".","Needed","for","measures","like","recall",",","precision",",","acc",",","f1","(","default","is","`","0.5","`",")",".","label",":","str",",","optional","Name","to","appear","in","result","and","plots",".","Overrides","default",".","Returns","--","--","--","--","--","-","ModelPerformance","class","object","Explanation","object","containing","the","main","result","attribute","and","the","plot","method",".","Notes","--","--","--","--","-","https",":","\/\/pbiecek.github.io\/ema\/modelPerformance.html"]
code: def model_performance(self, model_type=None, cutoff=0.5, label=None):
      """Calculate model-level model performance measures
  
      Parameters
      -----------
      model_type : {'regression', 'classification', None}
          Model task type that is used to choose the proper performance measures
          (default is `None`, which means try to extract from the `model_type` attribute).
      cutoff : float, optional
          Cutoff for predictions in classification models. Needed for measures like
          recall, precision, acc, f1 (default is `0.5`).
      label : str, optional
          Name to appear in result and plots. Overrides default.
  
      Returns
      -----------
      ModelPerformance class object
          Explanation object containing the main result attribute and the plot method.
  
      Notes
      --------
      - https://pbiecek.github.io/ema/modelPerformance.html
      """
  
      checks.check_data_again(self.data)
      checks.check_y_again(self.y)
  
      if model_type is None and self.model_type is None:
          raise TypeError(
              "if self.model_type is None, then model_type must be not None"
          )
      elif model_type is None:
          model_type = self.model_type
  
      _model_performance = ModelPerformance(
          model_type=model_type, cutoff=cutoff
      )
      _model_performance.fit(self)
  
      if label:
          _model_performance.result["label"] = label
  
      return _model_performance
  
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 7 for calling the Explainer obj's underlying member method code with example usage: obj.model_performance(model_type, cutoff, label) and returns: _model_performance