class_docstr: The SmartExplainer class is the main object of the Shapash library.
  It allows the Data Scientists to perform many operations to make the
  results more understandable :
  linking encoders, models, predictions, label dict and datasets.
  SmartExplainer users have several methods which are described below.
  Parameters
  ----------
  model : model object
      model used to consistency check. model object can also be used by some method to compute
      predict and predict_proba values
  backend : str or shapash.backend object (default: 'shap')
      Select which computation method to use in order to compute contributions
      and feature importance. Possible values are 'shap' or 'lime'. Default is 'shap'.
      It is also possible to pass a backend class inherited from shpash.backend.BaseBackend.
  preprocessing : category_encoders, ColumnTransformer, list, dict, optional (default: None)
      --> Differents types of preprocessing are available:
      - A single category_encoders (OrdinalEncoder/OnehotEncoder/BaseNEncoder/BinaryEncoder/TargetEncoder)
      - A single ColumnTransformer with scikit-learn encoding or category_encoders transformers
      - A list with multiple category_encoders with optional (dict, list of dict)
      - A list with a single ColumnTransformer with optional (dict, list of dict)
      - A dict
      - A list of dict
  postprocessing : dict, optional (default: None)
      Dictionnary of postprocessing modifications to apply in x_init dataframe.
      Dictionnary with feature names as keys (or number, or well labels referencing to features names),
      which modifies dataset features by features.
      --> Different types of postprocessing are available, but the syntax is this one:
      One key by features, 5 different types of modifications:
          features_groups : dict, optional (default: None)
      Dictionnary containing features that should be grouped together. This option allows
      to compute and display the contributions and importance of this group of features.
      Features that are grouped together will still be displayed in the webapp when clicking
      on a group.
      >>> {
      ‘feature1’ : { ‘type’ : ‘prefix’, ‘rule’ : ‘age: ‘ },
      ‘feature2’ : { ‘type’ : ‘suffix’, ‘rule’ : ‘$/week ‘ },
      ‘feature3’ : { ‘type’ : ‘transcoding’, ‘rule‘: { ‘code1’ : ‘single’, ‘code2’ : ‘married’}},
      ‘feature4’ : { ‘type’ : ‘regex’ , ‘rule‘: { ‘in’ : ‘AND’, ‘out’ : ‘ & ‘ }},
      ‘feature5’ : { ‘type’ : ‘case’ , ‘rule‘: ‘lower’‘ }
      }
      Only one transformation by features is possible.
  features_groups : dict, optional (default: None)
      Dictionnary containing features that should be grouped together. This option allows
      to compute and display the contributions and importance of this group of features.
      Features that are grouped together will still be displayed in the webapp when clicking
      on a group.
      >>> {
      ‘feature_group_1’ : ['feature3', 'feature7', 'feature24'],
      ‘feature_group_2’ : ['feature1', 'feature12'],
      }
  features_dict: dict
      Dictionary mapping technical feature names to domain names.
  label_dict: dict
      Dictionary mapping integer labels to domain names (classification - target values).
  title_story: str (default: None)
      The default title is empty. You can specify a custom title
      which can be used the webapp, or other methods
  palette_name : str
      Name of the palette used for the colors of the report (refer to style folder).
  colors_dic : dict
      dictionnary contaning every palettes of colors. You can use this parameter to change
      any color of the graphs.
  **backend_kwargs : dict
      Keyword parameters to be passed to the backend.
  
  Attributes
  ----------
  data: dict
      Data dictionary has 3 entries. Each key returns a pd.DataFrame (regression) or a list of pd.DataFrame
      (classification - The length of the lists is equivalent to the number of labels).
      All pd.DataFrame have she same shape (n_samples, n_features).
      For the regression case, data that should be regarded as a single array
      of size (n_samples, n_features, 3).
      data['contrib_sorted']: pandas.DataFrame (regression) or list of pandas.DataFrame (classification)
          Contains local contributions of the prediction set, with common line index.
          Columns are 'contrib_1', 'contrib_2', ... and contains the top contributions
          for each line from left to right. In multi-class problems, this is a list of
          contributions, one for each class.
      data['var_dict']: pandas.DataFrame (regression) or list of pandas.DataFrame (classification)
          Must contain only ints. It gives, for each line, the list of most import features
          regarding the local decomposition. In order to save space, columns are denoted by
          integers, the conversion being done with the columns_dict member. In multi-class
          problems, this is a list of dataframes, one for each class.
      data['x_sorted']: pandas.DataFrame (regression) or list of pandas.DataFrame (classification)
          It gives, for each line, the list of most important features values regarding the local
          decomposition. These values can only be understood with respect to data['var_dict']
  backend_name:
      backend name if backend passed is a string 
  x_encoded: pandas.DataFrame
      preprocessed dataset used by the model to perform the prediction.
  x_init: pandas.DataFrame
      x_encoded dataset with inverse transformation with eventual postprocessing modifications.
  x_contrib_plot: pandas.DataFrame
      x_encoded dataset with inverse transformation, without postprocessing used for contribution_plot.
  y_pred: pandas.DataFrame
      User-specified prediction values.
  contributions: pandas.DataFrame (regression) or list (classification)
      local contributions aggregated if the preprocessing part requires it (e.g. one-hot encoding).
  features_dict: dict
      Dictionary mapping technical feature names to domain names.
  inv_features_dict: dict
      Inverse features_dict mapping.
  label_dict: dict
      Dictionary mapping integer labels to domain names (classification - target values).
  inv_label_dict: dict
      Inverse label_dict mapping.
  columns_dict: dict
      Dictionary mapping integer column number to technical feature names.
  plot: object
      Helper object containing all plotting functions (Bridge pattern).
  model: model object
      model used to check the different values of target estimate predict proba
  features_desc: dict
      Dictionary that references the numbers of feature values ​​in the x_init
  features_imp: pandas.Series (regression) or list (classification)
      Features importance values
  local_neighbors: dict
      Dictionary of values to be displayed on the local_neighbors plot.
      The key is "norm_shap (normalized contributions values of instance and neighbors)
  features_stability: dict
      Dictionary of arrays to be displayed on the stability plot.
      The keys are "amplitude" (average contributions values for selected instances) and
      "stability" (stability metric across neighborhood)
  preprocessing : category_encoders, ColumnTransformer, list or dict
      The processing apply to the original data.
  postprocessing : dict
      Dictionnary of postprocessing modifications to apply in x_init dataframe.
  y_target : pandas.Series or pandas.DataFrame, optional (default: None)
      Target values
  
  Example
  --------
  >>> xpl = SmartExplainer(model, features_dict=featd,label_dict=labeld)
  >>> xpl.compile(x=x_encoded, y_target=y)
  >>> xpl.plot.features_importance()
