<jupyter_start><jupyter_text><jupyter_code>!pip install explainerdashboard
from sklearn.ensemble import RandomForestClassifier
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from explainerdashboard.datasets import titanic_survive, titanic_names

feature_descriptions = {
    "Sex": "Gender of passenger",
    "Gender": "Gender of passenger",
    "Deck": "The deck the passenger had their cabin on",
    "PassengerClass": "The class of the ticket: 1st, 2nd or 3rd class",
    "Fare": "The amount of money people paid", 
    "Embarked": "the port where the passenger boarded the Titanic. Either Southampton, Cherbourg or Queenstown",
    "Age": "Age of the passenger",
    "No_of_siblings_plus_spouses_on_board": "The sum of the number of siblings plus the number of spouses on board",
    "No_of_parents_plus_children_on_board" : "The sum of the number of parents plus the number of children on board",
}

X_train, y_train, X_test, y_test = titanic_survive()
train_names, test_names = titanic_names()
model = RandomForestClassifier(n_estimators=50, max_depth=5)
model.fit(X_train, y_train)

explainer = ClassifierExplainer(model, X_test, y_test, 
  cats=['Deck', 'Embarked',
  {'Gender': ['Sex_male', 'Sex_female', 'Sex_nan']}],
  descriptions=feature_descriptions, # defaults to None
  labels=['Not survived', 'Survived'], # defaults to ['0', '1', etc]
  idxs = test_names, # defaults to X.index
  index_name = "Passenger", # defaults to X.index.name
  target = "Survival", # defaults to y.name
  )

db = ExplainerDashboard(explainer, 
  title="Titanic Explainer", # defaults to "Model Explainer"
  whatif=False, # you can switch off tabs with bools
                        )
db.run(port=8050)
from explainerdashboard import InlineExplainer

InlineExplainer(explainer).tab.whatif()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10096153846153846, 'fraction_numerical': 0.00641025641025641, 'mean_word_length': 4.658610271903323, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '496683', 'license': 'MIT', 'n_tokens_mistral': 635, 'n_tokens_neox': 600, 'n_words': 174, 'path': 'ExplainModel.ipynb', 'repo_name': 'mleyvaz/Data-science-python', 'size': '1872'}