[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-oegedijk--explainerdashboard":3,"tool-oegedijk--explainerdashboard":64},[4,23,32,40,48,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":22},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,2,"2026-04-05T10:45:23",[13,14,15,16,17,18,19,20,21],"图像","数据工具","视频","插件","Agent","其他","语言模型","开发框架","音频","ready",{"id":24,"name":25,"github_repo":26,"description_zh":27,"stars":28,"difficulty_score":29,"last_commit_at":30,"category_tags":31,"status":22},2234,"scikit-learn","scikit-learn\u002Fscikit-learn","scikit-learn 是一个基于 Python 构建的开源机器学习库，依托于 SciPy、NumPy 等科学计算生态，旨在让机器学习变得简单高效。它提供了一套统一且简洁的接口，涵盖了从数据预处理、特征工程到模型训练、评估及选择的全流程工具，内置了包括线性回归、支持向量机、随机森林、聚类等在内的丰富经典算法。\n\n对于希望快速验证想法或构建原型的数据科学家、研究人员以及 Python 开发者而言，scikit-learn 是不可或缺的基础设施。它有效解决了机器学习入门门槛高、算法实现复杂以及不同模型间调用方式不统一的痛点，让用户无需重复造轮子，只需几行代码即可调用成熟的算法解决分类、回归、聚类等实际问题。\n\n其核心技术亮点在于高度一致的 API 设计风格，所有估算器（Estimator）均遵循相同的调用逻辑，极大地降低了学习成本并提升了代码的可读性与可维护性。此外，它还提供了强大的模型选择与评估工具，如交叉验证和网格搜索，帮助用户系统地优化模型性能。作为一个由全球志愿者共同维护的成熟项目，scikit-learn 以其稳定性、详尽的文档和活跃的社区支持，成为连接理论学习与工业级应用的最",65628,1,"2026-04-05T10:10:46",[20,18,14],{"id":33,"name":34,"github_repo":35,"description_zh":36,"stars":37,"difficulty_score":10,"last_commit_at":38,"category_tags":39,"status":22},3364,"keras","keras-team\u002Fkeras","Keras 是一个专为人类设计的深度学习框架，旨在让构建和训练神经网络变得简单直观。它解决了开发者在不同深度学习后端之间切换困难、模型开发效率低以及难以兼顾调试便捷性与运行性能的痛点。\n\n无论是刚入门的学生、专注算法的研究人员，还是需要快速落地产品的工程师，都能通过 Keras 轻松上手。它支持计算机视觉、自然语言处理、音频分析及时间序列预测等多种任务。\n\nKeras 3 的核心亮点在于其独特的“多后端”架构。用户只需编写一套代码，即可灵活选择 TensorFlow、JAX、PyTorch 或 OpenVINO 作为底层运行引擎。这一特性不仅保留了 Keras 一贯的高层易用性，还允许开发者根据需求自由选择：利用 JAX 或 PyTorch 的即时执行模式进行高效调试，或切换至速度最快的后端以获得最高 350% 的性能提升。此外，Keras 具备强大的扩展能力，能无缝从本地笔记本电脑扩展至大规模 GPU 或 TPU 集群，是连接原型开发与生产部署的理想桥梁。",63927,"2026-04-04T15:24:37",[20,14,18],{"id":41,"name":42,"github_repo":43,"description_zh":44,"stars":45,"difficulty_score":10,"last_commit_at":46,"category_tags":47,"status":22},2403,"crawl4ai","unclecode\u002Fcrawl4ai","Crawl4AI 是一款专为大语言模型（LLM）设计的开源网络爬虫与数据提取工具。它的核心使命是将纷繁复杂的网页内容转化为干净、结构化的 Markdown 格式，直接服务于检索增强生成（RAG）、智能体构建及各类数据管道，让 AI 能更轻松地“读懂”互联网。\n\n传统爬虫往往面临反爬机制拦截、动态内容加载困难以及输出格式杂乱等痛点，导致后续数据处理成本高昂。Crawl4AI 通过内置自动化的三级反机器人检测、代理升级策略以及对 Shadow DOM 的深度支持，有效突破了这些障碍。它能智能移除同意弹窗，处理深层链接，并具备长任务崩溃恢复能力，确保数据采集的稳定与高效。\n\n这款工具特别适合开发者、AI 研究人员及数据工程师使用。无论是需要为本地模型构建知识库，还是搭建大规模自动化信息采集流程，Crawl4AI 都提供了极高的可控性与灵活性。作为 GitHub 上备受瞩目的开源项目，它完全免费开放，无需繁琐的注册或昂贵的 API 费用，让用户能够专注于数据价值本身而非采集难题。",63242,"2026-04-02T22:29:19",[14,17],{"id":49,"name":50,"github_repo":51,"description_zh":52,"stars":53,"difficulty_score":10,"last_commit_at":54,"category_tags":55,"status":22},193,"meilisearch","meilisearch\u002Fmeilisearch","Meilisearch 是一个开源的极速搜索服务，专为现代应用和网站打造，开箱即用。它能帮助开发者快速集成高质量的搜索功能，无需复杂的配置或额外的数据预处理。传统搜索方案往往需要大量调优才能实现准确结果，而 Meilisearch 内置了拼写容错、同义词识别、即时响应等实用特性，并支持 AI 驱动的混合搜索（结合关键词与语义理解），显著提升用户查找信息的体验。\n\nMeilisearch 特别适合 Web 开发者、产品团队或初创公司使用，尤其适用于需要快速上线搜索功能的场景，如电商网站、内容平台或 SaaS 应用。它提供简洁的 RESTful API 和多种语言 SDK，部署简单，资源占用低，本地开发或生产环境均可轻松运行。对于希望在不依赖大型云服务的前提下，为用户提供流畅、智能搜索体验的团队来说，Meilisearch 是一个高效且友好的选择。",56972,"2026-04-05T22:34:33",[13,17,14,20,16,18],{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":22},223,"Made-With-ML","GokuMohandas\u002FMade-With-ML","Made-With-ML 是一个面向实战的开源项目，旨在帮助开发者系统掌握从设计、开发到部署和迭代生产级机器学习应用的完整流程。它解决了许多人在学习机器学习时“会训练模型但不会上线”的痛点，强调将软件工程最佳实践与 ML 技术结合，构建可靠、可维护的端到端系统。\n\n该项目特别适合三类人群：一是希望将模型真正落地的开发者（包括软件工程师、数据科学家）；二是刚毕业、想补齐工业界所需技能的学生；三是需要理解技术边界以更好推动产品的技术管理者或产品经理。\n\nMade-With-ML 的亮点在于注重第一性原理讲解，避免盲目调包；同时覆盖 MLOps 关键环节（如实验跟踪、模型测试、服务部署、CI\u002FCD 等），并支持在 Python 生态内平滑扩展训练与推理任务，无需切换语言或复杂基础设施。课程内容结构清晰，配有详细代码示例和视频导览，兼顾理论深度与工程实用性。",47120,"2026-04-05T22:16:18",[19,18,14,16,20],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":79,"owner_location":80,"owner_email":81,"owner_twitter":75,"owner_website":82,"owner_url":83,"languages":84,"stars":97,"forks":98,"last_commit_at":99,"license":100,"difficulty_score":10,"env_os":101,"env_gpu":102,"env_ram":102,"env_deps":103,"category_tags":115,"github_topics":116,"view_count":10,"oss_zip_url":82,"oss_zip_packed_at":82,"status":22,"created_at":128,"updated_at":129,"faqs":130,"releases":166},3675,"oegedijk\u002Fexplainerdashboard","explainerdashboard","Quickly build Explainable AI dashboards that show the inner workings of so-called \"blackbox\" machine learning models.","explainerdashboard 是一款专为机器学习模型打造的可视化工具，旨在快速构建可解释性 AI 仪表盘，让原本难以理解的“黑盒”模型变得透明直观。它有效解决了数据科学家在向业务团队或管理层展示模型决策逻辑时面临的沟通难题，通过交互式图表清晰呈现模型性能、特征重要性、单个预测的贡献度、假设分析（What-if）、部分依赖图以及 SHAP 值等关键信息。\n\n这款工具特别适合机器学习开发者、数据分析师及研究人员使用。无论是需要调试模型的工程师，还是希望向非技术人员汇报成果的数据专家，都能从中受益。其核心亮点在于极高的灵活性与兼容性：不仅支持 scikit-learn、XGBoost、LightGBM、CatBoost 等多种主流框架，还允许用户在 Jupyter Notebook 中直接探索组件或自定义布局，甚至能将多个仪表盘整合为统一的 ExplainerHub。此外，它支持将动态仪表盘导出为静态 HTML 文件，便于集成到自动化部署流程中。只需几行代码，用户即可启动一个功能完备的 Web 应用，轻松洞察模型内部运作机制，让复杂的算法决策过程变得有据可依、有迹可循。","![GitHub Workflow Status (with event)](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002Foegedijk\u002Fexplainerdashboard\u002Fexplainerdashboard.yml)\n![https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fexplainerdashboard\u002F](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fexplainerdashboard.svg)\n![https:\u002F\u002Fanaconda.org\u002Fconda-forge\u002Fexplainerdashboard\u002F](https:\u002F\u002Fanaconda.org\u002Fconda-forge\u002Fexplainerdashboard\u002Fbadges\u002Fversion.svg)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Foegedijk\u002Fexplainerdashboard\u002Fbranch\u002Fmaster\u002Fgraph\u002Fbadge.svg?token=0XU6HNEGBK)](undefined)\n[![Downloads](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_150dfe653354.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fexplainerdashboard)\n\n# explainerdashboard\nby: Oege Dijk\n\nThis package makes it convenient to quickly deploy a dashboard web app\nthat explains the workings of a (scikit-learn compatible) machine\nlearning model. The dashboard provides interactive plots on model performance,\nfeature importances, feature contributions to individual predictions,\n\"what if\" analysis,\npartial dependence plots, SHAP (interaction) values, visualization of individual\ndecision trees, etc.\n\nYou can also interactively explore components of the dashboard in a\nnotebook\u002Fcolab environment (or just launch a dashboard straight from there).\nOr design a dashboard with your own [custom layout](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fbuildcustom.html)\nand explanations (thanks to the modular design of the library). And you can combine multiple dashboards into\na single [ExplainerHub](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html).\n\nDashboards can be exported to static html directly from a running dashboard, or\nprogrammatically as an artifact as part of an automated CI\u002FCD deployment process.\n\n Examples deployed at: [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev), [Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic),\n detailed documentation at [explainerdashboard.readthedocs.io](http:\u002F\u002Fexplainerdashboard.readthedocs.io),\n example notebook on how to launch dashboard for different models [here](notebooks\u002Fdashboard_examples.ipynb), and an example notebook on how to interact with the explainer object [here](notebooks\u002Fexplainer_examples.ipynb).\n\n Works with `scikit-learn`, `xgboost`, `catboost`, `lightgbm`, and `skorch`\n (sklearn wrapper for tabular PyTorch models) and others.\n\n## Installation\n\nYou can install the package through pip:\n\n`pip install explainerdashboard`\n\nor conda-forge:\n\n`conda install -c conda-forge explainerdashboard`\n\n## SageMaker Studio\n\nSageMaker Studio runs notebooks and terminals in separate apps, so a common workflow\nis to export a dashboard config to disk and run it from the JupyterServer terminal.\nWhen running inside Studio, `explainerdashboard` can auto-detect SageMaker and apply\nthe correct proxy prefixes, or you can set them explicitly.\n\nNotebook example (export dashboard to disk):\n\n```python\ndb = ExplainerDashboard(\n    explainer,\n    mode=\"dash\",\n    port=8051,\n    sagemaker=True,\n)\ndb.to_yaml(\"dashboard.yaml\", explainerfile=\"dashboard.joblib\", dump_explainer=True)\n```\n\nTerminal example (run from the JupyterServer app):\n\n```bash\nexplainerdashboard run dashboard.yaml --sagemaker --port 8051 --no-browser\n```\n\nAccess the dashboard via the Studio proxy URL:\n\n```text\n\u003CSTUDIO_URL>\u002Fjupyter\u002Fdefault\u002Fproxy\u002F8051\u002F\n```\n\nIf your Studio proxy path differs, you can override the prefixes:\n\n```bash\nexplainerdashboard run dashboard.yaml \\\n  --routes-pathname-prefix=\"\u002F\" \\\n  --requests-pathname-prefix=\"\u002Fjupyter\u002Fdefault\u002Fproxy\u002F8051\u002F\"\n```\n\nAuto-detection uses the presence of `\u002Fopt\u002Fml\u002Fmetadata\u002Fresource-metadata.json`.\n\n## Demonstration:\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_5f117b8bf51a.gif](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_5f117b8bf51a.gif)\n\n\u003C!-- [![Dashboard Screenshot](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_59bfebb0ffdc.png)](https:\u002F\u002Fpostimg.cc\u002FPCj9mWd7) -->\n(for live demonstration see [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev) or [Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic))\n## Background\n\nIn a lot of organizations, especially governmental, but with the GDPR also increasingly in private sector, it is becoming more and more important to be able to explain the inner workings of your machine learning algorithms. Customers have to some extent a right to an explanation why they received a certain prediction, and more and more internal and external regulators require it. With recent innovations in explainable AI (e.g. SHAP values) the old black box trope is no longer valid, but it can still take quite a bit of data wrangling and plot manipulation to get the explanations out of a model. This library aims to make this easy.\n\nThe goal is manyfold:\n- Make it easy for data scientists to quickly inspect the workings and performance of their model in a few lines of code\n- Make it possible for non data scientist stakeholders such as managers, directors, internal and external watchdogs to interactively inspect the inner workings of the model without having to depend on a data scientist to generate every plot and table\n- Make it easy to build an application that explains individual predictions of your model for customers that ask for an explanation\n- Explain the inner workings of the model to the people working (human-in-the-loop) with it so that they gain understanding what the model does and doesn't do. This is important so that they can gain an intuition for when the model is likely missing information and may have to be overruled.\n\n\nThe library includes:\n- *Shap values* (i.e. what is the contributions of each feature to each individual prediction?)\n- *Permutation importances* (how much does the model metric deteriorate when you shuffle a feature?)\n- *Partial dependence plots* (how does the model prediction change when you vary a single feature?\n- *Shap interaction values* (decompose the shap value into a direct effect an interaction effects)\n- For Random Forest, XGBoost, and LightGBM models: visualisation of individual decision trees\n- Plus for classifiers: precision plots, confusion matrix, ROC AUC plot, PR AUC plot, etc\n- For regression models: goodness-of-fit plots, residual plots, etc.\n\nThe library is designed to be modular so that it should be easy to design your own interactive dashboards with plotly dash, with most of the work of calculating and formatting data, and rendering plots and tables handled by `explainerdashboard`, so that you can focus on the layout\nand project specific textual explanations. (i.e. design it so that it will be interpretable for business users in your organization, not just data scientists)\n\nAlternatively, there is a built-in standard dashboard with pre-built tabs (that you can switch off individually)\n\n## Examples of use\n\nFitting a model, building the explainer object, building the dashboard, and then running it can be as simple as:\n\n```python\nExplainerDashboard(ClassifierExplainer(RandomForestClassifier().fit(X_train, y_train), X_test, y_test)).run()\n```\n\nBelow a multi-line example, adding a few extra parameters.\nYou can group onehot encoded categorical variables together using the `cats`\nparameter. You can either pass a dict specifying a list of onehot cols per\ncategorical feature, or if you encode using e.g.\n`pd.get_dummies(df.Name, prefix=['Name'])` (resulting in column names `'Name_Adam', 'Name_Bob'`)\nyou can simply pass the prefix `'Name'`:\n\n```python\nfrom sklearn.ensemble import RandomForestClassifier\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\nfrom explainerdashboard.datasets import titanic_survive, titanic_names\n\nfeature_descriptions = {\n    \"Sex\": \"Gender of passenger\",\n    \"Gender\": \"Gender of passenger\",\n    \"Deck\": \"The deck the passenger had their cabin on\",\n    \"PassengerClass\": \"The class of the ticket: 1st, 2nd or 3rd class\",\n    \"Fare\": \"The amount of money people paid\",\n    \"Embarked\": \"the port where the passenger boarded the Titanic. Either Southampton, Cherbourg or Queenstown\",\n    \"Age\": \"Age of the passenger\",\n    \"No_of_siblings_plus_spouses_on_board\": \"The sum of the number of siblings plus the number of spouses on board\",\n    \"No_of_parents_plus_children_on_board\" : \"The sum of the number of parents plus the number of children on board\",\n}\n\nX_train, y_train, X_test, y_test = titanic_survive()\ntrain_names, test_names = titanic_names()\nmodel = RandomForestClassifier(n_estimators=50, max_depth=5)\nmodel.fit(X_train, y_train)\n\nexplainer = ClassifierExplainer(model, X_test, y_test,\n                                cats=['Deck', 'Embarked',\n                                    {'Gender': ['Sex_male', 'Sex_female', 'Sex_nan']}],\n                                cats_notencoded={'Embarked': 'Stowaway'}, # defaults to 'NOT_ENCODED'\n                                descriptions=feature_descriptions, # adds a table and hover labels to dashboard\n                                labels=['Not survived', 'Survived'], # defaults to ['0', '1', etc]\n                                idxs = test_names, # defaults to X.index\n                                index_name = \"Passenger\", # defaults to X.index.name\n                                target = \"Survival\", # defaults to y.name\n                                )\n\ndb = ExplainerDashboard(explainer,\n                        title=\"Titanic Explainer\", # defaults to \"Model Explainer\"\n                        shap_interaction=False, # you can switch off tabs with bools\n                        )\ndb.run(port=8050)\n```\n\nIf you are passing an sklearn\u002Fimblearn `Pipeline`, you can also clean up transformed\nfeature names and let the explainer infer onehot groups automatically:\n\n```python\nexplainer = ClassifierExplainer(\n    pipeline_model, X_test, y_test,\n    strip_pipeline_prefix=True,      # e.g. \"num__Age\" -> \"Age\"\n    feature_name_fn=None,            # optional custom rename function\n    auto_detect_pipeline_cats=True,  # infer cats from transformed pipeline output\n)\n```\n\nFor a regression model you can also pass the units of the target variable (e.g.\ndollars):\n\n```python\nX_train, y_train, X_test, y_test = titanic_fare()\nmodel = RandomForestRegressor().fit(X_train, y_train)\n\nexplainer = RegressionExplainer(model, X_test, y_test,\n                                cats=['Deck', 'Embarked', 'Sex'],\n                                descriptions=feature_descriptions,\n                                units = \"$\", # defaults to \"\"\n                                )\n\nExplainerDashboard(explainer).run()\n```\n\nFor pipeline-based models with post-processing\u002Fscaling, grouped categorical\nfeatures passed through `cats` are now accepted as long as encoded columns are\nbinary-like (not strictly only `0\u002F1`).\n\n`y_test` is actually optional, although some parts of the dashboard like performance\nmetrics will obviously not be available: `ExplainerDashboard(ClassifierExplainer(model, X_test)).run()`.\n\nYou can export a dashboard to static html with `db.save_html('dashboard.html')`.\n\n\n\u003Cdetails>\n\u003Csummary>You can pass a specific index for the static dashboard to display\u003C\u002Fsummary>\n\u003Cp>\n\n```\nExplainerDashboard(explainer, index=0).save_html('dashboard.html')\n```\n\nor\n\n\n```\nExplainerDashboard(explainer, index='Cumings, Mrs. John Bradley (Florence Briggs Thayer)').save_html('dashboard.html')\n```\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\nFor a simplified single page dashboard try `ExplainerDashboard(explainer, simple=True)`.\n\n\u003Cdetails>\u003Csummary>Show simplified dashboard screenshot\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_bbb75653b800.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_bbb75653b800.png)\n\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n### ExplainerHub\n\nYou can combine multiple dashboards and host them in a single place using\n[ExplainerHub](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html):\n\n```python\ndb1 = ExplainerDashboard(explainer1, title=\"Classifier Explainer\",\n         description=\"Model predicting survival on H.M.S. Titanic\")\ndb2 = ExplainerDashboard(explainer2, title=\"Regression Explainer\",\n         description=\"Model predicting ticket price on H.M.S. Titanic\")\nhub = ExplainerHub([db1, db2])\nhub.run()\n```\n\nYou can adjust titles and descriptions, manage users and logins, store and load\nfrom config, manage the hub through a CLI and more. See the\n[ExplainerHub documentation](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html).\n\n\u003Cdetails>\u003Csummary>Show ExplainerHub screenshot\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_9f6f60425514.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_9f6f60425514.png)\n\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n\n### Dealing with slow calculations\n\nSome of the calculations for the dashboard such as calculating SHAP (interaction) values\nand permutation importances can be slow for large datasets and complicated models.\nThere are a few tricks to make this less painful:\n\n1. Switching off the interactions tab (`shap_interaction=False`) and disabling\n    permutation importances (`no_permutations=True`). Especially SHAP interaction\n    values can be very slow to calculate, and often are not needed for analysis.\n    For permutation importances you can set the `n_jobs` parameter to speed up\n    the calculation in parallel.\n2. Calculate approximate shap values. You can pass approximate=True as a shap parameter by\n   passing `shap_kwargs=dict(approximate=True)` to the explainer initialization.\n3. Use GPU Tree SHAP by passing `shap='gputree'` when your model supports it.\n   This requires an NVIDIA GPU and a CUDA-enabled SHAP build (see the SHAP docs).\n4. Storing the explainer. The calculated properties are only calculated once\n    for each instance, however each time when you instantiate a new explainer\n    instance they will have to be recalculated. You can store them with\n    `explainer.dump(\"explainer.joblib\")` and load with e.g.\n    `ClassifierExplainer.from_file(\"explainer.joblib\")`. All calculated properties\n    are stored along with the explainer.\n5. Using a smaller (test) dataset, or using smaller decision trees.\n    TreeShap computational complexity is `O(TLD^2)`, where `T` is the\n    number of trees, `L` is the maximum number of leaves in any tree and\n    `D` the maximal depth of any tree. So reducing the number of leaves or average\n    depth in the decision tree can really speed up SHAP calculations.\n6. Pre-computing shap values. Perhaps you already have calculated the shap values\n    somewhere, or you can calculate them off on a giant cluster somewhere, or\n    your model supports [GPU generated shap values](https:\u002F\u002Fgithub.com\u002Frapidsai\u002Fgputreeshap).\n    You can simply add these pre-calculated shap values to the explainer\n    with `explainer.set_shap_values()` and `explainer.set_shap_interaction_values()` methods.\n7. Plotting only a random sample of points. When you have a lots of observations,\n    simply rendering the plots may get slow as well. You can pass the `plot_sample`\n    parameter to render a (different each time) random sample of observations\n    for the various scatter plots in the dashboard. E.g.:\n    `ExplainerDashboard(explainer, plot_sample=1000).run()`\n\n## Launching from within a notebook\n\nWhen working inside Jupyter or Google Colab you can use\n`ExplainerDashboard(mode='inline')`, `ExplainerDashboard(mode='external')` or\n`ExplainerDashboard(mode='jupyterlab')`, to run the dashboard inline in the notebook,\nor in a seperate tab but keep the notebook interactive. (`db.run(mode='inline')`\nnow also works)\n\nThere is also a specific interface for quickly displaying interactive components\ninline in your notebook: `InlineExplainer()`. For example you can use\n`InlineExplainer(explainer).shap.dependence()` to display the shap dependence\ncomponent interactively in your notebook output cell.\n\n## Command line tool\n\nYou can store explainers to disk with `explainer.dump(\"explainer.joblib\")`\nand then run them from the command-line:\n\n```bash\n$ explainerdashboard run explainer.joblib\n```\n\nOr store the full configuration of a dashboard to `.yaml` with e.g.\n`dashboard.to_yaml(\"dashboard.yaml\", explainerfile=\"explainer.joblib\", dump_explainer=True)` and run it with:\n\n```bash\n$ explainerdashboard run dashboard.yaml\n```\n\nYou can also build explainers from the commandline with `explainerdashboard build`.\nSee [explainerdashboard CLI documentation](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcli.html)\nfor details.\n\n## Customizing your dashboard\n\nThe dashboard is highly modular and customizable so that you can adjust it your\nown needs and project.\n\n### Changing bootstrap theme\n\nYou can change the bootstrap theme by passing a link to the appropriate css\nfile. You can use the convenient [themes](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fthemes\u002F) module of\n[dash_bootstrap_components](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002F) to generate\nthe css url for you:\n\n```python\nimport dash_bootstrap_components as dbc\n\nExplainerDashboard(explainer, bootstrap=dbc.themes.FLATLY).run()\n```\n\nSee the [dbc themes documentation](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fthemes\u002F)\nand [bootwatch website](https:\u002F\u002Fbootswatch.com\u002F) for the different themes that are supported.\n\n### Switching off tabs\n\nYou can switch off individual tabs using boolean flags. This also makes sure\nthat expensive calculations for that tab don't get executed:\n\n```python\nExplainerDashboard(explainer,\n                    importances=False,\n                    model_summary=True,\n                    contributions=True,\n                    whatif=True,\n                    shap_dependence=True,\n                    shap_interaction=False,\n                    decision_trees=True)\n```\n\n### Hiding components\n\nYou can also hide individual components on the various tabs:\n\n```python\n    ExplainerDashboard(explainer,\n        # importances tab:\n        hide_importances=True,\n        # classification stats tab:\n        hide_globalcutoff=True, hide_modelsummary=True,\n        hide_confusionmatrix=True, hide_precision=True,\n        hide_classification=True, hide_rocauc=True,\n        hide_prauc=True, hide_liftcurve=True, hide_cumprecision=True,\n        # regression stats tab:\n        # hide_modelsummary=True,\n        hide_predsvsactual=True, hide_residuals=True,\n        hide_regvscol=True,\n        # individual predictions tab:\n        hide_predindexselector=True, hide_predictionsummary=True,\n        hide_contributiongraph=True, hide_pdp=True,\n        hide_contributiontable=True,\n        # whatif tab:\n        hide_whatifindexselector=True, hide_whatifprediction=True,\n        hide_inputeditor=True, hide_whatifcontributiongraph=True,\n        hide_whatifcontributiontable=True, hide_whatifpdp=True,\n        # shap dependence tab:\n        hide_shapsummary=True, hide_shapdependence=True,\n        # shap interactions tab:\n        hide_interactionsummary=True, hide_interactiondependence=True,\n        # decisiontrees tab:\n        hide_treeindexselector=True, hide_treesgraph=True,\n        hide_treepathtable=True, hide_treepathgraph=True,\n        ).run()\n```\n\n### Hiding toggles and dropdowns inside components\n\nYou can also hide individual toggles and dropdowns using `**kwargs`. However they\nare not individually targeted, so if you pass `hide_cats=True` then the group\ncats toggle will be hidden on every component that has one:\n\n```python\nExplainerDashboard(explainer,\n                    no_permutations=True, # do not show or calculate permutation importances\n                    hide_poweredby=True, # hide the poweredby:explainerdashboard footer\n                    hide_popout=True, # hide the 'popout' button from each graph\n                    hide_depth=True, # hide the depth (no of features) dropdown\n                    hide_sort=True, # hide sort type dropdown in contributions graph\u002Ftable\n                    hide_orientation=True, # hide orientation dropdown in contributions graph\u002Ftable\n                    hide_type=True, # hide shap\u002Fpermutation toggle on ImportancesComponent\n                    hide_dropna=True, # hide dropna toggle on pdp component\n                    hide_sample=True, # hide sample size input on pdp component\n                    hide_gridlines=True, # hide gridlines on pdp component\n                    hide_gridpoints=True, # hide gridpoints input on pdp component\n                    hide_cats_sort=True, # hide the sorting option for categorical features\n                    hide_cutoff=True, # hide cutoff selector on classification components\n                    hide_percentage=True, # hide percentage toggle on classificaiton components\n                    hide_log_x=True, # hide x-axis logs toggle on regression plots\n                    hide_log_y=True, # hide y-axis logs toggle on regression plots\n                    hide_ratio=True, # hide the residuals type dropdown\n                    hide_points=True, # hide the show violin scatter markers toggle\n                    hide_winsor=True, # hide the winsorize input\n                    hide_wizard=True, # hide the wizard toggle in lift curve component\n                    hide_range=True, # hide the range subscript on feature input\n                    hide_star_explanation=True, # hide the '* indicates observed label` text\n)\n```\n\n### Setting default values\n\nYou can also set default values for the various dropdowns and toggles.\nAll the components with their parameters can be found [in the documentation](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcomponents.html).\nSome examples of useful parameters to pass:\n\n```python\nExplainerDashboard(explainer,\n                    higher_is_better=False, # flip green and red in contributions graph\n                    n_input_cols=3, # divide feature inputs into 3 columns on what if tab\n                    input_features=['Sex', 'Deck', 'PassengerClass', 'Fare', 'Age'], # show these what-if inputs in this order\n                    hide_features=['Fare'], # hide specific what-if inputs\n                    col='Fare', # initial feature in shap graphs\n                    color_col='Age', # color feature in shap dependence graph\n                    interact_col='Age', # interaction feature in shap interaction\n                    depth=5, # only show top 5 features\n                    sort = 'low-to-high', # sort features from lowest shap to highest in contributions graph\u002Ftable\n                    cats_topx=3, # show only the top 3 categories for categorical features\n                    cats_sort='alphabet', # short categorical features alphabetically\n                    orientation='horizontal', # horizontal bars in contributions graph\n                    index='Rugg, Miss. Emily', # initial index to display\n                    pdp_col='Fare', # initial pdp feature\n                    cutoff=0.8, # cutoff for classification plots\n                    round=2 # rounding to apply to floats\n                    show_metrics=['accuracy', 'f1', custom_metric] # only show certain metrics\n                    plot_sample=1000, # only display a 1000 random markers in scatter plots\n                    )\n```\n\n\n### Designing your own layout\n\nAll the components in the dashboard are modular and re-usable, which means that\nyou can build your own custom [dash](https:\u002F\u002Fdash.plotly.com\u002F) dashboards\naround them.\n\nBy using the built-in `ExplainerComponent` class it is easy to build your\nown layouts, with just a bare minimum of knowledge of HTML and [bootstrap](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fquickstart\u002F). For\nexample if you only wanted to display the `ConfusionMatrixComponent` and\n`ShapContributionsGraphComponent`, but hide\na few toggles:\n\n```python\nfrom explainerdashboard.custom import *\n\nclass CustomDashboard(ExplainerComponent):\n    def __init__(self, explainer, name=None):\n        super().__init__(explainer, title=\"Custom Dashboard\")\n        self.confusion = ConfusionMatrixComponent(explainer, name=self.name+\"cm\",\n                            hide_selector=True, hide_percentage=True,\n                            cutoff=0.75)\n        self.contrib = ShapContributionsGraphComponent(explainer, name=self.name+\"contrib\",\n                            hide_selector=True, hide_cats=True,\n                            hide_depth=True, hide_sort=True,\n                            index='Rugg, Miss. Emily')\n\n    def layout(self):\n        return dbc.Container([\n            dbc.Row([\n                dbc.Col([\n                    html.H1(\"Custom Demonstration:\"),\n                    html.H3(\"How to build your own layout using ExplainerComponents.\")\n                ])\n            ]),\n            dbc.Row([\n                dbc.Col([\n                    self.confusion.layout(),\n                ]),\n                dbc.Col([\n                    self.contrib.layout(),\n                ])\n            ])\n        ])\n\ndb = ExplainerDashboard(explainer, CustomDashboard, hide_header=True).run()\n```\n\n\u003Cdetails>\u003Csummary>Show example custom dashboard screenshot\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_3639d3fcc505.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_3639d3fcc505.png)\n\n\u003C\u002Fp>\n\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n\nYou can use this to define your own layouts, specifically tailored to your\nown model, project and needs. You can use the [ExplainerComposites](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fblob\u002Fmaster\u002Fexplainerdashboard\u002Fdashboard_components\u002Fcomposites.py) that\nare used for the tabs of the default dashboard as a starting point, and edit\nthem to reorganize components, add text, etc.\nSee [custom dashboard documentation](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcustom.html)\nfor more details. A deployed custom dashboard can be found on [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev\u002Fcustom\u002F)([source code](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic\u002Fblob\u002Fmaster\u002Fbuildcustom.py)).\n\n## Deployment\n\nIf you wish to use e.g. `gunicorn` or `waitress` to deploy the dashboard you should add\n`app = db.flask_server()` to your code to expose the Flask server. You can then\nstart the server with e.g. `gunicorn dashboard:app`\n(assuming the file you defined the dashboard in was called `dashboard.py`).\nSee also the [ExplainerDashboard section](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdashboards.html)\nand the [deployment section of the documentation](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html).\nFor platform-specific guides, see:\n[Deploying to Fly.io](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-fly-io)\nand\n[Deploying to Hugging Face Spaces](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-hugging-face-spaces).\nand\n[Deploying to Azure Web Apps](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-azure-web-apps),\n[Deploying behind reverse proxies and path prefixes](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-behind-reverse-proxies-and-path-prefixes),\n[Deploying to Google Cloud Run](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-google-cloud-run),\n[Deploying to Kubernetes (Ingress)](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-kubernetes-ingress),\n[Deploying in Databricks notebooks](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-in-databricks-notebooks),\nand\n[Deploying in Kaggle notebooks](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-in-kaggle-notebooks).\n\nFor a concise production pattern, expose a single WSGI app and run with `gunicorn`:\n`app = db.flask_server()` and `gunicorn --bind=0.0.0.0:${PORT:-8000} dashboard:app`.\nIf your deployment runs behind a proxy\u002Fpath prefix and you see `Loading...`, check\nthe deployment docs above and align `url_base_pathname`, `routes_pathname_prefix`,\nand `requests_pathname_prefix`.\n\nIt can be helpful to store your `explainer` and dashboard layout to disk, and\nthen reload, e.g.:\n\n**generate_dashboard.py**:\n```python\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\nfrom explainerdashboard.custom import *\n\nexplainer = ClassifierExplainer(model, X_test, y_test)\n\n# building an ExplainerDashboard ensures that all necessary properties\n# get calculated:\ndb = ExplainerDashboard(explainer, [ShapDependenceComposite, WhatIfComposite],\n                        title='Awesome Dashboard', hide_whatifpdp=True)\n\n# store both the explainer and the dashboard configuration:\ndb.to_yaml(\"dashboard.yaml\", explainerfile=\"explainer.joblib\", dump_explainer=True)\n```\n\nYou can then reload it in **dashboard.py**:\n```python\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\n\n# you can override params during load from_config:\ndb = ExplainerDashboard.from_config(\"dashboard.yaml\", title=\"Awesomer Title\")\n\napp = db.flask_server()\n```\n\nAnd then run it with:\n\n```sh\n    $ gunicorn dashboard:app\n```\n\nor with waitress (also works on Windows):\n\n```sh\n    $ waitress-serve dashboard:app\n```\n\n### Minimizing memory usage\n\nWhen you deploy a dashboard with a dataset with a large number of rows (`n`) and columns (`m`),\nthe memory usage of the dashboard can be substantial. You can check the (approximate)\nmemory usage with `explainer.memory_usage()`. (as a side note: if you have lots\nof rows, you probably want to set the `plot_sample` parameter as well)\n\nIn order to reduce the memory footprint there are a number of things you can do:\n\n1. Not including shap interaction tab: shap interaction values are shape (`n*m*m`),\n    so can take a subtantial amount of memory.\n2. Setting a lower precision. By default shap values are stored as `'float64'`,\n    but you can store them as `'float32'` instead and save half the space:\n    ```ClassifierExplainer(model, X_test, y_test, precision='float32')```. You\n    can also set a lower precision on your `X_test` dataset yourself of course.\n3. For multi class classifier, by default `ClassifierExplainer` calculates\n    shap values for all classes. If you're only interested in a single class\n    you can drop the other shap values: `explainer.keep_shap_pos_label_only(pos_label)`\n4. Storing data externally. You can for example only store a subset of 10.000 rows in\n    the explainer itself (enough to generate importance and dependence plots),\n    and store the rest of your millions of rows of input data in an external file\n    or database:\n    - with `explainer.set_X_row_func()` you can set a function that takes\n        an `index` as argument and returns a single row dataframe with model\n        compatible input data for that index. This function can include a query\n        to a database or fileread.\n    - with `explainer.set_y_func()` you can set a function that takes\n        and `index` as argument and returns the observed outcome `y` for\n        that index.\n    - with `explainer.set_index_list_func()` you can set a function\n        that returns a list of available indexes that can be queried. Only gets\n        called upon start of the dashboard.\n\n    If you have a very large number of indexes and the user is able to look\n    them up elsewhere, you can also replace the index dropdowns with a simple free\n    text field with `index_dropdown=False`. Only valid indexes (i.e. in the\n    `get_index_list()` list) get propagated\n    to other components by default, but this can be overriden with `index_check=False`.\n    Instead of an ``index_list_func`` you can also set an\n    ``explainer.set_index_check_func(func)`` which should return a bool whether\n    the ``index`` exists or not.\n\n    Important: these function can be called multiple times by multiple independent\n    components, so probably best to implement some kind of caching functionality.\n    The functions you pass can be also methods, so you have access to all of the\n    internals of the explainer.\n\n\n## Documentation\n\nDocumentation can be found at [explainerdashboard.readthedocs.io](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002F).\n\nExample notebook on how to launch dashboards for different model types here: [dashboard_examples.ipynb](notebooks\u002Fdashboard_examples.ipynb).\n\nExample notebook on how to interact with the explainer object here: [explainer_examples.ipynb](notebooks\u002Fexplainer_examples.ipynb).\n\nExample notebook on how to design a custom dashboard: [custom_examples.ipynb](notebooks\u002Fcustom_examples.ipynb).\n\n\n\n## Deployed example:\n\nYou can find example dashboards at [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev) and [Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic)\n\n(source code at [https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic))\n\n## Citation:\n\nA doi can be found at [zenodo](https:\u002F\u002Fzenodo.org\u002Frecord\u002F7633294)\n","![GitHub 工作流状态（带事件）](https:\u002F\u002Fimg.shields.io\u002Fgithub\u002Factions\u002Fworkflow\u002Fstatus\u002Foegedijk\u002Fexplainerdashboard\u002Fexplainerdashboard.yml)\n![https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fexplainerdashboard\u002F](https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fexplainerdashboard.svg)\n![https:\u002F\u002Fanaconda.org\u002Fconda-forge\u002Fexplainerdashboard\u002F](https:\u002F\u002Fanaconda.org\u002Fconda-forge\u002Fexplainerdashboard\u002Fbadges\u002Fversion.svg)\n[![codecov](https:\u002F\u002Fcodecov.io\u002Fgh\u002Foegedijk\u002Fexplainerdashboard\u002Fbranch\u002Fmaster\u002Fgraph\u002Fbadge.svg?token=0XU6HNEGBK)](undefined)\n[![下载量](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_150dfe653354.png)](https:\u002F\u002Fpepy.tech\u002Fproject\u002Fexplainerdashboard)\n\n# explainerdashboard\n作者：Oege Dijk\n\n此软件包方便快速部署一个用于解释机器学习模型（兼容 scikit-learn）工作原理的仪表板 Web 应用程序。该仪表板提供关于模型性能、特征重要性、特征对单个预测的贡献、假设情景分析、部分依赖图、SHAP（交互）值、单个决策树可视化等的交互式图表。\n\n您还可以在笔记本或 Colab 环境中交互式地探索仪表板的各个组件，或者直接从这些环境中启动仪表板。借助库的模块化设计，您还可以使用自己的[自定义布局](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fbuildcustom.html)和说明来设计仪表板，并将多个仪表板组合成一个[ExplainerHub](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html)。\n\n仪表板可以直接从正在运行的仪表板导出为静态 HTML，也可以作为自动化 CI\u002FCD 部署流程的一部分以程序化方式生成为工件。\n\n示例已部署于：[Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev)、[Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic)，详细文档请参见 [explainerdashboard.readthedocs.io](http:\u002F\u002Fexplainerdashboard.readthedocs.io)，有关如何为不同模型启动仪表板的示例笔记本请见[notebooks\u002Fdashboard_examples.ipynb]，而有关如何与解释器对象交互的示例笔记本则请见[notebooks\u002Fexplainer_examples.ipynb]。\n\n它支持 `scikit-learn`、`xgboost`、`catboost`、`lightgbm` 和 `skorch`（用于表格型 PyTorch 模型的 sklearn 封装）等框架。\n\n## 安装\n\n您可以通过 pip 安装该软件包：\n\n`pip install explainerdashboard`\n\n或者通过 conda-forge：\n\n`conda install -c conda-forge explainerdashboard`\n\n## SageMaker Studio\n\nSageMaker Studio 在独立的应用程序中运行笔记本和终端，因此常见的工作流程是将仪表板配置导出到磁盘，然后从 JupyterServer 终端运行它。当在 Studio 中运行时，`explainerdashboard` 可以自动检测 SageMaker 并应用正确的代理前缀，或者您可以显式设置它们。\n\n笔记本示例（将仪表板导出到磁盘）：\n\n```python\ndb = ExplainerDashboard(\n    explainer,\n    mode=\"dash\",\n    port=8051,\n    sagemaker=True,\n)\ndb.to_yaml(\"dashboard.yaml\", explainerfile=\"dashboard.joblib\", dump_explainer=True)\n```\n\n终端示例（从 JupyterServer 应用程序运行）：\n\n```bash\nexplainerdashboard run dashboard.yaml --sagemaker --port 8051 --no-browser\n```\n\n通过 Studio 代理 URL 访问仪表板：\n\n```text\n\u003CSTUDIO_URL>\u002Fjupyter\u002Fdefault\u002Fproxy\u002F8051\u002F\n```\n\n如果您的 Studio 代理路径不同，可以覆盖前缀：\n\n```bash\nexplainerdashboard run dashboard.yaml \\\n  --routes-pathname-prefix=\"\u002F\" \\\n  --requests-pathname-prefix=\"\u002Fjupyter\u002Fdefault\u002Fproxy\u002F8051\u002F\"\n```\n\n自动检测会检查 `\u002Fopt\u002Fml\u002Fmetadata\u002Fresource-metadata.json` 文件是否存在。\n\n## 演示：\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_5f117b8bf51a.gif](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_5f117b8bf51a.gif)\n\n\u003C!-- [![仪表板截图](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_59bfebb0ffdc.png)](https:\u002F\u002Fpostimg.cc\u002FPCj9mWd7) -->\n（如需实时演示，请访问 [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev) 或 [Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic)）\n\n## 背景\n\n在许多组织中，尤其是政府机构，但随着 GDPR 的实施，在私营部门也越来越重要的是能够解释机器学习算法的内部运作机制。客户在一定程度上有权了解为何会收到某一特定预测结果，而越来越多的内部和外部监管机构也要求提供解释。随着可解释 AI 方面的最新进展（例如 SHAP 值），传统的“黑箱”说法已不再适用，但要从模型中提取解释仍然需要大量的数据处理和图表制作工作。本库旨在简化这一过程。\n\n其目标是多方面的：\n- 使数据科学家能够在几行代码内快速检查其模型的工作原理和性能；\n- 使非数据科学领域的利益相关者，如管理者、董事以及内部和外部监督机构，能够在无需依赖数据科学家生成每一张图表和表格的情况下，交互式地检查模型的内部运作；\n- 便于构建一款应用程序，为要求解释的客户提供对其模型个体预测的解释；\n- 向与模型协同工作的人员（人机协作）解释模型的内部运作，使他们理解模型能做什么、不能做什么。这一点很重要，因为它可以帮助他们判断何时模型可能缺乏信息而需要人工干预。\n\n该库包含：\n- *SHAP 值*（即每个特征对每个个体预测的贡献是多少？）\n- *排列重要性*（当您随机打乱某个特征时，模型指标会恶化多少？）\n- *部分依赖图*（当您改变单个特征时，模型预测会发生怎样的变化？）\n- *SHAP 交互值*（将 SHAP 值分解为直接效应和交互效应）\n- 对于随机森林、XGBoost 和 LightGBM 模型：单个决策树的可视化\n- 对于分类模型：精确度曲线、混淆矩阵、ROC AUC 曲线、PR AUC 曲线等\n- 对于回归模型：拟合优度图、残差图等。\n\n该库的设计具有模块化特性，因此应该很容易使用 Plotly Dash 构建您自己的交互式仪表板，其中大部分数据计算、格式化以及图表和表格的渲染工作都由 `explainerdashboard` 处理，从而使您可以专注于布局和项目特定的文字说明。（即设计使其不仅对数据科学家，而且对贵组织的业务用户也易于理解）\n\n此外，还提供了一个内置的标准仪表板，带有预建的选项卡（您可以单独关闭它们）。\n\n## 使用示例\n\n拟合模型、构建解释器对象、搭建仪表板并运行它，可以简单地如下所示：\n\n```python\nExplainerDashboard(ClassifierExplainer(RandomForestClassifier().fit(X_train, y_train), X_test, y_test)).run()\n```\n\n下面是一个多行示例，添加了一些额外的参数。\n你可以使用 `cats` 参数将独热编码的分类变量分组在一起。你可以传递一个字典，指定每个分类特征对应的独热列列表；或者如果你使用例如 `pd.get_dummies(df.Name, prefix=['Name'])` 进行编码（生成列名 `'Name_Adam', 'Name_Bob'`），则可以直接传递前缀 `'Name'`：\n\n```python\nfrom sklearn.ensemble import RandomForestClassifier\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\nfrom explainerdashboard.datasets import titanic_survive, titanic_names\n\nfeature_descriptions = {\n    \"Sex\": \"乘客性别\",\n    \"Gender\": \"乘客性别\",\n    \"Deck\": \"乘客所处的甲板\",\n    \"PassengerClass\": \"船票等级：1等、2等或3等\",\n    \"Fare\": \"乘客支付的票价\",\n    \"Embarked\": \"乘客登船的港口，可能是南安普敦、瑟堡或昆士敦\",\n    \"Age\": \"乘客年龄\",\n    \"No_of_siblings_plus_spouses_on_board\": \"船上兄弟姐妹与配偶人数之和\",\n    \"No_of_parents_plus_children_on_board\" : \"船上父母与子女人数之和\",\n}\n\nX_train, y_train, X_test, y_test = titanic_survive()\ntrain_names, test_names = titanic_names()\nmodel = RandomForestClassifier(n_estimators=50, max_depth=5)\nmodel.fit(X_train, y_train)\n\nexplainer = ClassifierExplainer(model, X_test, y_test,\n                                cats=['Deck', 'Embarked',\n                                    {'Gender': ['Sex_male', 'Sex_female', 'Sex_nan']}],\n                                cats_notencoded={'Embarked': 'Stowaway'}, # 默认为 'NOT_ENCODED'\n                                descriptions=feature_descriptions, # 为仪表板添加表格和悬停标签\n                                labels=['未幸存', '幸存'], # 默认为 ['0', '1', 等]\n                                idxs = test_names, # 默认为 X.index\n                                index_name = \"乘客\", # 默认为 X.index.name\n                                target = \"生存\", # 默认为 y.name\n                                )\n\ndb = ExplainerDashboard(explainer,\n                        title=\"泰坦尼克号解释器\", # 默认为 \"模型解释器\"\n                        shap_interaction=False, # 可以通过布尔值关闭选项卡\n                        )\ndb.run(port=8050)\n```\n\n如果你传递的是 sklearn 或 imblearn 的 `Pipeline`，你还可以清理转换后的特征名称，并让解释器自动推断独热编码组：\n\n```python\nexplainer = ClassifierExplainer(\n    pipeline_model, X_test, y_test,\n    strip_pipeline_prefix=True,      # 例如 \"num__Age\" -> \"Age\"\n    feature_name_fn=None,            # 可选的自定义重命名函数\n    auto_detect_pipeline_cats=True,  # 从转换后的管道输出中推断分类变量\n)\n```\n\n对于回归模型，你还可以传递目标变量的单位（例如美元）：\n\n```python\nX_train, y_train, X_test, y_test = titanic_fare()\nmodel = RandomForestRegressor().fit(X_train, y_train)\n\nexplainer = RegressionExplainer(model, X_test, y_test,\n                                cats=['Deck', 'Embarked', 'Sex'],\n                                descriptions=feature_descriptions,\n                                units = \"$\", # 默认为空字符串\n                                )\n\nExplainerDashboard(explainer).run()\n```\n\n对于带有后处理\u002F缩放的管道模型，只要编码后的列是二值化的（不一定是严格的 `0\u002F1`），现在就可以接受通过 `cats` 传递的分组分类特征。\n\n`y_test` 实际上是可选的，尽管仪表板的某些部分，比如性能指标，显然将不可用：`ExplainerDashboard(ClassifierExplainer(model, X_test)).run()`。\n\n你可以使用 `db.save_html('dashboard.html')` 将仪表板导出为静态 HTML 文件。\n\n\n\u003Cdetails>\n\u003Csummary>你可以为静态仪表板指定要显示的具体索引\u003C\u002Fsummary>\n\u003Cp>\n\n```\nExplainerDashboard(explainer, index=0).save_html('dashboard.html')\n```\n\n或者\n\n\n```\nExplainerDashboard(explainer, index='Cumings, Mrs. John Bradley (Florence Briggs Thayer)').save_html('dashboard.html')\n```\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\n对于简化的单页仪表板，可以尝试 `ExplainerDashboard(explainer, simple=True)`。\n\n\u003Cdetails>\u003Csummary>展示简化版仪表板截图\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_bbb75653b800.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_bbb75653b800.png)\n\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n### ExplainerHub\n\n你可以使用 [ExplainerHub](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html) 将多个仪表板组合起来，并托管在一个地方：\n\n```python\ndb1 = ExplainerDashboard(explainer1, title=\"分类器解释器\",\n         description=\"预测泰坦尼克号上乘客生存情况的模型\")\ndb2 = ExplainerDashboard(explainer2, title=\"回归解释器\",\n         description=\"预测泰坦尼克号船票价格的模型\")\nhub = ExplainerHub([db1, db2])\nhub.run()\n```\n\n你可以调整标题和描述，管理用户和登录，从配置文件中存储和加载数据，通过命令行管理 Hub 等等。更多信息请参阅 [ExplainerHub 文档](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fhub.html)。\n\n\u003Cdetails>\u003Csummary>展示 ExplainerHub 截图\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_9f6f60425514.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_9f6f60425514.png)\n\n\u003C\u002Fp>\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n### 处理计算缓慢的问题\n\n仪表板中的一些计算，例如 SHAP（交互）值和置换重要性的计算，在处理大型数据集或复杂模型时可能会非常缓慢。以下是一些技巧，可以帮助您减少这种不便：\n\n1. 关闭交互性选项卡（`shap_interaction=False`），并禁用置换重要性计算（`no_permutations=True`）。尤其是 SHAP 交互值的计算速度可能非常慢，而且通常在分析中并不需要。对于置换重要性计算，您可以设置 `n_jobs` 参数以并行加速计算。\n2. 计算近似 SHAP 值。您可以在初始化解释器时通过传递 `shap_kwargs=dict(approximate=True)` 来启用近似 SHAP 值的计算。\n3. 如果您的模型支持，可以使用 GPU Tree SHAP，只需在初始化时传入 `shap='gputree'` 即可。这需要 NVIDIA GPU 和支持 CUDA 的 SHAP 构建环境（请参阅 SHAP 文档）。\n4. 存储解释器对象。虽然每个实例的计算结果只会被计算一次，但每次实例化新的解释器时都需要重新计算这些属性。您可以通过 `explainer.dump(\"explainer.joblib\")` 将其保存，并使用 `ClassifierExplainer.from_file(\"explainer.joblib\")` 加载。所有已计算的属性都会与解释器一同存储。\n5. 使用较小的（测试）数据集，或者采用更小的决策树。TreeSHAP 的计算复杂度为 `O(TLD^2)`，其中 `T` 是树的数量，`L` 是任意一棵树的最大叶节点数，`D` 则是任意一棵树的最大深度。因此，减少决策树中的叶节点数量或平均深度可以显著加快 SHAP 计算的速度。\n6. 预先计算 SHAP 值。如果您已经在其他地方计算过 SHAP 值，或者可以在大型集群上进行计算，又或者您的模型支持 [GPU 生成的 SHAP 值](https:\u002F\u002Fgithub.com\u002Frapidsai\u002Fgputreeshap)，那么您可以直接将这些预计算的 SHAP 值通过 `explainer.set_shap_values()` 和 `explainer.set_shap_interaction_values()` 方法添加到解释器中。\n7. 只绘制随机样本点。当观测数量非常多时，渲染图表本身也可能变得很慢。您可以使用 `plot_sample` 参数来为仪表板中的各种散点图绘制一个（每次不同）随机样本。例如：`ExplainerDashboard(explainer, plot_sample=1000).run()`。\n\n## 在笔记本中启动\n\n在 Jupyter 或 Google Colab 中工作时，您可以使用 `ExplainerDashboard(mode='inline')`、`ExplainerDashboard(mode='external')` 或 `ExplainerDashboard(mode='jupyterlab')` 来在笔记本内嵌入式运行仪表板，或者在单独的标签页中运行，同时保持笔记本的交互性。（`db.run(mode='inline')` 现在也适用）\n\n此外，还有一个专门的界面可用于在笔记本中快速显示交互式组件：`InlineExplainer()`。例如，您可以使用 `InlineExplainer(explainer).shap.dependence()` 在笔记本的输出单元格中交互式地显示 SHAP 依赖性组件。\n\n## 命令行工具\n\n您可以使用 `explainer.dump(\"explainer.joblib\")` 将解释器保存到磁盘，然后通过命令行运行：\n\n```bash\n$ explainerdashboard run explainer.joblib\n```\n\n或者将整个仪表板的配置保存为 `.yaml` 文件，例如使用 `dashboard.to_yaml(\"dashboard.yaml\", explainerfile=\"explainer.joblib\", dump_explainer=True)`，然后通过以下命令运行：\n\n```bash\n$ explainerdashboard run dashboard.yaml\n```\n\n您还可以使用 `explainerdashboard build` 命令行工具构建解释器。有关详细信息，请参阅 [explainerdashboard CLI 文档](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcli.html)。\n\n## 自定义您的仪表板\n\n仪表板具有高度模块化和可定制性，因此您可以根据自身需求和项目进行调整。\n\n### 更改 Bootstrap 主题\n\n您可以通过传递相应 CSS 文件的链接来更改 Bootstrap 主题。您可以使用 [dash_bootstrap_components](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002F) 提供的便捷 [themes](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fthemes\u002F) 模块为您生成 CSS URL：\n\n```python\nimport dash_bootstrap_components as dbc\n\nExplainerDashboard(explainer, bootstrap=dbc.themes.FLATLY).run()\n```\n\n有关支持的主题列表，请参阅 [dbc 主题文档](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fthemes\u002F) 和 [bootwatch 网站](https:\u002F\u002Fbootswatch.com\u002F)。\n\n### 关闭选项卡\n\n您可以通过布尔标志关闭单个选项卡。这样做还可以确保不会执行该选项卡所需的昂贵计算：\n\n```python\nExplainerDashboard(explainer,\n                    importances=False,\n                    model_summary=True,\n                    contributions=True,\n                    whatif=True,\n                    shap_dependence=True,\n                    shap_interaction=False,\n                    decision_trees=True)\n```\n\n### 隐藏组件\n\n您还可以在各个选项卡上隐藏单个组件：\n\n```python\n    ExplainerDashboard(explainer,\n        # 重要性选项卡：\n        hide_importances=True,\n        # 分类统计选项卡：\n        hide_globalcutoff=True, hide_modelsummary=True,\n        hide_confusionmatrix=True, hide_precision=True,\n        hide_classification=True, hide_rocauc=True,\n        hide_prauc=True, hide_liftcurve=True, hide_cumprecision=True,\n        # 回归统计选项卡：\n        # hide_modelsummary=True,\n        hide_predsvsactual=True, hide_residuals=True,\n        hide_regvscol=True,\n        # 个体预测选项卡：\n        hide_predindexselector=True, hide_predictionsummary=True,\n        hide_contributiongraph=True, hide_pdp=True,\n        hide_contributiontable=True,\n        # WhatIf 选项卡：\n        hide_whatifindexselector=True, hide_whatifprediction=True,\n        hide_inputeditor=True, hide_whatifcontributiongraph=True,\n        hide_whatifcontributiontable=True, hide_whatifpdp=True,\n        # SHAP 依赖性选项卡：\n        hide_shapsummary=True, hide_shapdependence=True,\n        # SHAP 交互性选项卡：\n        hide_interactionsummary=True, hide_interactiondependence=True,\n        # 决策树选项卡：\n        hide_treeindexselector=True, hide_treesgraph=True,\n        hide_treepathtable=True, hide_treepathgraph=True,\n        ).run()\n```\n\n### 在组件内部隐藏切换按钮和下拉菜单\n\n你还可以使用 `**kwargs` 来隐藏单个切换按钮和下拉菜单。然而，这些选项并不是针对单个组件的，因此如果你传递 `hide_cats=True`，那么所有包含该选项的组件中的分类特征切换按钮都会被隐藏：\n\n```python\nExplainerDashboard(explainer,\n                    no_permutations=True, # 不显示或计算排列重要性\n                    hide_poweredby=True, # 隐藏 poweredby:explainerdashboard 页脚\n                    hide_popout=True, # 隐藏每个图表上的“弹出”按钮\n                    hide_depth=True, # 隐藏深度（特征数量）下拉菜单\n                    hide_sort=True, # 隐藏贡献度图表\u002F表格中的排序类型下拉菜单\n                    hide_orientation=True, # 隐藏贡献度图表\u002F表格中的方向下拉菜单\n                    hide_type=True, # 隐藏重要性组件中的 SHAP\u002F排列切换按钮\n                    hide_dropna=True, # 隐藏 PDP 组件中的 dropna 切换按钮\n                    hide_sample=True, # 隐藏 PDP 组件中的样本大小输入框\n                    hide_gridlines=True, # 隐藏 PDP 组件中的网格线\n                    hide_gridpoints=True, # 隐藏 PDP 组件中的网格点输入框\n                    hide_cats_sort=True, # 隐藏分类特征的排序选项\n                    hide_cutoff=True, # 隐藏分类组件中的阈值选择器\n                    hide_percentage=True, # 隐藏分类组件中的百分比切换按钮\n                    hide_log_x=True, # 隐藏回归图中的 x 轴对数切换按钮\n                    hide_log_y=True, # 隐藏回归图中的 y 轴对数切换按钮\n                    hide_ratio=True, # 隐藏残差类型的下拉菜单\n                    hide_points=True, # 隐藏小提琴图散点标记的显示切换按钮\n                    hide_winsor=True, # 隐藏 Winsorize 输入框\n                    hide_wizard=True, # 隐藏提升曲线组件中的向导切换按钮\n                    hide_range=True, # 隐藏特征输入上的范围下标\n                    hide_star_explanation=True, # 隐藏“* 表示观测标签”的文本\n)\n```\n\n### 设置默认值\n\n你还可以为各种下拉菜单和切换按钮设置默认值。所有组件及其参数都可以在[文档](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcomponents.html)中找到。以下是一些有用的参数示例：\n\n```python\nExplainerDashboard(explainer,\n                    higher_is_better=False, # 反转贡献度图表中的绿色和红色\n                    n_input_cols=3, # 将“如果怎样”选项卡中的特征输入分为 3 列\n                    input_features=['Sex', 'Deck', 'PassengerClass', 'Fare', 'Age'], # 按此顺序显示这些“如果怎样”输入\n                    hide_features=['Fare'], # 隐藏特定的“如果怎样”输入\n                    col='Fare', # SHAP 图表中的初始特征\n                    color_col='Age', # SHAP 依赖关系图中的颜色特征\n                    interact_col='Age', # SHAP 相互作用图中的交互特征\n                    depth=5, # 仅显示前 5 个特征\n                    sort = 'low-to-high', # 在贡献度图表\u002F表格中按 SHAP 值从低到高排序\n                    cats_topx=3, # 仅显示分类特征的前 3 个类别\n                    cats_sort='alphabet', # 按字母顺序对分类特征进行排序\n                    orientation='horizontal', # 贡献度图表中的水平条形图\n                    index='Rugg, Miss. Emily', # 初始显示的索引\n                    pdp_col='Fare', # 初始的 PDP 特征\n                    cutoff=0.8, # 分类图表中的阈值\n                    round=2 # 对浮点数应用的四舍五入位数\n                    show_metrics=['accuracy', 'f1', custom_metric] # 仅显示某些指标\n                    plot_sample=1000, # 仅在散点图中显示 1000 个随机标记\n                    )\n```\n\n\n### 设计自定义布局\n\n仪表板中的所有组件都是模块化的且可重用的，这意味着你可以围绕它们构建自己的自定义 [Dash](https:\u002F\u002Fdash.plotly.com\u002F) 仪表板。\n\n通过使用内置的 `ExplainerComponent` 类，只需具备最基本的 HTML 和 [Bootstrap](https:\u002F\u002Fdash-bootstrap-components.opensource.faculty.ai\u002Fdocs\u002Fquickstart\u002F) 知识，就可以轻松构建自己的布局。例如，如果你只想显示 `ConfusionMatrixComponent` 和 `ShapContributionsGraphComponent`，但要隐藏一些切换按钮：\n\n```python\nfrom explainerdashboard.custom import *\n\nclass CustomDashboard(ExplainerComponent):\n    def __init__(self, explainer, name=None):\n        super().__init__(explainer, title=\"Custom Dashboard\")\n        self.confusion = ConfusionMatrixComponent(explainer, name=self.name+\"cm\",\n                            hide_selector=True, hide_percentage=True,\n                            cutoff=0.75)\n        self.contrib = ShapContributionsGraphComponent(explainer, name=self.name+\"contrib\",\n                            hide_selector=True, hide_cats=True,\n                            hide_depth=True, hide_sort=True,\n                            index='Rugg, Miss. Emily')\n\n    def layout(self):\n        return dbc.Container([\n            dbc.Row([\n                dbc.Col([\n                    html.H1(\"Custom Demonstration:\"),\n                    html.H3(\"如何使用 ExplainerComponents 构建自定义布局。\")\n                ])\n            ]),\n            dbc.Row([\n                dbc.Col([\n                    self.confusion.layout(),\n                ]),\n                dbc.Col([\n                    self.contrib.layout(),\n                ])\n            ])\n        )\n\ndb = ExplainerDashboard(explainer, CustomDashboard, hide_header=True).run()\n```\n\n\u003Cdetails>\u003Csummary>显示自定义仪表板示例截图\u003C\u002Fsummary>\n\u003Cp>\n\n\n![https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_3639d3fcc505.png](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_readme_3639d3fcc505.png)\n\n\u003C\u002Fp>\n\n\u003C\u002Fdetails>\n\u003Cp>\u003C\u002Fp>\n\n\n你可以利用这一点来定义专属于你自己的模型、项目和需求的自定义布局。你可以以默认仪表板选项卡所使用的 [ExplainerComposites](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fblob\u002Fmaster\u002Fexplainerdashboard\u002Fdashboard_components\u002Fcomposites.py) 作为起点，并对其进行编辑以重新组织组件、添加文本等。更多详细信息请参阅[自定义仪表板文档](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fcustom.html)。一个已部署的自定义仪表板可以在 [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev\u002Fcustom\u002F)([源代码](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic\u002Fblob\u002Fmaster\u002Fbuildcustom.py)) 上找到。\n\n## 部署\n\n如果你想使用例如 `gunicorn` 或 `waitress` 来部署仪表板，你应该在代码中添加 `app = db.flask_server()` 来暴露 Flask 服务器。然后你可以通过例如 `gunicorn dashboard:app` 来启动服务器\n（假设你定义仪表板的文件名为 `dashboard.py`）。\n另请参阅 [ExplainerDashboard 章节](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdashboards.html)\n以及文档中的 [部署章节](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html)。\n针对特定平台的指南，请参阅：\n[部署到 Fly.io](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-fly-io)\n和\n[部署到 Hugging Face Spaces](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-hugging-face-spaces)。\n还有\n[部署到 Azure Web 应用](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-azure-web-apps),\n[部署在反向代理和路径前缀后](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-behind-reverse-proxies-and-path-prefixes),\n[部署到 Google Cloud Run](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-google-cloud-run),\n[部署到 Kubernetes (Ingress)](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-to-kubernetes-ingress),\n[在 Databricks 笔记本中部署](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-in-databricks-notebooks),\n以及\n[在 Kaggle 笔记本中部署](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002Fdeployment.html#deploying-in-kaggle-notebooks)。\n\n对于简洁的生产模式，只需暴露一个 WSGI 应用程序，并使用 `gunicorn` 运行：\n`app = db.flask_server()` 和 `gunicorn --bind=0.0.0.0:${PORT:-8000} dashboard:app`。\n如果你的部署运行在代理或路径前缀之后，并且看到“加载中…”的提示，请查看上述部署文档，确保 `url_base_pathname`、`routes_pathname_prefix` 和 `requests_pathname_prefix` 设置一致。\n\n将你的 `explainer` 和仪表板布局存储到磁盘上，然后再重新加载可能会很有帮助，例如：\n\n**generate_dashboard.py**:\n```python\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\nfrom explainerdashboard.custom import *\n\nexplainer = ClassifierExplainer(model, X_test, y_test)\n\n# 构建 ExplainerDashboard 可确保所有必要的属性都被计算出来：\ndb = ExplainerDashboard(explainer, [ShapDependenceComposite, WhatIfComposite],\n                        title='Awesome Dashboard', hide_whatifpdp=True)\n\n# 将 explainer 和仪表板配置都保存下来：\ndb.to_yaml(\"dashboard.yaml\", explainerfile=\"explainer.joblib\", dump_explainer=True)\n```\n\n然后你可以在 **dashboard.py** 中重新加载它：\n```python\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\n\n# 你可以在从配置文件加载时覆盖参数：\ndb = ExplainerDashboard.from_config(\"dashboard.yaml\", title=\"Awesomer Title\")\n\napp = db.flask_server()\n```\n\n然后可以通过以下命令运行：\n\n```sh\n    $ gunicorn dashboard:app\n```\n\n或者使用 waitress（Windows 上也适用）：\n\n```sh\n    $ waitress-serve dashboard:app\n```\n\n### 最小化内存使用\n\n当你部署一个包含大量行数 (`n`) 和列数 (`m`) 的数据集的仪表板时，其内存占用可能会非常大。你可以使用 `explainer.memory_usage()` 来检查（近似的）内存使用情况。（顺便提一句：如果你的数据行数很多，可能还需要设置 `plot_sample` 参数）\n\n为了减少内存占用，你可以采取以下几种措施：\n\n1. 不包含 SHAP 交互图：SHAP 交互值的形状是 (`n*m*m`)，因此会占用相当大的内存。\n2. 降低精度。默认情况下，SHAP 值以 `'float64'` 格式存储，但你可以将其改为 `'float32'` 格式来节省一半的空间：\n   ```ClassifierExplainer(model, X_test, y_test, precision='float32')```\n   当然，你也可以自行对 `X_test` 数据集设置较低的精度。\n3. 对于多分类模型，默认情况下 `ClassifierExplainer` 会为所有类别计算 SHAP 值。如果你只对某一类别感兴趣，可以丢弃其他类别的 SHAP 值：\n   `explainer.keep_shap_pos_label_only(pos_label)`\n4. 将数据外部存储。例如，你可以在 explainer 中仅存储 10,000 行数据（足以生成重要性与依赖性图表），而将剩余的数百万行输入数据存储在外部文件或数据库中：\n   - 使用 `explainer.set_X_row_func()` 可以设置一个函数，该函数接受一个 `index` 作为参数，并返回对应索引的单行 DataFrame，其中包含与模型兼容的输入数据。这个函数可以包括对数据库的查询或文件读取操作。\n   - 使用 `explainer.set_y_func()` 可以设置一个函数，该函数接受一个 `index` 作为参数，返回该索引对应的观测结果 `y`。\n   - 使用 `explainer.set_index_list_func()` 可以设置一个函数，该函数返回可查询的可用索引列表。此函数仅在仪表板启动时调用一次。\n\n   如果索引数量非常多，且用户能够在其他地方查找这些索引，你还可以将索引下拉菜单替换为简单的自由文本输入框，方法是设置 `index_dropdown=False`。默认情况下，只有有效的索引（即在 `get_index_list()` 列表中）才会被传递给其他组件，但你可以通过设置 `index_check=False` 来覆盖这一行为。此外，你还可以设置一个 `explainer.set_index_check_func(func)` 函数，该函数应返回一个布尔值，指示给定的 `index` 是否存在。\n\n   重要提示：这些函数可能会被多个独立组件多次调用，因此最好实现某种缓存功能。你传入的函数也可以是方法，这样你就可以访问 explainer 的所有内部机制。\n\n\n## 文档\n\n文档可在 [explainerdashboard.readthedocs.io](https:\u002F\u002Fexplainerdashboard.readthedocs.io\u002Fen\u002Flatest\u002F) 找到。\n\n关于如何为不同类型的模型启动仪表板的示例笔记本在此：[dashboard_examples.ipynb](notebooks\u002Fdashboard_examples.ipynb)。\n\n关于如何与 explainer 对象交互的示例笔记本在此：[explainer_examples.ipynb](notebooks\u002Fexplainer_examples.ipynb)。\n\n关于如何设计自定义仪表板的示例笔记本在此：[custom_examples.ipynb](notebooks\u002Fcustom_examples.ipynb)。\n\n\n\n## 已部署示例：\n\n你可以在 [Fly.io](https:\u002F\u002Ftitanicexplainer.fly.dev) 和 [Hugging Face Space](https:\u002F\u002Fhuggingface.co\u002Fspaces\u002Foegedijk\u002Fexplainingtitanic) 找到示例仪表板。\n\n（源代码位于 [https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic](https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainingtitanic)）\n\n## 引用：\n\nDOI 可在 [zenodo](https:\u002F\u002Fzenodo.org\u002Frecord\u002F7633294) 上找到","# explainerdashboard 快速上手指南\n\n`explainerdashboard` 是一个用于快速部署机器学习模型解释仪表盘的 Python 库。它支持 `scikit-learn`、`xgboost`、`catboost`、`lightgbm` 等主流框架，能够生成交互式网页，展示模型性能、特征重要性、SHAP 值、部分依赖图（PDP）以及“如果...会怎样”分析等功能，帮助数据科学家和业务人员理解黑盒模型。\n\n## 环境准备\n\n*   **操作系统**：Windows, macOS, Linux\n*   **Python 版本**：建议 Python 3.7 及以上\n*   **前置依赖**：\n    *   已训练好的机器学习模型（需兼容 scikit-learn 接口）\n    *   测试数据集 (`X_test`, `y_test`)\n    *   基础科学计算库：`pandas`, `numpy`, `scikit-learn`\n    *   可视化后端：`plotly`, `dash` (安装本库时会自动处理)\n\n## 安装步骤\n\n推荐使用国内镜像源加速安装。\n\n### 方式一：使用 pip 安装（推荐）\n\n```bash\npip install explainerdashboard -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n### 方式二：使用 conda 安装\n\n```bash\nconda install -c conda-forge explainerdashboard\n```\n\n## 基本使用\n\n只需几行代码即可为分类或回归模型启动一个完整的解释性仪表盘。\n\n### 1. 最简示例（一行代码启动）\n\n适用于快速检查模型行为。以下示例使用随机森林分类器：\n\n```python\nfrom sklearn.ensemble import RandomForestClassifier\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\n\n# 假设 X_train, y_train, X_test, y_test 已准备好\nmodel = RandomForestClassifier().fit(X_train, y_train)\n\n# 构建解释器并直接运行仪表盘\nExplainerDashboard(ClassifierExplainer(model, X_test, y_test)).run()\n```\n\n运行后，终端会显示访问地址（默认为 `http:\u002F\u002F127.0.0.1:8050`），在浏览器打开即可查看。\n\n### 2. 标准示例（自定义配置）\n\n在实际项目中，通常需要指定特征描述、类别分组和标签名称，以提升仪表盘的可读性。\n\n```python\nfrom sklearn.ensemble import RandomForestClassifier\nfrom explainerdashboard import ClassifierExplainer, ExplainerDashboard\n\n# 1. 训练模型\nmodel = RandomForestClassifier(n_estimators=50, max_depth=5)\nmodel.fit(X_train, y_train)\n\n# 2. 构建解释器对象\n# cats: 将 One-Hot 编码的列归组（如 'Sex_male', 'Sex_female' 归为 'Sex'）\n# descriptions: 特征的人类可读描述\n# labels: 分类目标的标签名称\nexplainer = ClassifierExplainer(\n    model, \n    X_test, \n    y_test,\n    cats=['Deck', 'Embarked', {'Gender': ['Sex_male', 'Sex_female']}],\n    descriptions={\n        \"Age\": \"乘客年龄\",\n        \"Fare\": \"票價\",\n        \"Sex\": \"性别\"\n    },\n    labels=['未幸存', '幸存'],\n    idxs=test_names, # 可选：设置样本索引名称\n    index_name=\"乘客姓名\",\n    target=\"生存状态\"\n)\n\n# 3. 创建并运行仪表盘\ndb = ExplainerDashboard(\n    explainer,\n    title=\"泰坦尼克号生存预测模型解释\",\n    shap_interaction=False, # 可关闭特定标签页以简化界面\n)\n\ndb.run(port=8050)\n```\n\n### 3. 回归模型示例\n\n对于回归任务，使用 `RegressionExplainer` 并可指定目标单位：\n\n```python\nfrom sklearn.ensemble import RandomForestRegressor\nfrom explainerdashboard import RegressionExplainer, ExplainerDashboard\n\nmodel = RandomForestRegressor().fit(X_train, y_train)\n\nexplainer = RegressionExplainer(\n    model, \n    X_test, \n    y_test,\n    cats=['Deck', 'Embarked', 'Sex'],\n    units=\"$\" # 指定目标变量单位\n)\n\nExplainerDashboard(explainer).run()\n```\n\n### 4. 导出静态 HTML\n\n若需将仪表盘作为报告分享或集成到 CI\u002FCD 流程中，可导出为静态 HTML 文件：\n\n```python\n# 导出包含所有交互功能的静态 HTML\ndb.save_html('dashboard.html')\n\n# 或者导出针对特定样本的静态页面\nExplainerDashboard(explainer, index=0).save_html('specific_prediction.html')\n```","某金融风控团队正在向监管机构汇报其信贷违约预测模型的合规性，急需直观展示复杂集成模型（如 XGBoost）的决策逻辑。\n\n### 没有 explainerdashboard 时\n- 数据科学家需手动编写大量 Matplotlib 代码绘制 SHAP 值和特征重要性，耗时数天且难以维护。\n- 业务人员无法理解静态报告中的数学图表，反复询问“为什么拒绝这位客户”，沟通成本极高。\n- 缺乏交互能力，监管方提出的“如果改变某个收入变量结果会怎样”等假设性问题无法现场验证。\n- 每次模型迭代更新解释报告都需要重新运行脚本并生成新文件，流程繁琐且容易出错。\n- 难以将分散的分析图表整合成统一视图，导致汇报材料杂乱，缺乏专业说服力。\n\n### 使用 explainerdashboard 后\n- 仅需几行代码即可自动部署包含模型性能、特征贡献及决策树可视化的交互式 Web 看板，效率提升十倍。\n- 业务人员可通过界面直接查看单个客户的预测归因，清晰理解拒贷原因，沟通障碍瞬间消除。\n- 内置\"What-if\"分析模块，允许用户实时调整输入参数并观察预测变化，轻松应对监管质询。\n- 支持一键导出静态 HTML 或集成至 CI\u002FCD 流程，确保每次模型上线都能同步生成最新的解释文档。\n- 通过模块化设计将多个分析维度整合进 ExplainerHub，提供一站式、专业且美观的汇报演示体验。\n\nexplainerdashboard 将黑盒模型转化为透明、可交互的信任桥梁，让技术团队能高效满足合规要求并赢得业务侧信赖。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Foegedijk_explainerdashboard_59bfebb0.png","oegedijk","Oege Dijk","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Foegedijk_57a86154.jpg","Lead Machine Learning Engineer @ thoughtworks","Marcura","Rotterdam, the Netherlands","oegedijk@gmail.com",null,"https:\u002F\u002Fgithub.com\u002Foegedijk",[85,89,93],{"name":86,"color":87,"percentage":88},"Python","#3572A5",99,{"name":90,"color":91,"percentage":92},"CSS","#663399",0.8,{"name":94,"color":95,"percentage":96},"Just","#384d54",0.2,2484,346,"2026-04-04T16:26:37","MIT","Linux, macOS, Windows","未说明",{"notes":104,"python":102,"dependencies":105},"该工具主要用于解释 scikit-learn 兼容的机器学习模型（如随机森林、XGBoost、LightGBM、CatBoost 及 PyTorch 表格模型）。支持通过 pip 或 conda-forge 安装。可在 Jupyter\u002FColab 中交互运行，也可部署为 Web 应用或导出为静态 HTML。特别支持 AWS SageMaker Studio 环境，可自动检测并配置代理前缀。无明确的 GPU 或大内存强制要求，具体资源需求取决于所加载的基础模型大小。",[25,106,107,108,109,110,111,112,113,114],"xgboost","catboost","lightgbm","skorch","plotly","dash","shap","pandas","numpy",[14],[111,117,118,119,120,121,122,123,112,110,124,125,126,127],"shap-values","dashboard","model-predictions","data-scientists","explainer","interactive-dashboards","permutation-importances","inner-workings","interactive-plots","xai-library","xai","2026-03-27T02:49:30.150509","2026-04-06T08:10:29.649958",[131,136,141,146,151,156,161],{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},16829,"如何将 Dashboard 导出为静态 HTML 文件以便离线查看或存储？","可以通过两种方式导出静态 HTML：1. 在 Dashboard 界面头部的下载链接直接下载；2. 使用代码直接导出，例如调用 `dashboard.save_html(\"dashboard.html\")`。注意静态导出会限制部分交互功能，但适合存档模型训练信息。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F90",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},16830,"如何减少 ExplainerDashboard 运行时的内存占用（特别是处理大规模数据集时）？","针对大数据集（如 30 万样本），可以通过以下方式优化内存：1. 安装最新版本（v0.3.0+），其中包含针对二分类器的内存优化；2. 参考 README 中的“最小化内存使用”章节（Minimizing Memory Usage）进行配置；3. 考虑将个体层面的属性存储到数据库中，仅在回调时查询，而不是全部加载到 RAM 中。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F68",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},16831,"当 SHAP 值计算出现随机加法性检查异常（additivity check exceptions）时如何解决？","该问题通常由竞态条件引起。解决方案包括：1. 升级到最新版本（v0.3.2.2+），该版本添加了锁机制以防止竞态条件；2. 如果索引存在于 `X_test` 中，系统现在会直接查找而不是重新计算 SHAP 值，从而避免错误；3. 确保不要从外部源动态加载数据导致状态不一致。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F84",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},16832,"如何在 SHAP 依赖图（Shap Dependence Plot）中切换是否显示异常值处理效果？","新版本（v0.3.3.1+）已支持此功能。用户可以在图表上通过切换按钮来启用或禁用异常值处理。这允许用户同时观察原始数据和经过异常值处理后的数据对特征依赖关系的影响，无需在传入数据前手动预处理。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F93",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},16833,"dtreeviz 库升级到 2.0 版本后是否会影响 explainerdashboard 的使用？","dtreeviz 2.0 的 API 变更曾导致兼容性问题，但已在 explainerdashboard v0.4.2 版本中修复。如果遇到相关警告或错误，请升级 explainerdashboard 到 v0.4.2 或更高版本。集成示例代码：`db = ExplainerDashboard.from_config(\"dashboard.yaml\", url_base_pathname=\"\u002Fdashboard\u002F\"); app = db.flask_server()`。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F243",{"id":157,"question_zh":158,"answer_zh":159,"source_url":160},16834,"如何通过指定 ID（而非列表索引）加载单个样本的预测解释？","现已支持通过任意指定 ID 加载个体预测。可以通过实现外部加载函数（如 `set_X_row_func`, `set_y_func`）并结合数据库（如 SQLite）和缓存（如 Redis）来实现。具体实现可参考 v0.3.2.2 版本更新，该版本解决了不同分类器模型返回格式不一致的问题，并添加了 `get_shap_row()` 方法以检索特定索引的 SHAP 值。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F89",{"id":162,"question_zh":163,"answer_zh":164,"source_url":165},16835,"如何在 Heroku 上正确部署应用以避免 Slug 过大（超过 500MB）？","部署时需正确添加 Buildpack。步骤包括：1. 将 `bin` 文件夹从 `niteoweb\u002Fheroku-buildpack-shell` 添加到项目根目录；2. 创建 `.heroku` 文件夹并在其中添加 `run.sh` 文件，内容包含必要的安装命令（如 `pip install -y xgboost`）；3. 确保在 Heroku 设置中正确配置了该 Buildpack。若仍生成过大 Slug，请检查是否有多余的大文件被提交或依赖包未正确排除。","https:\u002F\u002Fgithub.com\u002Foegedijk\u002Fexplainerdashboard\u002Fissues\u002F38",[167,172,177,182,187,192,197,202,207,212,217,221,226,231,236,241,246,251,256,261],{"id":168,"version":169,"summary_zh":170,"released_at":171},99103,"v0.5.8","## 版本 0.5.8：\n\n### 错误修复\n- 修复问题 #198：在 SHAP\u002F仪表板路径中处理包含字符串类型分类特征的 LightGBM 模型时，通过规范化树 SHAP 评估输入中的分类列来解决该问题。\n- 防止在计算 SHAP 值过程中，由于对象或字符串类型的分类值而导致 LightGBM 的假设分析\u002FSHAP 流程崩溃。\n- 修复 CatBoost PDP\u002F仪表板回调在 `X_row` 中存在缺失的（NaN）分类值时发生的崩溃问题，方法是保留数据框的分类列处理逻辑，并对 CatBoost 的分类预测输入进行清理。\n- 修复问题 #146：现在 `ExplainerHub.to_yaml(..., integrate_dashboard_yamls=True)` 会尊重 `pickle_type` 设置，而不是硬编码为 `.joblib`；同时，在 `dump_explainers=True` 时也能正确转储解释器文件。\n- 修复问题 #294：通过在多分类对数几率显示中使用每个类别的原始边际值，使 Prediction Box 和贡献度图在 `model_output='logodds'` 语义上保持一致。\n- 修正多分类 PDP 在对数几率模式下突出显示预测时，使其采用与 SHAP 贡献度相同的原始边际尺度。\n- 修正 XGBoost 多分类决策路径摘要的表述，当解释器的 `model_output='logodds'` 时，显示为“预测（对数几率）”。\n- 修复问题 #256：为那些暴露 `decision_function` 但未提供 `predict_proba` 方法的分类器（例如 `LinearSVC`），添加稳健的多分类概率回退机制，并在核 SHAP、预测辅助函数、PDP 和置换评分器路径中统一使用该机制。\n- 当用户提供的或损坏的 `predict_proba` 输出与模型类别数量不匹配时，通过回退到基于 `decision_function` 的概率计算，防止多分类类别计数不一致的问题。\n- 修复问题 #118：在仪表板的树形选项卡中，通过 explainer 自动检测、树形绘图和决策路径渲染等功能，新增对 LightGBM 决策树可视化（dtreeviz）的支持。\n- 通过将 matplotlib 切换为非交互式后端以在主线程之外进行树形渲染，从而避免仪表板出现 500 错误，修复了 macOS 上 dtreeviz 回调渲染的问题。","2026-02-08T16:41:38",{"id":173,"version":174,"summary_zh":175,"released_at":176},99104,"v0.5.7","## 版本 0.5.7：\n\n### 错误修复\n- 允许 FeatureInputComponent（假设输入）自定义数值范围和四舍五入，并为输入应用最小值、最大值和步长限制。\n- 向 FeatureInputComponent 添加 `input_features` 和 `hide_features` 参数，以便显式地设置假设字段的顺序并选择性隐藏部分字段，同时保持完整的回调输入契约。\n- 修复问题 #220：在 `get_contrib_df` 中接受单行列表或数组形式的 `X_row` 输入，并通过回归测试强化相关行级输入路径（`get_col_value_plus_prediction`、`pdp_df` 以及分类器\u002F回归模型的 `prediction_result_df`）。\n- 修复问题 #262：为分类器\u002F回归模型的 `random_index(...)` 方法添加基于特征的过滤条件（数值范围和类别包含），从而实现受输入特征值约束的假设随机选择功能。\n- 通过在分类器\u002F回归模型的辅助路径中对 `predict_proba`\u002F`predict` 的输出进行索引之前将其强制转换为 NumPy 数组，提升与 AutoGluon\u002F自定义封装器的兼容性。\n- 强化 one-vs-all 评分器的处理逻辑，使 `make_one_vs_all_scorer` 也能接受 `predict_proba` 返回 Pandas DataFrame 的分类器。\n- 修复 ExplainerHub 在首次请求后调用 `add_dashboard_route` 时的问题：允许在路由触发的注册过程中动态完成仪表板的注册与初始化，并为问题 #269 添加回归测试。\n- 修复问题 #273：避免在解释器设置、PDP\u002F类别排序以及分类变量绘图路径中，因混合类型和 NaN 值的存在而导致分类值排序时发生崩溃。\n- 为解释器和绘图中的混合类型分类值排序以及混合目标标签排序回退机制添加回归测试。","2026-02-08T09:50:06",{"id":178,"version":179,"summary_zh":180,"released_at":181},99105,"v0.5.6","\r\n## 版本 0.5.6:\r\n\r\n### 错误修复\r\n- 修复 FeatureInputComponent 对布尔列的范围计算问题（避免对布尔值使用 np.round），并添加回归测试。\r\n- 确保 save_html 包含自定义标签页，方法是为没有 to_html 实现的标签页提供静态导出的回退方案。\r\n- 在 ClassifierExplainer 中支持字符串类型的类别标签，通过保留标签映射并避免浮点数转换来实现。  \r\n- 支持 CalibratedClassifierCV，使用其拟合好的基础估计器进行 SHAP 分析（避免回退到核方法）。\r\n\r\n### 改进\r\n- 替换 print 语句","2026-02-06T21:13:00",{"id":183,"version":184,"summary_zh":185,"released_at":186},99106,"v0.5.5.1","## 版本 0.5.5：\n\n### 错误修复\n- 通过在输入中显示“NaN”选项，并将“NaN”选择归一化回真实的缺失值，来处理分类特征中的缺失值。\n- 添加测试，覆盖合并与未合并输入路径下的分类特征 NaN 处理逻辑。\n- 在排列重要性洗牌和 PDP 网格生成过程中保留分类数据类型，以防止因数据类型不匹配导致的模型错误（例如 LightGBM）。\n- 对用户提供的 `X_row` 输入的分类和布尔数据类型进行对齐，并添加数据类型对齐测试。\n\n### 改进\n- 通过 `shap='gputree'` 添加对 GPU Tree SHAP 解释器的支持（需要启用 CUDA 的 SHAP 库）。\n- 添加对 SageMaker Studio 的支持：自动检测环境、应用代理前缀，并提供用于覆盖的 CLI 标志。","2026-01-29T20:37:55",{"id":188,"version":189,"summary_zh":190,"released_at":191},99107,"v0.5.4","## 版本 0.5.4：\n\n### 破坏性变更\n- 要求 Dash >=3.0.4 以支持 dash-bootstrap-components 2.x\n\n### 改进\n- 放宽了 dash-bootstrap-components 的版本上限，允许使用 2.x 版本\n- 更新了 DropdownMenu 的对齐方式，改为在 dbc 2.x 中使用 `align_end`\n- 调整了逻辑回归的测试 fixture，以避免收敛警告\n\n### Bug 修复\n- 通过向不包含 `feature_names_in_` 属性的估计器传递 NumPy 数组，避免在 PDP 计算中出现 sklearn 的特征名称警告\n- 统一了 PDP 和预测辅助函数中的模型输入处理方式，以减少警告信息的干扰\n","2026-01-25T21:45:50",{"id":193,"version":194,"summary_zh":195,"released_at":196},99108,"v0.5.3","## 版本 0.5.3：\n\n### 改进\n- 允许使用 NumPy 2.x，但在 Python 3.11 及以上版本中将其版本限制在 `\u003C2.4`，以避免 numba\u002Fllvmlite 降级问题。\n","2026-01-25T20:45:49",{"id":198,"version":199,"summary_zh":200,"released_at":201},99109,"v0.5.2.1","## 版本 0.5.2：\n\n### 破坏性变更\n- 停止对 Python 3.8 和 3.9 的支持（Python 3.9 已结束生命周期）。最低 Python 版本现为 3.10。\n- 明确支持并测试 Python 3.10、3.11、3.12 和 3.13。\n\n### 改进\n- 移除了 `dash` 和 `plotly` 依赖的版本上限约束，现支持 Dash 2.10+ 和 3.0+，以及 Plotly 5.0+ 和 6.0+。\n- 添加了向后兼容代码，同时支持 Dash 2.x (`app.run_server()`) 和 Dash 3.x (`app.run()`) API。\n- 通过将 `titlefont` 更新为 `title.font` 格式，修复了与 Plotly 6.0 的兼容性问题。\n- 使用 `webdriver-manager` 实现 ChromeDriver 的自动管理，改进了集成测试的设置。\n- 通过切换到推荐的 `plotly.graph_objects` 导入方式，解决了 Plotly 验证器初始化时的线程问题。\n- 在 Intel Mac 上，将 `torch` 和 `skorch` 设为可选依赖项（因为这些平台上没有可用的 torch 轮子）。\n\n### 错误修复\n- 修复了在多线程环境中因 Plotly 验证器初始化而导致的集成测试中的 `SystemExit` 警告。\n- 更新了 `.gitignore` 文件，以排除 webdriver-manager 的缓存目录和 `uv.lock` 文件。\n- **XGBoost 3.1+ 兼容性**：修复了 XGBoost 3.1+ 返回的字符串格式预测值和 `base_score` 值的处理问题。新增了健壮的字符串到数值转换逻辑，并使用正则表达式作为后备方案，以应对各种字符串格式（例如 `'[3.2967056E1]'`、`'[8.563135E-2,7.169811E-1,1.9738752E-1]'` 等）。\n- **XGBoost SHAP 初始化**：修复了在 `get_params()` 方法以及 booster 内部 JSON 配置中 `base_score` 的转换问题，确保 SHAP TreeExplainer 能够正确初始化于 XGBoost 3.1+。\n- **RandomForest dtreeviz 兼容性**：修复了 `y_train` 的数据类型处理问题（现使用 `int` 类型而非 `int16`），并改进了 `predict_path()` 所需观测数组的转换，使其能够与较新的 dtreeviz 版本兼容。\n- **dtreeviz decisiontree_view**：确保观测值以 NumPy 数组形式传递，以避免在 dtreeviz 按整数位置索引特征时出现 Pandas 标签查找错误。\n- **PyPI 打包**：从 hatchling 构建配置中移除了重复的 wheel 条目，以解决“本地标头中存在重复文件名”的上传错误。\n- **Pandas 弃用警告**：移除了已弃用的 `pd.option_context(\"future.no_silent_downcasting\")` 以及 `.infer_objects()` 调用中的 `copy=False` 参数。\n- **运行时警告**：通过添加适当的零值检查，并使用带有 `where` 参数的 `np.divide()` 函数，修复了分类图和残差图中因对数比计算而产生的除零警告。","2026-01-25T16:23:39",{"id":203,"version":204,"summary_zh":205,"released_at":206},99110,"v0.5.1","迁移到现代的 pyproject.toml（并弃用旧的 setup.py）","2025-06-03T18:36:58",{"id":208,"version":209,"summary_zh":210,"released_at":211},99111,"v0.4.8","进行了少量更改，以确保与 scikit-learn 1.6 兼容。\n\n某些模型，例如 XGBoost 或 Skorch，并未更新其 __sklearn_tags__ 属性，但预计这些问题很快会在上游得到修复。","2024-12-29T21:23:05",{"id":213,"version":214,"summary_zh":215,"released_at":216},99112,"v0.4.7","## 版本 0.4.7：\n\n\n### 错误修复\n- 修复在没有分类列时合并分类列的问题\n- 处理 Pandas 选项设置上下文，以防其不存在\n- 移除 `is_categorical_dtype`，因为它已被弃用","2024-03-18T21:01:54",{"id":218,"version":219,"summary_zh":82,"released_at":220},99113,"v0.4.6.1","2024-03-12T20:06:51",{"id":222,"version":223,"summary_zh":224,"released_at":225},99114,"v0.4.6","### Bug Fixes\r\n- should now work with the format of shap 0.45 that returns a three dimensional np.array instead of a list of 2-dimensional np.arrays for classifiers\r\n-\r\n\r\n### Improvements\r\n- Fixed several pandas warning about to be deprecated behaviours\r\n-","2024-03-12T19:27:03",{"id":227,"version":228,"summary_zh":229,"released_at":230},99115,"v0.4.5","- it seems numba and numpy are getting along better again","2023-12-17T19:42:14",{"id":232,"version":233,"summary_zh":234,"released_at":235},99116,"v0.4.4","### Bug Fixes\r\n- Add warning to set `shap_kwargs=dict(check_additivity=True)` for skorch models, and switch this on for the tests.\r\n-","2023-12-17T13:04:46",{"id":237,"version":238,"summary_zh":239,"released_at":240},99117,"v0.4.3","\r\n## Version 0.4.3:\r\n\r\n### New Features\r\n- models that use kernel explainer but output multi-dimensional predictions such as PLSRegression are now supported. \r\nPredictions now get squeezed in the kernel function.\r\n\r\n\r\n### Bug Fixes\r\n- Fixed bug with pandas v2, Pandas v2 now supported\r\n\r\n### Improvements\r\n- Fixed a number of UserWarnings","2023-08-01T11:52:36",{"id":242,"version":243,"summary_zh":244,"released_at":245},99118,"v0.4.2.2","## Version 0.4.2.2:\r\n\r\n- pins dependencies for flask-wtf>1.1, numpy\u003C1.24 and pandas\u003C2 while working to sort out some compatibility issues.","2023-05-04T07:26:58",{"id":247,"version":248,"summary_zh":249,"released_at":250},99119,"v0.4.2.1","## Version 0.4.2.1:\r\n\r\n\r\n### Bug Fixes\r\n- tries to work around wonky index dropdown search bug introduced by latest dash release: https:\u002F\u002Fgithub.com\u002Fplotly\u002Fdash\u002Fissues\u002F2428\r\n- Dropdown search now works again, but index propagation is still flaky when number of idxs > max_idxs_in_dropdown(1000 by default)\r\n- displays warning to downgrade to dash 2.6.2 when this happens\r\n","2023-02-19T21:13:25",{"id":252,"version":253,"summary_zh":254,"released_at":255},99120,"v0.4.2","\r\n## Version 0.4.2:\r\n### Breaking Changes\r\n- Now needs dtreeviz>2.1, due to the API change with version v2\r\n\r\n### Bug Fixes\r\n- Fixed import and tree display bug with newer version of dtreeviz","2023-02-12T12:35:01",{"id":257,"version":258,"summary_zh":259,"released_at":260},99121,"v0.4.1.1","- adds `MANIFEST.in` to include `requirements.txt` in the pypi upload, which should fix the conda package issue","2023-01-02T19:09:46",{"id":262,"version":263,"summary_zh":264,"released_at":265},99122,"v0.4.1","# Version 0.4.1\r\n\r\n\r\n## New Features\r\n- added routes_pathname_prefix:str=None, requests_pathname_prefix:str=None, to ExplainerDashboard to help running the dashboard on e.g. Sagemaker\r\n\r\n## Bug Fixes\r\n- Bug with plotly showticklabels=False changed to tickfont=dict(color=\"rgba(0, 0, 0, 0)\")\r\n- Imports now comply with dtreeviz v2 API\r\n","2022-12-31T21:02:02"]