class_docstr_tok: ["The","SmartExplainer","class","is","the","main","object","of","the","Shapash","library",".","It","allows","the","Data","Scientists","to","perform","many","operations","to","make","the","results","more","understandable",":","linking","encoders",",","models",",","predictions",",","label","dict","and","datasets",".","SmartExplainer","users","have","several","methods","which","are","described","below",".","Parameters","--","--","--","--","--","model",":","model","object","model","used","to","consistency","check",".","model","object","can","also","be","used","by","some","method","to","compute","predict","and","predict_proba","values","backend",":","str","or","shapash.backend","object","(","default",":","'shap","'",")","Select","which","computation","method","to","use","in","order","to","compute","contributions","and","feature","importance",".","Possible","values","are","'shap","'","or","'lime","'",".","Default","is","'shap","'",".","It","is","also","possible","to","pass","a","backend","class","inherited","from","shpash.backend.BaseBackend",".","preprocessing",":","category_encoders",",","ColumnTransformer",",","list",",","dict",",","optional","(","default",":","None",")","--",">","Differents","types","of","preprocessing","are","available",":","-","A","single","category_encoders","(","OrdinalEncoder\/OnehotEncoder\/BaseNEncoder\/BinaryEncoder\/TargetEncoder",")","-","A","single","ColumnTransformer","with","scikit-learn","encoding","or","category_encoders","transformers","-","A","list","with","multiple","category_encoders","with","optional","(","dict",",","list","of","dict",")","-","A","list","with","a","single","ColumnTransformer","with","optional","(","dict",",","list","of","dict",")","-","A","dict","-","A","list","of","dict","postprocessing",":","dict",",","optional","(","default",":","None",")","Dictionnary","of","postprocessing","modifications","to","apply","in","x_init","dataframe",".","Dictionnary","with","feature","names","as","keys","(","or","number",",","or","well","labels","referencing","to","features","names",")",",","which","modifies","dataset","features","by","features",".","--",">","Different","types","of","postprocessing","are","available",",","but","the","syntax","is","this","one",":","One","key","by","features",",","5","different","types","of","modifications",":","features_groups",":","dict",",","optional","(","default",":","None",")","Dictionnary","containing","features","that","should","be","grouped","together",".","This","option","allows","to","compute","and","display","the","contributions","and","importance","of","this","group","of","features",".","Features","that","are","grouped","together","will","still","be","displayed","in","the","webapp","when","clicking","on","a","group",".",">",">",">","{","\u2018","feature1","\u2019",":","{","\u2018","type","\u2019",":","\u2018","prefix","\u2019",",","\u2018","rule","\u2019",":","\u2018","age",":","\u2018","}",",","\u2018","feature2","\u2019",":","{","\u2018","type","\u2019",":","\u2018","suffix","\u2019",",","\u2018","rule","\u2019",":","\u2018","$","\/week","\u2018","}",",","\u2018","feature3","\u2019",":","{","\u2018","type","\u2019",":","\u2018","transcoding","\u2019",",","\u2018","rule","\u2018",":","{","\u2018","code1","\u2019",":","\u2018","single","\u2019",",","\u2018","code2","\u2019",":","\u2018","married","\u2019","}","}",",","\u2018","feature4","\u2019",":","{","\u2018","type","\u2019",":","\u2018","regex","\u2019",",","\u2018","rule","\u2018",":","{","\u2018","in","\u2019",":","\u2018","AND","\u2019",",","\u2018","out","\u2019",":","\u2018","&","\u2018","}","}",",","\u2018","feature5","\u2019",":","{","\u2018","type","\u2019",":","\u2018","case","\u2019",",","\u2018","rule","\u2018",":","\u2018","lower","\u2019","\u2018","}","}","Only","one","transformation","by","features","is","possible",".","features_groups",":","dict",",","optional","(","default",":","None",")","Dictionnary","containing","features","that","should","be","grouped","together",".","This","option","allows","to","compute","and","display","the","contributions","and","importance","of","this","group","of","features",".","Features","that","are","grouped","together","will","still","be","displayed","in","the","webapp","when","clicking","on","a","group",".",">",">",">","{","\u2018","feature_group_1","\u2019",":","[","'feature3","'",",","'feature7","'",",","'feature24","'","]",",","\u2018","feature_group_2","\u2019",":","[","'feature1","'",",","'feature12","'","]",",","}","features_dict",":","dict","Dictionary","mapping","technical","feature","names","to","domain","names",".","label_dict",":","dict","Dictionary","mapping","integer","labels","to","domain","names","(","classification","-","target","values",")",".","title_story",":","str","(","default",":","None",")","The","default","title","is","empty",".","You","can","specify","a","custom","title","which","can","be","used","the","webapp",",","or","other","methods","palette_name",":","str","Name","of","the","palette","used","for","the","colors","of","the","report","(","refer","to","style","folder",")",".","colors_dic",":","dict","dictionnary","contaning","every","palettes","of","colors",".","You","can","use","this","parameter","to","change","any","color","of","the","graphs",".","*","*","backend_kwargs",":","dict","Keyword","parameters","to","be","passed","to","the","backend",".","Attributes","--","--","--","--","--","data",":","dict","Data","dictionary","has","3","entries",".","Each","key","returns","a","pd.DataFrame","(","regression",")","or","a","list","of","pd.DataFrame","(","classification","-","The","length","of","the","lists","is","equivalent","to","the","number","of","labels",")",".","All","pd.DataFrame","have","she","same","shape","(","n_samples",",","n_features",")",".","For","the","regression","case",",","data","that","should","be","regarded","as","a","single","array","of","size","(","n_samples",",","n_features",",","3",")",".","data","[","'contrib_sorted","'","]",":","pandas.DataFrame","(","regression",")","or","list","of","pandas.DataFrame","(","classification",")","Contains","local","contributions","of","the","prediction","set",",","with","common","line","index",".","Columns","are","'contrib_1","'",",","'contrib_2","'",",","...","and","contains","the","top","contributions","for","each","line","from","left","to","right",".","In","multi-class","problems",",","this","is","a","list","of","contributions",",","one","for","each","class",".","data","[","'var_dict","'","]",":","pandas.DataFrame","(","regression",")","or","list","of","pandas.DataFrame","(","classification",")","Must","contain","only","ints",".","It","gives",",","for","each","line",",","the","list","of","most","import","features","regarding","the","local","decomposition",".","In","order","to","save","space",",","columns","are","denoted","by","integers",",","the","conversion","being","done","with","the","columns_dict","member",".","In","multi-class","problems",",","this","is","a","list","of","dataframes",",","one","for","each","class",".","data","[","'x_sorted","'","]",":","pandas.DataFrame","(","regression",")","or","list","of","pandas.DataFrame","(","classification",")","It","gives",",","for","each","line",",","the","list","of","most","important","features","values","regarding","the","local","decomposition",".","These","values","can","only","be","understood","with","respect","to","data","[","'var_dict","'","]","backend_name",":","backend","name","if","backend","passed","is","a","string","x_encoded",":","pandas.DataFrame","preprocessed","dataset","used","by","the","model","to","perform","the","prediction",".","x_init",":","pandas.DataFrame","x_encoded","dataset","with","inverse","transformation","with","eventual","postprocessing","modifications",".","x_contrib_plot",":","pandas.DataFrame","x_encoded","dataset","with","inverse","transformation",",","without","postprocessing","used","for","contribution_plot",".","y_pred",":","pandas.DataFrame","User-specified","prediction","values",".","contributions",":","pandas.DataFrame","(","regression",")","or","list","(","classification",")","local","contributions","aggregated","if","the","preprocessing","part","requires","it","(","e.g",".","one-hot","encoding",")",".","features_dict",":","dict","Dictionary","mapping","technical","feature","names","to","domain","names",".","inv_features_dict",":","dict","Inverse","features_dict","mapping",".","label_dict",":","dict","Dictionary","mapping","integer","labels","to","domain","names","(","classification","-","target","values",")",".","inv_label_dict",":","dict","Inverse","label_dict","mapping",".","columns_dict",":","dict","Dictionary","mapping","integer","column","number","to","technical","feature","names",".","plot",":","object","Helper","object","containing","all","plotting","functions","(","Bridge","pattern",")",".","model",":","model","object","model","used","to","check","the","different","values","of","target","estimate","predict","proba","features_desc",":","dict","Dictionary","that","references","the","numbers","of","feature","values","\u200b\u200bin","the","x_init","features_imp",":","pandas.Series","(","regression",")","or","list","(","classification",")","Features","importance","values","local_neighbors",":","dict","Dictionary","of","values","to","be","displayed","on","the","local_neighbors","plot",".","The","key","is","``","norm_shap","(","normalized","contributions","values","of","instance","and","neighbors",")","features_stability",":","dict","Dictionary","of","arrays","to","be","displayed","on","the","stability","plot",".","The","keys","are","``","amplitude","''","(","average","contributions","values","for","selected","instances",")","and","``","stability","''","(","stability","metric","across","neighborhood",")","preprocessing",":","category_encoders",",","ColumnTransformer",",","list","or","dict","The","processing","apply","to","the","original","data",".","postprocessing",":","dict","Dictionnary","of","postprocessing","modifications","to","apply","in","x_init","dataframe",".","y_target",":","pandas.Series","or","pandas.DataFrame",",","optional","(","default",":","None",")","Target","values","Example","--","--","--","--",">",">",">","xpl","=","SmartExplainer","(","model",",","features_dict=featd",",","label_dict=labeld",")",">",">",">","xpl.compile","(","x=x_encoded",",","y_target=y",")",">",">",">","xpl.plot.features_importance","(",")"]
docstr: Modifies x_init Dataframe according to postprocessing modifications, if exists.
  Parameters
  ----------
  postprocessing: Dict
      Dictionnary of postprocessing modifications to apply in x_init.
  Returns
  -------
  pandas.Dataframe
      Returns x_init if postprocessing is empty, modified dataframe otherwise.
docstr_tok: ["Modifies","x_init","Dataframe","according","to","postprocessing","modifications",",","if","exists",".","Parameters","--","--","--","--","--","postprocessing",":","Dict","Dictionnary","of","postprocessing","modifications","to","apply","in","x_init",".","Returns","--","--","--","-","pandas.Dataframe","Returns","x_init","if","postprocessing","is","empty",",","modified","dataframe","otherwise","."]
code: def apply_postprocessing(self, postprocessing=None):
      """
      Modifies x_init Dataframe according to postprocessing modifications, if exists.
      Parameters
      ----------
      postprocessing: Dict
          Dictionnary of postprocessing modifications to apply in x_init.
      Returns
      -------
      pandas.Dataframe
          Returns x_init if postprocessing is empty, modified dataframe otherwise.
      """
      if postprocessing:
          return apply_postprocessing(self.x_init, postprocessing)
      else:
          return self.x_init
  
imports: import logging
  import copy
  import tempfile
  import shutil
  import numpy
  import pandas
  from shapash.webapp.smart_app import SmartApp
  from shapash.backend import BaseBackend, get_backend_cls_from_name
  from shapash.utils.io import save_pickle
  from shapash.utils.io import load_pickle
  from shapash.utils.transform import inverse_transform, apply_postprocessing, handle_categorical_missing
  from shapash.utils.utils import get_host_name
  from shapash.utils.threading import CustomThread
  from shapash.utils.check import check_model, check_label_dict, check_y, check_postprocessing, check_features_name, check_additional_data
  from shapash.backend.shap_backend import get_shap_interaction_values
  from shapash.manipulation.select_lines import keep_right_contributions
  from shapash.report import check_report_requirements
  from shapash.manipulation.summarize import create_grouped_features_values
  from .smart_plotter import SmartPlotter
  import shapash.explainer.smart_predictor
  from shapash.utils.model import predict_proba, predict, predict_error
  from shapash.utils.explanation_metrics import find_neighbors, shap_neighbors, get_min_nb_features, get_distance
  from shapash.style.style_utils import colors_loading, select_palette
label_desc: Use image node_id 13 for calling the SmartExplainer obj's underlying member method code with example usage: obj.apply_postprocessing(postprocessing) and returns: apply_postprocessing, self