[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-salesforce--OmniXAI":3,"tool-salesforce--OmniXAI":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",156804,2,"2026-04-15T11:34:33",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",108322,"2026-04-10T11:39:34",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":97,"forks":98,"last_commit_at":99,"license":100,"difficulty_score":32,"env_os":101,"env_gpu":102,"env_ram":103,"env_deps":104,"category_tags":116,"github_topics":117,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":123,"updated_at":124,"faqs":125,"releases":156},7818,"salesforce\u002FOmniXAI","OmniXAI","OmniXAI: A Library for eXplainable AI","OmniXAI 是一个专为可解释人工智能（XAI）打造的 Python 开源库，旨在帮助开发者轻松理解机器学习模型背后的决策逻辑。在实际应用中，许多复杂的 AI 模型如同“黑盒”，让人难以知晓其为何做出特定预测，OmniXAI 正是为了解决这一痛点而生。它提供了一套统一且易用的接口，支持表格、图像、文本和时间序列等多种数据类型，兼容 Scikit-learn 等传统机器学习框架以及 PyTorch、TensorFlow 等深度学习模型。\n\n无论是数据科学家、机器学习研究人员还是工程实践者，都能通过 OmniXAI 快速生成特征归因、反事实解释、梯度分析等多样化的解释结果。除了代码调用，它还配备了直观的图形化仪表盘，让用户能可视化地探索模型行为，获得更深层的洞察。值得一提的是，最新版本还创新性地集成了基于 GPT 的实验性解释器，能够结合 SHAP 和 MACE 的计算结果，利用大语言模型生成自然流畅的文字解释，进一步降低了理解门槛。如果你希望在构建可信 AI 的过程中让模型决策更加透明，OmniXAI 将是一个得力的助手。","\u003Cp align=\"center\">\n    \u003Cbr>\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_ab44c7aac341.png\" width=\"400\"\u002F>\n    \u003Cbr>\n\u003Cp>\n\n# OmniXAI: A Library for Explainable AI\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"#\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.7, 3.8, 3.9, 3.10-blue\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fomnixai\">\n  \u003Cimg alt=\"PyPI\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fomnixai.svg\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\">\n  \u003Cimg alt=\"Documentation\" src=\"https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Factions\u002Fworkflows\u002Fdocs.yml\u002Fbadge.svg\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpepy.tech\u002Fproject\u002Fomnixai\">\n  \u003Cimg alt=\"Downloads\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_7ae11847d0dd.png\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612\">\n  \u003Cimg alt=\"DOI\" src=\"https:\u002F\u002Fzenodo.org\u002Fbadge\u002FDOI\u002F10.48550\u002FARXIV.2206.01612.svg\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n## Table of Contents\n1. [Introduction](#introduction)\n2. [Installation](#installation)\n3. [Getting Started](#getting-started)\n4. [Documentation](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html)\n5. [Tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html)\n6. [Deployment](#deployment)\n7. [Dashboard Demo](https:\u002F\u002Fomnixai-24e10803fd23.herokuapp.com\u002F)\n8. [How to Contribute](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Fomnixai.html#how-to-contribute)\n9. [Technical Report and Citing OmniXAI](#technical-report-and-citing-omnixai)\n\n## What's New\n\nThe latest version includes an experimental GPT explainer. This explainer leverages the outcomes \nproduced by SHAP and MACE to formulate the input prompt for ChatGPT. Subsequently, ChatGPT \nanalyzes these results and generates the corresponding explanations that provide developers with \na clearer understanding of the rationale behind the model's predictions.\n\n## Introduction\n\nOmniXAI (short for Omni eXplainable AI) is a Python machine-learning library for explainable AI (XAI), offering omni-way explainable AI and interpretable \nmachine learning capabilities to address many pain points in explaining decisions made by machine learning \nmodels in practice. OmniXAI aims to be a one-stop comprehensive library that makes explainable AI easy for \ndata scientists, ML researchers and practitioners who need explanation for various types of data, models and \nexplanation methods at different stages of ML process:\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_44155682279e.png)\n\nOmniXAI includes a rich family of explanation methods integrated in a unified interface, which \nsupports multiple data types (tabular data, images, texts, time-series), multiple types of ML models \n(traditional ML in Scikit-learn and deep learning models in PyTorch\u002FTensorFlow), and a range of diverse explaination \nmethods including \"model-specific\" and \"model-agnostic\" methods (such as feature-attribution explanation, \ncounterfactual explanation, gradient-based explanation, feature visualization, etc). For practitioners, OmniXAI provides an easy-to-use \nunified interface to generate the explanations for their applications by only writing a few lines of \ncodes, and also a GUI dashboard for visualization for obtaining more insights about decisions.\n\nThe following table shows the supported explanation methods and features in our library.\nWe will continue improving this library to make it more comprehensive in the future.\n\n|          Method           |  Model Type   | Explanation Type | EDA | Tabular | Image | Text | Timeseries | \n:-------------------------:|:-------------:|:----------------:|:---:|:-------:|:-----:| :---: | :---:\n|     Feature analysis      |      NA       |      Global      |  ✅  |         |       |      |      |\n|     Feature selection     |      NA       |      Global      |  ✅  |         |       |      |      |\n|    Prediction metrics     |   Black box   |      Global      |     |    ✅    |   ✅   | ✅   |  ✅  |\n|       Bias metrics        |   Black box   |      Global      |     |    ✅    |       |      |      |\n| Partial dependence plots  |   Black box   |      Global      |     |    ✅    |       |      |      |\n| Accumulated local effects |   Black box   |      Global      |     |    ✅    |       |      |      |\n|   Sensitivity analysis    |   Black box   |      Global      |     |    ✅    |       |      |      |\n|  Permutation explanation  |   Black box   |      Global      |     |    ✅    |       |      |      |\n|   Feature visualization   |  Torch or TF  |      Global      |     |         |   ✅   |      |      |\n|       Feature maps        |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|       GPT explainer       | Black box     |     Local        |     |    ✅    |       |      |      |\n|           LIME            |   Black box   |      Local       |     |    ✅    |   ✅   | ✅   |      |\n|           SHAP            |  Black box*   |      Local       |     |    ✅    |   ✅   | ✅   |  ✅  |\n|          What-if          |   Black box   |      Local       |     |    ✅    |       |      |     |\n|    Integrated gradient    |  Torch or TF  |      Local       |     |    ✅    |   ✅   | ✅   |      |\n|      Counterfactual       |  Black box*   |      Local       |     |    ✅    |   ✅   | ✅   |  ✅  |\n|  Contrastive explanation  |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|   Grad-CAM, Grad-CAM++    |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|         Score-CAM         |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|         Layer-CAM         |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|      Smooth gradient      |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|  Guided backpropagation   |  Torch or TF  |      Local       |     |         |   ✅   |      |      |\n|    Learning to explain    |   Black box   |      Local       |     |    ✅    |   ✅   | ✅   |      |\n|       Linear models       | Linear models | Global and Local |     |    ✅    |       |      |      |\n|        Tree models        |  Tree models  | Global and Local |     |    ✅    |       |      |      |\n\n*SHAP* accepts black box models for tabular data, PyTorch\u002FTensorflow models for image data, transformer models\nfor text data. *Counterfactual* accepts black box models for tabular, text and time-series data, and PyTorch\u002FTensorflow models for\nimage data.\n\nThis [table](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html#comparison-with-competitors) \nshows the comparison between our toolkit\u002Flibrary and other existing XAI toolkits\u002Flibraries\nin literature.\n\n**OmniXAI also integrates ChatGPT for generating plain text explanations given a classification\u002Fregression\nmodel on tabular datasets.** The generated results may not be 100% accurate, but it is worth trying this \nexplainer (we will continue improving the input prompts).\n\n## Installation\n\nYou can install ``omnixai`` from PyPI by calling ``pip install omnixai``. You may install from source by\ncloning the OmniXAI repo, navigating to the root directory, and calling\n``pip install .``, or ``pip install -e .`` to install in editable mode. You may install additional dependencies:\n\n- **For plotting & visualization**: Calling ``pip install omnixai[plot]``, or ``pip install .[plot]`` from the\n  root directory of the repo.\n- **For vision tasks**: Calling ``pip install omnixai[vision]``, or ``pip install .[vision]`` from the\n  root directory of the repo.\n- **For NLP tasks**: Calling ``pip install omnixai[nlp]``, or ``pip install .[nlp]`` from the\n  root directory of the repo.\n- **Install all the dependencies**: Calling ``pip install omnixai[all]``, or ``pip install .[all]`` from the\n  root directory of the repo.\n\n## Getting Started\n\nFor example code and an introduction to the library, see the Jupyter notebooks in\n[tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html), and the guided walkthrough\n[here](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html).\n\nSome examples:\n1. [Tabular classification](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular_classification.ipynb)\n2. [Tabular regression](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular_regression.ipynb)\n3. [Image classification](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision.ipynb)\n4. [Text classification](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fnlp_imdb.ipynb)\n5. [Time-series anomaly detection](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftimeseries.ipynb)\n6. [Vision-language tasks](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Fgradcam_vlm.ipynb)\n7. [Ranking tasks](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular\u002Franking.ipynb)\n8. [Feature visualization](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Ffeature_visualization_torch.ipynb)\n9. [Check feature maps](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Ffeature_map_torch.ipynb)\n10. [GPT explainer for tabular](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular\u002Fgpt.ipynb)\n\nTo get started, we recommend the linked tutorials in [tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html).\nIn general, we recommend using `TabularExplainer`, `VisionExplainer`,\n`NLPExplainer` and `TimeseriesExplainer` for tabular, vision, NLP and time-series tasks, respectively, and using\n`DataAnalyzer` and `PredictionAnalyzer` for feature analysis and prediction result analysis.\nThese classes act as the factories of the individual explainers supported in OmniXAI, providing a simpler\ninterface to generate multiple explanations. To generate explanations, you only need to specify\n\n- **The ML model to explain**: e.g., a scikit-learn model, a tensorflow model, a pytorch model or a black-box prediction function.\n- **The pre-processing function**: i.e., converting raw input features into the model inputs.\n- **The post-processing function (optional)**: e.g., converting the model outputs into class probabilities.\n- **The explainers to apply**: e.g., SHAP, MACE, Grad-CAM.\n\nBesides using these classes, you can also create a single explainer defined in the `omnixai.explainers` package, e.g.,\n`ShapTabular`, `GradCAM`, `IntegratedGradient` or `FeatureVisualizer`.\n\nLet's take the income prediction task as an example.\nThe [dataset](https:\u002F\u002Farchive.ics.uci.edu\u002Fml\u002Fdatasets\u002Fadult) used in this example is for income prediction.\nWe recommend using data class `Tabular` to represent a tabular dataset. To create a `Tabular` instance given a pandas\ndataframe, you need to specify the dataframe, the categorical feature names (if exists) and the target\u002Flabel\ncolumn name (if exists).\n\n```python\nfrom omnixai.data.tabular import Tabular\n# Load the dataset\nfeature_names = [\n   \"Age\", \"Workclass\", \"fnlwgt\", \"Education\",\n   \"Education-Num\", \"Marital Status\", \"Occupation\",\n   \"Relationship\", \"Race\", \"Sex\", \"Capital Gain\",\n   \"Capital Loss\", \"Hours per week\", \"Country\", \"label\"\n]\ndf = pd.DataFrame(\n  np.genfromtxt('adult.data', delimiter=', ', dtype=str),\n  columns=feature_names\n)\ntabular_data = Tabular(\n   df,\n   categorical_columns=[feature_names[i] for i in [1, 3, 5, 6, 7, 8, 9, 13]],\n   target_column='label'\n)\n```\n\nThe package `omnixai.preprocessing` provides several useful preprocessing functions\nfor a `Tabular` instance. `TabularTransform` is a special transform designed for processing tabular data.\nBy default, it converts categorical features into one-hot encoding, and keeps continuous-valued features.\nThe  method ``transform`` of `TabularTransform` transforms a `Tabular` instance to a numpy array.\nIf the `Tabular` instance has a target\u002Flabel column, the last column of the numpy array\nwill be the target\u002Flabel. You can apply any customized preprocessing functions instead of using `TabularTransform`. \nAfter data preprocessing, let's train a XGBoost classifier for this task.\n\n```python\nfrom omnixai.preprocessing.tabular import TabularTransform\n# Data preprocessing\ntransformer = TabularTransform().fit(tabular_data)\nclass_names = transformer.class_names\nx = transformer.transform(tabular_data)\n# Split into training and test datasets\ntrain, test, train_labels, test_labels = \\\n    sklearn.model_selection.train_test_split(x[:, :-1], x[:, -1], train_size=0.80)\n# Train an XGBoost model (the last column of `x` is the label column after transformation)\nmodel = xgboost.XGBClassifier(n_estimators=300, max_depth=5)\nmodel.fit(train, train_labels)\n# Convert the transformed data back to Tabular instances\ntrain_data = transformer.invert(train)\ntest_data = transformer.invert(test)\n```\n\nTo initialize `TabularExplainer`, the following parameters need to be set:\n\n- ``explainers``: The names of the explainers to apply, e.g., [\"lime\", \"shap\", \"mace\", \"pdp\"].\n- ``data``: The data used to initialize explainers. ``data`` is the training dataset for training the\n  machine learning model. If the training dataset is too large, ``data`` can be a subset of it by applying\n  `omnixai.sampler.tabular.Sampler.subsample`.\n- ``model``: The ML model to explain, e.g., a scikit-learn model, a tensorflow model or a pytorch model.\n- ``preprocess``: The preprocessing function converting the raw inputs (A `Tabular` instance) into the inputs of ``model``.\n- ``postprocess`` (optional): The postprocessing function transforming the outputs of ``model`` to a\n  user-specific form, e.g., the predicted probability for each class. The output of `postprocess` should be a numpy array.\n- ``mode``: The task type, e.g., \"classification\" or \"regression\".\n\nThe preprocessing function takes a `Tabular` instance as its input and outputs the processed features that\nthe ML model consumes. In this example, we simply call ``transformer.transform``. If you use some customized transforms \non pandas dataframes, the preprocess function has this format: `lambda z: some_transform(z.to_pd())`. If the output of ``model``\nis not a numpy array, ``postprocess`` needs to be set to convert it into a numpy array.\n\n```python\nfrom omnixai.explainers.tabular import TabularExplainer\n# Initialize a TabularExplainer\nexplainer = TabularExplainer(\n  explainers=[\"lime\", \"shap\", \"mace\", \"pdp\", \"ale\"], # The explainers to apply\n  mode=\"classification\",                             # The task type\n  data=train_data,                                   # The data for initializing the explainers\n  model=model,                                       # The ML model to explain\n  preprocess=lambda z: transformer.transform(z),     # Converts raw features into the model inputs\n  params={\n     \"mace\": {\"ignored_features\": [\"Sex\", \"Race\", \"Relationship\", \"Capital Loss\"]}\n  }                                                  # Additional parameters\n)\n```\n\nIn this example, LIME, SHAP and MACE generate local explanations while PDP (partial dependence plot)\ngenerates global explanations. ``explainer.explain`` returns the local explanations generated by the\nthree methods given the test instances, and ``explainer.explain_global`` returns the global explanations\ngenerated by PDP. `TabularExplainer` hides all the details behind the explainers, so we can simply call\nthese two methods to generate explanations.\n\n```python\n# Generate explanations\ntest_instances = test_data[:5]\nlocal_explanations = explainer.explain(X=test_instances)\nglobal_explanations = explainer.explain_global(\n    params={\"pdp\": {\"features\": [\"Age\", \"Education-Num\", \"Capital Gain\",\n                                 \"Capital Loss\", \"Hours per week\", \"Education\",\n                                 \"Marital Status\", \"Occupation\"]}}\n)\n```\n\nSimilarly, we create a `PredictionAnalyzer` for computing performance metrics for this classification task. \nTo initialize `PredictionAnalyzer`, the following parameters need to be set:\n\n- `mode`: The task type, e.g., \"classification\" or \"regression\".\n- `test_data`: The test dataset, which should be a `Tabular` instance.\n- `test_targets`: The test labels or targets. For classification, ``test_targets`` should be integers \n  (processed by a LabelEncoder) and match the class probabilities returned by the ML model.\n- `preprocess`: The preprocessing function converting the raw data (a `Tabular` instance) into the inputs of `model`.\n- `postprocess` (optional): The postprocessing function transforming the outputs of ``model`` to a user-specific form, \n  e.g., the predicted probability for each class. The output of `postprocess` should be a numpy array.\n\n```python\nfrom omnixai.explainers.prediction import PredictionAnalyzer\n\nanalyzer = PredictionAnalyzer(\n    mode=\"classification\",\n    test_data=test_data,                           # The test dataset (a `Tabular` instance)\n    test_targets=test_labels,                      # The test labels (a numpy array)\n    model=model,                                   # The ML model\n    preprocess=lambda z: transformer.transform(z)  # Converts raw features into the model inputs\n)\nprediction_explanations = analyzer.explain()\n```\n\nGiven the generated explanations, we can launch a dashboard (a Dash app) for visualization by setting the test\ninstance, the local explanations, the global explanations, the prediction metrics, the class names, and additional\nparameters for visualization (optional). If you want \"what-if\" analysis, you can set the ``explainer`` parameter\nwhen initializing the dashboard. For \"what-if\" analysis, OmniXAI also allows you to set a second explainer\nif you want to compare different models.\n\n```python\nfrom omnixai.visualization.dashboard import Dashboard\n# Launch a dashboard for visualization\ndashboard = Dashboard(\n   instances=test_instances,                        # The instances to explain\n   local_explanations=local_explanations,           # Set the local explanations\n   global_explanations=global_explanations,         # Set the global explanations\n   prediction_explanations=prediction_explanations, # Set the prediction metrics\n   class_names=class_names,                         # Set class names\n   explainer=explainer                              # The created TabularExplainer for what if analysis\n)\ndashboard.show()                                    # Launch the dashboard\n```\n\nAfter opening the Dash app in the browser, we will see a dashboard showing the explanations:\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_598137252b3e.gif)\n\nYou can also use the GPT explainer to generate explanations in text for tabular models:\n\n```python\nexplainer = TabularExplainer(\n  explainers=[\"gpt\"],                                # The GPT explainer to apply\n  mode=\"classification\",                             # The task type\n  data=train_data,                                   # The data for initializing the explainers\n  model=model,                                       # The ML model to explain\n  preprocess=lambda z: transformer.transform(z),     # Converts raw features into the model inputs\n  params={\n     \"gpt\": {\"apikey\": \"xxxx\"}\n  }                                                  # Set the OpenAI API KEY\n)\nlocal_explanations = explainer.explain(X=test_instances)\n```\n\nFor vision tasks, the same interface is used to create explainers and generate explanations. \nLet's take an image classification model as an example.\n\n```python\nfrom omnixai.explainers.vision import VisionExplainer\nfrom omnixai.visualization.dashboard import Dashboard\n\nexplainer = VisionExplainer(\n    explainers=[\"gradcam\", \"lime\", \"ig\", \"ce\", \"feature_visualization\"],\n    mode=\"classification\",\n    model=model,                   # An image classification model, e.g., ResNet50\n    preprocess=preprocess,         # The preprocessing function\n    postprocess=postprocess,       # The postprocessing function\n    params={\n        # Set the target layer for GradCAM\n        \"gradcam\": {\"target_layer\": model.layer4[-1]},\n        # Set the objective for feature visualization\n        \"feature_visualization\": \n          {\"objectives\": [{\"layer\": model.layer4[-3], \"type\": \"channel\", \"index\": list(range(6))}]}\n    },\n)\n# Generate explanations of GradCAM, LIME, IG and CE\nlocal_explanations = explainer.explain(test_img)\n# Generate explanations of feature visualization\nglobal_explanations = explainer.explain_global()\n# Launch the dashboard\ndashboard = Dashboard(\n    instances=test_img,\n    local_explanations=local_explanations,\n    global_explanations=global_explanations\n)\ndashboard.show()\n```\n\nThe following figure shows the dashboard of these explanations:\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_8badba3da314.gif)\n\nFor NLP tasks and time-series forecasting\u002Fanomaly detection, OmniXAI also provides the same interface\nto generate and visualize explanations. This figure shows a dashboard example of text classification\nand time-series anomaly detection:\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_397778cba7fa.gif)\n\n## Deployment\n\nThe explainers in OmniXAI can be easily deployed via [BentoML](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FBentoML). \nBentoML is a popular open-source unified model serving framework, supporting multiple platforms including\nAWS, GCP, Heroku, etc. We implemented the BentoML-format interfaces for OmniXAI so that users only need\nfew lines of code to deploy their selected explainers. \n\nLet's take the income prediction task as an example. Given the trained model and the initialized explainer, \nyou only need to save the explainer in the BentoML local model store:\n\n```python\nfrom omnixai.explainers.tabular import TabularExplainer\nfrom omnixai.deployment.bentoml.omnixai import save_model\n\nexplainer = TabularExplainer(\n  explainers=[\"lime\", \"shap\", \"mace\", \"pdp\", \"ale\"],\n  mode=\"classification\",\n  data=train_data,\n  model=model,\n  preprocess=lambda z: transformer.transform(z),\n  params={\n     \"mace\": {\"ignored_features\": [\"Sex\", \"Race\", \"Relationship\", \"Capital Loss\"]}\n  }\n)\nsave_model(\"tabular_explainer\", explainer)\n```\n\nAnd then create a file (e.g., service.py) for the ML service code:\n\n```python\nfrom omnixai.deployment.bentoml.omnixai import init_service\n\nsvc = init_service(\n    model_tag=\"tabular_explainer:latest\",\n    task_type=\"tabular\",\n    service_name=\"tabular_explainer\"\n)\n```\n\nThe `init_service` function defines two API endpoints, i.e., `\u002Fpredict` for model predictions and `\u002Fexplain` for\ngenerating explanations. You can start an API server locally to test the service code above:\n\n```python\nbentoml serve service:svc --reload\n```\n\nThe endpoints can be accessed locally:\n\n```python\nimport requests\nfrom requests_toolbelt.multipart.encoder import MultipartEncoder\n\ndata = '[\"39\", \"State-gov\", \"77516\", \"Bachelors\", \"13\", \"Never-married\", ' \\\n       '\"Adm-clerical\", \"Not-in-family\", \"White\", \"Male\", \"2174\", \"0\", \"40\", \"United-States\"]'\n\n# Test the prediction endpoint\nprediction = requests.post(\n    \"http:\u002F\u002F0.0.0.0:3000\u002Fpredict\",\n    headers={\"content-type\": \"application\u002Fjson\"},\n    data=data\n).text\n\n# Test the explanation endpoint\nm = MultipartEncoder(\n    fields={\n        \"data\": data,\n        \"params\": '{\"lime\": {\"y\": [0]}}',\n    }\n)\nresult = requests.post(\n    \"http:\u002F\u002F0.0.0.0:3000\u002Fexplain\",\n    headers={\"Content-Type\": m.content_type},\n    data=m\n).text\n\n# Parse the results\nfrom omnixai.explainers.base import AutoExplainerBase\nexp = AutoExplainerBase.parse_explanations_from_json(result)\nfor name, explanation in exp.items():\n    explanation.ipython_plot()\n```\n\nYou can build Bento for deployment by following the steps shown in the \n[BentoML repo](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FBentoML#how-it-works). For more examples, please\ncheck [Tabular](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Ftabular), \n[Vision](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Fvision), \n[NLP](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Fnlp).\n\n## How to Contribute\n\nWe welcome the contribution from the open-source community to improve the library!\n\nTo add a new explanation method\u002Ffeature into the library, please follow the template and steps demonstrated in this \n[documentation](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Fomnixai.html#how-to-contribute).\n\n## Technical Report and Citing OmniXAI\nYou can find more details in our technical report: [https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612)\n\nIf you're using OmniXAI in your research or applications, please cite using this BibTeX:\n```\n@article{wenzhuo2022-omnixai,\n  author    = {Wenzhuo Yang and Hung Le and Silvio Savarese and Steven Hoi},\n  title     = {OmniXAI: A Library for Explainable AI},\n  year      = {2022},\n  doi       = {10.48550\u002FARXIV.2206.01612},\n  url       = {https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612},\n  archivePrefix = {arXiv},\n  eprint    = {206.01612},\n}\n```\n\n## Contact Us\nIf you have any questions, comments or suggestions, please do not hesitate to contact us at omnixai@salesforce.com.\n\n## License\n[BSD 3-Clause License](LICENSE)\n","\u003Cp align=\"center\">\n    \u003Cbr>\n    \u003Cimg src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_ab44c7aac341.png\" width=\"400\"\u002F>\n    \u003Cbr>\n\u003Cp>\n\n# OmniXAI：可解释人工智能库\n\u003Cdiv align=\"center\">\n  \u003Ca href=\"#\">\n  \u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.7, 3.8, 3.9, 3.10-blue\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fomnixai\">\n  \u003Cimg alt=\"PyPI\" src=\"https:\u002F\u002Fimg.shields.io\u002Fpypi\u002Fv\u002Fomnixai.svg\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\">\n  \u003Cimg alt=\"文档\" src=\"https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Factions\u002Fworkflows\u002Fdocs.yml\u002Fbadge.svg\"\u002F>\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpepy.tech\u002Fproject\u002Fomnixai\">\n  \u003Cimg alt=\"下载量\" src=\"https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_7ae11847d0dd.png\">\n  \u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612\">\n  \u003Cimg alt=\"DOI\" src=\"https:\u002F\u002Fzenodo.org\u002Fbadge\u002FDOI\u002F10.48550\u002FARXIV.2206.01612.svg\"\u002F>\n  \u003C\u002Fa>\n\u003C\u002Fdiv>\n\n## 目录\n1. [简介](#introduction)\n2. [安装](#installation)\n3. [快速入门](#getting-started)\n4. [文档](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html)\n5. [教程](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html)\n6. [部署](#deployment)\n7. [仪表板演示](https:\u002F\u002Fomnixai-24e10803fd23.herokuapp.com\u002F)\n8. [如何贡献](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Fomnixai.html#how-to-contribute)\n9. [技术报告与引用 OmniXAI](#technical-report-and-citing-omnixai)\n\n## 最新动态\n\n最新版本引入了一个实验性的 GPT 解释器。该解释器利用 SHAP 和 MACE 的输出结果，为 ChatGPT 构建输入提示。随后，ChatGPT 分析这些结果并生成相应的解释，帮助开发者更清晰地理解模型预测背后的逻辑。\n\n## 简介\n\nOmniXAI（全栈可解释人工智能的简称）是一个用于可解释人工智能（XAI）的 Python 机器学习库，提供全方位的可解释性和可解释性机器学习能力，以解决实际应用中机器学习模型决策解释方面的诸多痛点。OmniXAI 致力于成为一站式综合库，让数据科学家、机器学习研究人员和从业者能够轻松实现可解释人工智能，适用于不同类型的数据、模型以及不同机器学习阶段的各种解释方法：\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_44155682279e.png)\n\nOmniXAI 包含一个丰富的解释方法家族，并通过统一的接口进行集成，支持多种数据类型（表格数据、图像、文本、时间序列）、多种机器学习模型（Scikit-learn 中的传统机器学习模型以及 PyTorch\u002FTensorFlow 中的深度学习模型），以及一系列多样化的解释方法，包括“模型特定”和“模型无关”的方法（如特征归因解释、反事实解释、基于梯度的解释、特征可视化等）。对于实践者而言，OmniXAI 提供了一个易于使用的统一接口，只需编写几行代码即可为其应用生成解释；同时，还配备了一个 GUI 仪表板，用于可视化展示，从而获得对决策的更多洞察。\n\n下表展示了我们库中支持的解释方法和功能。未来我们将继续完善此库，使其更加全面。\n\n|          方法           |  模型类型   | 解释类型 | EDA | 表格 | 图像 | 文本 | 时间序列 | \n:-------------------------:|:-------------:|:----------------:|:---:|:-------:|:-----:| :---: | :---:\n|     特征分析      |      NA       |      全局      |  ✅  |         |       |      |      |\n|     特征选择     |      NA       |      全局      |  ✅  |         |       |      |      |\n|    预测指标     |   黑盒   |      全局      |     |    ✅    |   ✅   | ✅   |  ✅  |\n|       偏差指标        |   黑盒   |      全局      |     |    ✅    |       |      |      |\n| 部分依赖图  |   黑盒   |      全局      |     |    ✅    |       |      |      |\n| 累积局部效应 |   黑盒   |      全局      |     |    ✅    |       |      |      |\n|   敏感性分析    |   黑盒   |      全局      |     |    ✅    |       |      |      |\n|  排列重要性解释  |   黑盒   |      全局      |     |    ✅    |       |      |      |\n|   特征可视化   |  Torch 或 TF  |      全局      |     |         |   ✅   |      |      |\n|       特征图        |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|       GPT 解释器       | 黑盒     |     局部        |     |    ✅    |       |      |      |\n|           LIME            |   黑盒   |      局部       |     |    ✅    |   ✅   | ✅   |      |\n|           SHAP            |  黑盒*   |      局部       |     |    ✅    |   ✅   | ✅   |  ✅  |\n|          如果-则          |   黑盒   |      局部       |     |    ✅    |       |      |     |\n|    积分梯度    |  Torch 或 TF  |      局部       |     |    ✅    |   ✅   | ✅   |      |\n|      反事实       |  黑盒*   |      局部       |     |    ✅    |   ✅   | ✅   |  ✅  |\n|  对比解释  |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|   Grad-CAM、Grad-CAM++    |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|         Score-CAM         |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|         Layer-CAM         |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|      平滑梯度      |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|  引导式反向传播   |  Torch 或 TF  |      局部       |     |         |   ✅   |      |      |\n|    学习解释    |   黑盒   |      局部       |     |    ✅    |   ✅   | ✅   |      |\n|       线性模型       | 线性模型 | 全局和局部 |     |    ✅    |       |      |      |\n|        决策树模型        |  决策树模型  | 全局和局部 |     |    ✅    |       |      |      |\n\n*SHAP* 支持黑盒模型处理表格数据，支持 PyTorch\u002FTensorFlow 模型处理图像数据，支持 Transformer 模型处理文本数据。*反事实*支持黑盒模型处理表格、文本和时间序列数据，同时也支持 PyTorch\u002FTensorFlow 模型处理图像数据。\n\n此[表格](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html#comparison-with-competitors)展示了我们的工具包\u002F库与其他现有 XAI 工具包\u002F库在文献中的比较。\n\n**OmniXAI 还集成了 ChatGPT，可根据表格数据集上的分类或回归模型生成纯文本解释。** 生成的结果可能并非 100% 准确，但仍然值得一试（我们将持续优化输入提示）。\n\n## 安装\n\n您可以通过运行 `pip install omnixai` 从 PyPI 安装 `omnixai`。您也可以通过克隆 OmniXAI 仓库、进入根目录并运行 `pip install .` 来从源代码安装，或者使用 `pip install -e .` 以可编辑模式安装。此外，您可以安装额外的依赖项：\n\n- **用于绘图与可视化**：运行 `pip install omnixai[plot]`，或从仓库根目录运行 `pip install .[plot]`。\n- **用于视觉任务**：运行 `pip install omnixai[vision]`，或从仓库根目录运行 `pip install .[vision]`。\n- **用于 NLP 任务**：运行 `pip install omnixai[nlp]`，或从仓库根目录运行 `pip install .[nlp]`。\n- **安装所有依赖项**：运行 `pip install omnixai[all]`，或从仓库根目录运行 `pip install .[all]`。\n\n## 快速入门\n\n有关示例代码和库的介绍，请参阅 [tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html) 中的 Jupyter 笔记本，以及此处的引导式教程 [here](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Findex.html)。\n\n一些示例：\n1. [表格分类](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular_classification.ipynb)\n2. [表格回归](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular_regression.ipynb)\n3. [图像分类](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision.ipynb)\n4. [文本分类](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fnlp_imdb.ipynb)\n5. [时间序列异常检测](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftimeseries.ipynb)\n6. [视觉-语言任务](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Fgradcam_vlm.ipynb)\n7. [排序任务](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular\u002Franking.ipynb)\n8. [特征可视化](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Ffeature_visualization_torch.ipynb)\n9. [检查特征图](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Fvision\u002Ffeature_map_torch.ipynb)\n10. [用于表格数据的 GPT 解释器](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fblob\u002Fmain\u002Ftutorials\u002Ftabular\u002Fgpt.ipynb)\n\n要开始使用，我们建议您参考 [tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html) 中的链接教程。通常，我们推荐在处理表格数据、视觉任务、NLP 和时间序列任务时分别使用 `TabularExplainer`、`VisionExplainer`、`NLPExplainer` 和 `TimeseriesExplainer`；而对于特征分析和预测结果分析，则可以使用 `DataAnalyzer` 和 `PredictionAnalyzer`。这些类充当 OmniXAI 中支持的各个解释器的工厂，提供更简单的接口来生成多种解释。要生成解释，您只需指定：\n\n- **待解释的机器学习模型**：例如，scikit-learn 模型、TensorFlow 模型、PyTorch 模型或黑盒预测函数。\n- **预处理函数**：即将原始输入特征转换为模型输入。\n- **后处理函数（可选）**：例如，将模型输出转换为类别概率。\n- **要应用的解释方法**：例如，SHAP、MACE、Grad-CAM 等。\n\n除了使用这些类之外，您还可以直接创建 `omnixai.explainers` 包中定义的单个解释器，例如 `ShapTabular`、 `GradCAM`、`IntegratedGradient` 或 `FeatureVisualizer`。\n\n让我们以收入预测任务为例。\n此示例中使用的 [数据集](https:\u002F\u002Farchive.ics.uci.edu\u002Fml\u002Fdatasets\u002Fadult) 用于收入预测。我们建议使用 `Tabular` 数据类来表示表格数据集。要根据 Pandas DataFrame 创建一个 `Tabular` 实例，您需要指定 DataFrame、分类特征名称（如果存在）以及目标\u002F标签列名称（如果存在）。\n\n```python\nfrom omnixai.data.tabular import Tabular\n# 加载数据集\nfeature_names = [\n   \"年龄\", \"工作类型\", \"fnlwgt\", \"教育\",\n   \"受教育年限\", \"婚姻状况\", \"职业\",\n   \"关系\", \"种族\", \"性别\", \"资本收益\",\n   \"资本损失\", \"每周工时\", \"国籍\", \"label\"\n]\ndf = pd.DataFrame(\n  np.genfromtxt('adult.data', delimiter=', ', dtype=str),\n  columns=feature_names\n)\ntabular_data = Tabular(\n   df,\n   categorical_columns=[feature_names[i] for i in [1, 3, 5, 6, 7, 8, 9, 13]],\n   target_column='label'\n)\n```\n\n`omnixai.preprocessing` 包提供了多个适用于 `Tabular` 实例的实用预处理函数。`TabularTransform` 是一种专为处理表格数据而设计的特殊转换工具。默认情况下，它会将分类特征转换为独热编码，并保留连续值特征。`TabularTransform` 的 `transform` 方法会将 `Tabular` 实例转换为 NumPy 数组。如果 `Tabular` 实例包含目标\u002F标签列，则 NumPy 数组的最后一列即为目标\u002F标签。您也可以不使用 `TabularTransform`，而是应用自定义的预处理函数。完成数据预处理后，让我们为该任务训练一个 XGBoost 分类器。\n\n```python\nfrom omnixai.preprocessing.tabular import TabularTransform\n# 数据预处理\ntransformer = TabularTransform().fit(tabular_data)\nclass_names = transformer.class_names\nx = transformer.transform(tabular_data)\n# 将数据分为训练集和测试集\ntrain, test, train_labels, test_labels = \\\n    sklearn.model_selection.train_test_split(x[:, :-1], x[:, -1], train_size=0.80)\n# 训练 XGBoost 模型（转换后，`x` 的最后一列是标签列）\nmodel = xgboost.XGBClassifier(n_estimators=300, max_depth=5)\nmodel.fit(train, train_labels)\n\n# 将转换后的数据重新转换为 Tabular 实例\ntrain_data = transformer.invert(train)\ntest_data = transformer.invert(test)\n```\n\n要初始化 `TabularExplainer`，需要设置以下参数：\n\n- ``explainers``：要应用的解释器名称列表，例如 [\"lime\", \"shap\", \"mace\", \"pdp\"]。\n- ``data``：用于初始化解释器的数据。``data`` 是用于训练机器学习模型的训练数据集。如果训练数据集过大，可以通过应用 `omnixai.sampler.tabular.Sampler.subsample` 将其缩减为子集。\n- ``model``：要解释的机器学习模型，例如 scikit-learn 模型、tensorflow 模型或 pytorch 模型。\n- ``preprocess``：预处理函数，将原始输入（一个 `Tabular` 实例）转换为 ``model`` 的输入。\n- ``postprocess``（可选）：后处理函数，将 ``model`` 的输出转换为用户特定的形式，例如每个类别的预测概率。`postprocess` 的输出应为 numpy 数组。\n- ``mode``：任务类型，例如 \"classification\" 或 \"regression\"。\n\n预处理函数以 `Tabular` 实例作为输入，输出机器学习模型所使用的处理后的特征。在本示例中，我们直接调用 ``transformer.transform``。如果您对 pandas 数据框使用自定义转换，则预处理函数的格式为：`lambda z: some_transform(z.to_pd())`。如果 ``model`` 的输出不是 numpy 数组，则需要设置 ``postprocess`` 以将其转换为 numpy 数组。\n\n```python\nfrom omnixai.explainers.tabular import TabularExplainer\n# 初始化一个 TabularExplainer\nexplainer = TabularExplainer(\n  explainers=[\"lime\", \"shap\", \"mace\", \"pdp\", \"ale\"], # 要应用的解释器\n  mode=\"classification\",                             # 任务类型\n  data=train_data,                                   # 用于初始化解释器的数据\n  model=model,                                       # 要解释的机器学习模型\n  preprocess=lambda z: transformer.transform(z),     # 将原始特征转换为模型输入\n  params={\n     \"mace\": {\"ignored_features\": [\"Sex\", \"Race\", \"Relationship\", \"Capital Loss\"]}\n  }                                                  # 额外参数\n)\n```\n\n在本示例中，LIME、SHAP 和 MACE 生成局部解释，而 PDP（部分依赖图）生成全局解释。``explainer.explain`` 根据测试实例返回这三种方法生成的局部解释，而 ``explainer.explain_global`` 返回由 PDP 生成的全局解释。`TabularExplainer` 将所有解释器背后的细节封装起来，因此我们可以直接调用这两个方法来生成解释。\n\n```python\n# 生成解释\ntest_instances = test_data[:5]\nlocal_explanations = explainer.explain(X=test_instances)\nglobal_explanations = explainer.explain_global(\n    params={\"pdp\": {\"features\": [\"Age\", \"Education-Num\", \"Capital Gain\",\n                                 \"Capital Loss\", \"Hours per week\", \"Education\",\n                                 \"Marital Status\", \"Occupation\"]}}\n)\n```\n\n同样地，我们创建了一个 `PredictionAnalyzer` 来计算该分类任务的性能指标。要初始化 `PredictionAnalyzer`，需要设置以下参数：\n\n- `mode`：任务类型，例如 \"classification\" 或 \"regression\"。\n- `test_data`：测试数据集，应为 `Tabular` 实例。\n- `test_targets`：测试标签或目标值。对于分类任务，``test_targets`` 应为整数（经过 LabelEncoder 处理），并与机器学习模型返回的类别概率相匹配。\n- `preprocess`：预处理函数，将原始数据（一个 `Tabular` 实例）转换为 `model` 的输入。\n- `postprocess`（可选）：后处理函数，将 ``model`` 的输出转换为用户特定的形式，例如每个类别的预测概率。`postprocess` 的输出应为 numpy 数组。\n\n```python\nfrom omnixai.explainers.prediction import PredictionAnalyzer\n\nanalyzer = PredictionAnalyzer(\n    mode=\"classification\",\n    test_data=test_data,                           # 测试数据集（一个 `Tabular` 实例）\n    test_targets=test_labels,                      # 测试标签（一个 numpy 数组）\n    model=model,                                   # 机器学习模型\n    preprocess=lambda z: transformer.transform(z)  # 将原始特征转换为模型输入\n)\nprediction_explanations = analyzer.explain()\n```\n\n根据生成的解释，我们可以通过设置测试实例、局部解释、全局解释、预测指标、类别名称以及用于可视化的额外参数（可选），启动一个仪表板（Dash 应用程序）进行可视化。如果您想要进行“假设分析”，可以在初始化仪表板时设置 ``explainer`` 参数。对于“假设分析”，OmniXAI 还允许您设置第二个解释器，以便比较不同的模型。\n\n```python\nfrom omnixai.visualization.dashboard import Dashboard\n\n# 启动可视化仪表板\ndashboard = Dashboard(\n   instances=test_instances,                        # 需要解释的实例\n   local_explanations=local_explanations,           # 设置局部解释\n   global_explanations=global_explanations,         # 设置全局解释\n   prediction_explanations=prediction_explanations, # 设置预测指标\n   class_names=class_names,                         # 设置类别名称\n   explainer=explainer                              # 用于假设分析的已创建 TabularExplainer\n)\ndashboard.show()                                    # 启动仪表板\n```\n\n在浏览器中打开 Dash 应用后，我们将看到一个显示解释结果的仪表板：\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_598137252b3e.gif)\n\n你还可以使用 GPT 解释器为表格型模型生成文本形式的解释：\n\n```python\nexplainer = TabularExplainer(\n  explainers=[\"gpt\"],                                # 要应用的 GPT 解释器\n  mode=\"classification\",                             # 任务类型\n  data=train_data,                                   # 用于初始化解释器的数据\n  model=model,                                       # 需要解释的机器学习模型\n  preprocess=lambda z: transformer.transform(z),     # 将原始特征转换为模型输入\n  params={\n     \"gpt\": {\"apikey\": \"xxxx\"}\n  }                                                  # 设置 OpenAI API 密钥\n)\nlocal_explanations = explainer.explain(X=test_instances)\n```\n\n对于视觉任务，同样使用该接口来创建解释器并生成解释。我们以图像分类模型为例。\n\n```python\nfrom omnixai.explainers.vision import VisionExplainer\nfrom omnixai.visualization.dashboard import Dashboard\n\nexplainer = VisionExplainer(\n    explainers=[\"gradcam\", \"lime\", \"ig\", \"ce\", \"feature_visualization\"],\n    mode=\"classification\",\n    model=model,                   # 图像分类模型，例如 ResNet50\n    preprocess=preprocess,         # 预处理函数\n    postprocess=postprocess,       # 后处理函数\n    params={\n        # 设置 GradCAM 的目标层\n        \"gradcam\": {\"target_layer\": model.layer4[-1]},\n        # 设置特征可视化的目标\n        \"feature_visualization\": \n          {\"objectives\": [{\"layer\": model.layer4[-3], \"type\": \"channel\", \"index\": list(range(6))}]}\n    },\n)\n# 生成 GradCAM、LIME、IG 和 CE 的解释\nlocal_explanations = explainer.explain(test_img)\n# 生成特征可视化的全局解释\nglobal_explanations = explainer.explain_global()\n# 启动仪表板\ndashboard = Dashboard(\n    instances=test_img,\n    local_explanations=local_explanations,\n    global_explanations=global_explanations\n)\ndashboard.show()\n```\n\n下图展示了这些解释的仪表板：\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_8badba3da314.gif)\n\n对于 NLP 任务以及时间序列预测\u002F异常检测，OmniXAI 同样提供了相同的接口来生成和可视化解释。下图展示了文本分类和时间序列异常检测的仪表板示例：\n![alt text](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_readme_397778cba7fa.gif)\n\n## 部署\n\nOmniXAI 中的解释器可以通过 [BentoML](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FBentoML) 轻松部署。BentoML 是一个流行的开源统一模型服务框架，支持包括 AWS、GCP、Heroku 等在内的多个平台。我们为 OmniXAI 实现了 BentoML 格式的接口，因此用户只需几行代码即可部署他们选择的解释器。\n\n以收入预测任务为例。给定训练好的模型和已初始化的解释器，你只需将解释器保存到 BentoML 的本地模型仓库中：\n\n```python\nfrom omnixai.explainers.tabular import TabularExplainer\nfrom omnixai.deployment.bentoml.omnixai import save_model\n\nexplainer = TabularExplainer(\n  explainers=[\"lime\", \"shap\", \"mace\", \"pdp\", \"ale\"],\n  mode=\"classification\",\n  data=train_data,\n  model=model,\n  preprocess=lambda z: transformer.transform(z),\n  params={\n     \"mace\": {\"ignored_features\": [\"Sex\", \"Race\", \"Relationship\", \"Capital Loss\"]}\n  }\n)\nsave_model(\"tabular_explainer\", explainer)\n```\n\n然后创建一个文件（例如 service.py）用于 ML 服务代码：\n\n```python\nfrom omnixai.deployment.bentoml.omnixai import init_service\n\nsvc = init_service(\n    model_tag=\"tabular_explainer:latest\",\n    task_type=\"tabular\",\n    service_name=\"tabular_explainer\"\n)\n```\n\n`init_service` 函数定义了两个 API 端点，即 `\u002Fpredict` 用于模型预测，以及 `\u002Fexplain` 用于生成解释。你可以在本地启动一个 API 服务器来测试上述服务代码：\n\n```python\nbentoml serve service:svc --reload\n```\n\n这些端点可以在本地访问：\n\n```python\nimport requests\nfrom requests_toolbelt.multipart.encoder import MultipartEncoder\n\ndata = '[\"39\", \"State-gov\", \"77516\", \"Bachelors\", \"13\", \"Never-married\", ' \\\n       '\"Adm-clerical\", \"Not-in-family\", \"White\", \"Male\", \"2174\", \"0\", \"40\", \"United-States\"]'\n\n# 测试预测端点\nprediction = requests.post(\n    \"http:\u002F\u002F0.0.0.0:3000\u002Fpredict\",\n    headers={\"content-type\": \"application\u002Fjson\"},\n    data=data\n).text\n\n# 测试解释端点\nm = MultipartEncoder(\n    fields={\n        \"data\": data,\n        \"params\": '{\"lime\": {\"y\": [0]}}',\n    }\n)\nresult = requests.post(\n    \"http:\u002F\u002F0.0.0.0:3000\u002Fexplain\",\n    headers={\"Content-Type\": m.content_type},\n    data=m\n).text\n\n# 解析结果\nfrom omnixai.explainers.base import AutoExplainerBase\nexp = AutoExplainerBase.parse_explanations_from_json(result)\nfor name, explanation in exp.items():\n    explanation.ipython_plot()\n```\n\n你可以按照 [BentoML 仓库](https:\u002F\u002Fgithub.com\u002Fbentoml\u002FBentoML#how-it-works) 中所示的步骤构建 Bento 进行部署。更多示例请参阅 [Tabular](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Ftabular)、[Vision](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Fvision) 和 [NLP](https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Fomnixai\u002Ftests\u002Fdeployment\u002Fbentoml\u002Fnlp) 目录。\n\n## 如何贡献\n\n我们欢迎开源社区为改进本库做出贡献！\n\n如需向本库添加新的解释方法或功能，请遵循本 [文档](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Fomnixai.html#how-to-contribute) 中展示的模板和步骤。\n\n## 技术报告与 OmniXAI 的引用\n您可以在我们的技术报告中找到更多详细信息：[https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612](https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612)\n\n如果您在研究或应用中使用 OmniXAI，请使用以下 BibTeX 格式进行引用：\n```\n@article{wenzhuo2022-omnixai,\n  author    = {Wenzhuo Yang 和 Hung Le 和 Silvio Savarese 和 Steven Hoi},\n  title     = {OmniXAI：可解释人工智能库},\n  year      = {2022},\n  doi       = {10.48550\u002FARXIV.2206.01612},\n  url       = {https:\u002F\u002Farxiv.org\u002Fabs\u002F2206.01612},\n  archivePrefix = {arXiv},\n  eprint    = {206.01612},\n}\n```\n\n## 联系我们\n如果您有任何问题、意见或建议，请随时通过 omnixai@salesforce.com 与我们联系。\n\n## 许可证\n[BSD 3-Clause 许可证](LICENSE)","# OmniXAI 快速上手指南\n\nOmniXAI 是一个全面的可解释人工智能（XAI）Python 库，旨在为数据科学家和机器学习从业者提供“一站式”解决方案。它支持表格、图像、文本和时间序列等多种数据类型，兼容 Scikit-learn、PyTorch 和 TensorFlow 模型，并集成了 SHAP、LIME、Grad-CAM 以及最新的 GPT 解释器等多种解释方法。\n\n## 环境准备\n\n在开始之前，请确保您的开发环境满足以下要求：\n\n*   **操作系统**：Linux, macOS, 或 Windows\n*   **Python 版本**：3.7, 3.8, 3.9, 或 3.10\n*   **前置依赖**：建议预先安装 `pip` 包管理工具。根据您的任务类型（如视觉或 NLP），可能需要额外的系统级依赖（如 OpenCV 相关库），通常通过下方的可选安装命令自动处理。\n\n## 安装步骤\n\n您可以通过 PyPI 直接安装核心库，或根据具体任务安装包含额外依赖的版本。\n\n### 1. 安装核心库\n```bash\npip install omnixai\n```\n\n### 2. 按需安装扩展功能\n为了获得完整的绘图、视觉或自然语言处理能力，推荐安装以下扩展：\n\n*   **绘图与可视化支持**：\n    ```bash\n    pip install omnixai[plot]\n    ```\n*   **计算机视觉任务支持**：\n    ```bash\n    pip install omnixai[vision]\n    ```\n*   **自然语言处理 (NLP) 任务支持**：\n    ```bash\n    pip install omnixai[nlp]\n    ```\n*   **安装所有依赖（推荐）**：\n    ```bash\n    pip install omnixai[all]\n    ```\n\n> **提示**：国内用户若遇到下载速度慢的问题，可使用清华或阿里镜像源加速安装，例如：\n> `pip install omnixai[all] -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple`\n\n## 基本使用\n\nOmniXAI 提供了统一的接口类（如 `TabularExplainer`, `VisionExplainer` 等）来简化解释器的调用。以下以**表格数据分类任务**（收入预测）为例，展示最基础的使用流程。\n\n### 1. 数据加载与预处理\n首先，使用 `Tabular` 类加载数据，并定义分类特征和目标列。\n\n```python\nimport pandas as pd\nimport numpy as np\nfrom omnixai.data.tabular import Tabular\n\n# 加载数据集 (示例使用 adult 数据集)\nfeature_names = [\n   \"Age\", \"Workclass\", \"fnlwgt\", \"Education\",\n   \"Education-Num\", \"Marital Status\", \"Occupation\",\n   \"Relationship\", \"Race\", \"Sex\", \"Capital Gain\",\n   \"Capital Loss\", \"Hours per week\", \"Country\", \"label\"\n]\n\n# 模拟读取数据 (实际使用时请替换为真实文件路径)\ndf = pd.DataFrame(\n  np.genfromtxt('adult.data', delimiter=', ', dtype=str),\n  columns=feature_names\n)\n\n# 创建 Tabular 数据对象\ntabular_data = Tabular(\n   df,\n   categorical_columns=[feature_names[i] for i in [1, 3, 5, 6, 7, 8, 9, 13]],\n   target_column='label'\n)\n```\n\n### 2. 模型训练与解释器初始化\n假设您已经训练好了一个模型（如 XGBoost），接下来初始化 `TabularExplainer`。您需要指定模型、预处理函数（将原始数据转换为模型输入）以及要使用的解释方法（如 SHAP）。\n\n```python\nfrom omnixai.explainers.tabular import TabularExplainer\n\n# 假设 model 是已经训练好的 scikit-learn 或 xgboost 模型\n# def preprocess(x): 将原始数据转换为模型所需的 numpy 数组或 DataFrame\n# def postprocess(x): 将模型输出转换为概率 (可选)\n\nexplainer = TabularExplainer(\n    model=model,\n    train_data=tabular_data,\n    preprocess_function=preprocess,\n    postprocess_function=postprocess,\n    explainers=[\"shap\", \"lime\"] # 指定需要使用的解释方法\n)\n```\n\n### 3. 生成解释\n调用 `explain` 方法即可获取局部或全局解释结果。\n\n```python\n# 对特定样本进行局部解释\nexplanations = explainer.explain(\n    X=tabular_data[:5], # 取前 5 条数据进行解释\n    explanation_type=\"local\"\n)\n\n# 查看 SHAP 的解释结果\nshap_result = explanations[\"shap\"]\nprint(shap_result)\n```\n\n对于图像、文本或时间序列任务，只需将上述步骤中的 `TabularExplainer` 和 `Tabular` 数据类分别替换为 `VisionExplainer`\u002F`NLPExplainer`\u002F`TimeseriesExplainer` 及对应的数据类即可，接口逻辑保持一致。\n\n更多详细示例代码（包括图像分类、文本分析及 GPT 解释器用法），请参考官方 [Tutorials](https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html)。","某金融风控团队正在构建基于机器学习的信贷审批系统，急需向监管机构和业务方解释模型为何拒绝特定用户的贷款申请。\n\n### 没有 OmniXAI 时\n- **解释方法分散且割裂**：团队需分别调用 SHAP、LIME 等不同库处理表格数据，代码冗余且接口不统一，维护成本极高。\n- **多模态支持缺失**：当引入用户上传的收入证明（图像）或征信描述（文本）时，缺乏统一框架生成连贯的解释，导致多源数据决策成“黑盒”。\n- **沟通效率低下**：生成的特征重要性图表过于技术化，业务人员难以理解，无法向被拒客户清晰说明具体原因，易引发合规投诉。\n- **反事实分析困难**：难以快速计算“若用户收入增加多少即可获批”等反事实场景，限制了模型对用户的指导价值。\n\n### 使用 OmniXAI 后\n- **统一接口高效集成**：OmniXAI 提供标准化接口，一行代码即可切换多种解释算法，完美兼容 Scikit-learn 与 PyTorch 模型，开发效率提升 50%。\n- **全数据类型覆盖**：利用其内置能力，团队轻松实现了对表格、图像及文本数据的联合解释，确保复杂审批逻辑透明可见。\n- **自然语言智能解读**：借助最新的 GPT 解释器功能，OmniXAI 将复杂的 SHAP 值转化为通俗易懂的自然语言报告，直接用于客户通知，显著降低沟通门槛。\n- **交互式反事实推演**：通过内置的反事实解释模块，快速生成具体的改进建议（如“负债率降低 5% 即可通过），增强了模型的辅助决策能力。\n\nOmniXAI 通过一站式可解释性方案，将晦涩的模型决策转化为透明、可信且具行动指导意义的业务洞察。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fsalesforce_OmniXAI_59813725.gif","salesforce","Salesforce","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fsalesforce_6ff2d82a.png","Noteworthy Open Source projects made available by Salesforce. Available under Open Source or Creative Commons licensing. No warranty or support implied",null,"osscore@salesforce.com","https:\u002F\u002Fopensource.salesforce.com","https:\u002F\u002Fgithub.com\u002Fsalesforce",[81,85,89,93],{"name":82,"color":83,"percentage":84},"Jupyter Notebook","#DA5B0B",94.6,{"name":86,"color":87,"percentage":88},"Python","#3572A5",5.3,{"name":90,"color":91,"percentage":92},"CSS","#663399",0.1,{"name":94,"color":95,"percentage":96},"JavaScript","#f1e05a",0,966,106,"2026-03-31T04:25:00","BSD-3-Clause","","未说明（支持 PyTorch\u002FTensorFlow 模型，部分视觉解释方法如 Grad-CAM 可能需要 GPU，但无具体型号或显存要求）","未说明",{"notes":105,"python":106,"dependencies":107},"该库支持多种数据类型（表格、图像、文本、时间序列）和模型类型。可通过 pip 安装额外依赖包以支持特定任务：[plot] 用于可视化，[vision] 用于视觉任务，[nlp] 用于自然语言处理，[all] 安装所有依赖。最新版本包含实验性的 GPT 解释器，需配置 ChatGPT API。","3.7, 3.8, 3.9, 3.10",[108,109,110,111,112,113,114,115],"scikit-learn","pandas","numpy","torch","tensorflow","shap","lime","transformers (用于 GPT explainer)",[14],[118,119,120,121,122],"explainable-ai","explainable-ml","interpretable-machine-learning","machine-learning","explanation","2026-03-27T02:49:30.150509","2026-04-16T01:44:48.479384",[126,131,136,141,146,151],{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},35015,"在表格分类任务中使用 MACE 算法时出现 \"Illegal instruction (core dumped)\" 错误，如何解决？","该问题通常是因为 hnswlib 包与当前 CPU 不匹配导致的。解决方法是克隆 hnswlib 的源代码，然后使用 `pip install .` 进行重新安装，而不是直接使用 `pip install hnswlib` 安装预编译包。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F68",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},35016,"为什么使用 TabularTransform.transform() 后数据维度发生了变化（例如从 13 列变为 25 列）？","这通常是因为输入数据中存在重复的列名。建议直接使用 pandas DataFrame 创建 Tabular 实例，因为这样更直观：DataFrame 的列名即为特征列和目标列，values 即为数据值。请检查并修复数据中的重复列名问题。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F47",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},35017,"LIME 和 SHAP 解释结果中为何缺少部分原始特征？","这可能是由于算法内部的特征选择机制或参数设置导致的。可以通过配置解释器的参数字典来调整，例如在初始化时设置 `\"lime\": {\"kernel_width\": 3, \"feature_selection\": \u003C具体值>}` 来控制特征选择行为。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F59",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},35018,"在小数据集或模型性能较差时使用 MACE 报错 \"RuntimeError: Cannot return the results in a contigious 2D array\" 或 \"AttributeError: 'NoneType' object has no attribute 'to_pd'\"，如何处理？","这是由数据集过小或最近邻搜索失败引起的。临时解决方案是修改 `mace.py` 文件中的 `candidates, indices = self.recall.get_cf_features(x, desired_label)` 这一行，将其替换为一个直接返回所有特征值作为候选特征的函数。对于小数据集，这种简化处理是可行的。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F69",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},35019,"运行 NLP 教程（nlp.ipynb）耗时过长（超过 10 分钟），是否有优化方案？","该问题已知悉并计划在未来更新中优化。目前的临时解决方案可参考 Polyjuice 项目的相关讨论（https:\u002F\u002Fgithub.com\u002Ftongshuangwu\u002Fpolyjuice\u002Fissues\u002F10）以寻找加速运行的方法。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F21",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},35020,"无法运行 OmniXAI 的解释器，在哪里可以找到完整的使用示例和教程？","所有示例代码可在官方文档的应用章节找到：https:\u002F\u002Fopensource.salesforce.com\u002FOmniXAI\u002Flatest\u002Ftutorials.html#applications。此外，GitHub 仓库的 tutorials 目录（https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Ftree\u002Fmain\u002Ftutorials）也包含了针对表格、图像、文本和时间序列数据的完整示例。","https:\u002F\u002Fgithub.com\u002Fsalesforce\u002FOmniXAI\u002Fissues\u002F5",[157,162,167,172,177,182,187,192,197,202,207,212,217,222,227],{"id":158,"version":159,"summary_zh":160,"released_at":161},272387,"v1.3.2","更新 IPython 版本","2024-04-25T01:38:42",{"id":163,"version":164,"summary_zh":165,"released_at":166},272388,"v1.3.1","修复与 TabularTransform 中默认参数相关的问题。","2023-07-16T04:56:57",{"id":168,"version":169,"summary_zh":170,"released_at":171},272389,"v1.3.0","1. OmniXAI v1.3.0 新增了一个实验性的 GPT 解释器。该解释器利用 SHAP 和 MACE 生成的解释结果，构造用于 ChatGPT 的输入提示。随后，ChatGPT 对这些结果进行分析，并生成相应的解释文本，帮助开发者更清晰地理解模型预测背后的逻辑。  \n2. 修复了解释器和可视化模块中的一些小问题。  \n3. 更新了版权信息。","2023-05-27T06:15:13",{"id":173,"version":174,"summary_zh":175,"released_at":176},272390,"v1.2.5","1. 为表格数据添加假设分析功能，例如用户可以修改特征值并比较不同模型。  \n2. 修订可视化仪表板，以支持 Google Colab 笔记本。  \n3. MACE 现在可以在不使用 KNN 搜索的情况下生成反事实样本。该功能主要适用于小型数据集。","2023-02-08T06:56:30",{"id":178,"version":179,"summary_zh":180,"released_at":181},272391,"v1.2.4","1. 支持模型偏差分析  \n2. 修订文档  \n3. 修复 OmniXAI v1.2.3 中的一些 bug","2023-01-03T04:11:59",{"id":183,"version":184,"summary_zh":185,"released_at":186},272392,"v1.2.3","1. 添加全局 SHAP 特征重要性。 2. 添加置换特征重要性。 3. 添加基于 KNN 的反事实解释器。 4. 修订全局解释的仪表板图表。 5. 修复一些 bug 和界面问题。","2022-11-22T09:45:01",{"id":188,"version":189,"summary_zh":190,"released_at":191},272393,"v1.2.2","1. 支持将 TabularExplainer、VisionExplainer 和 NLPExplainer 部署到 BentoML。\n2. 为所有解释类支持 JSON 转换器。\n3. 修复在 Torch 版本大于 1.7 时特征可视化中的一个小 bug。","2022-10-25T10:00:17",{"id":193,"version":194,"summary_zh":195,"released_at":196},272394,"v1.2.1","1. 为特征可视化添加 FFT 预处理  \n2. 实现 ScoreCAM、LayerCAM、SmoothGrad 和 Guided Backpropagation  \n3. 修复一些小 bug。","2022-09-16T05:57:40",{"id":198,"version":199,"summary_zh":200,"released_at":201},272395,"v1.2.0","1. 支持视觉模型的特征可视化（基于优化的方法）。\r\n2. 允许在卷积神经网络模型中可视化特征图。\r\n3. 增加更多关于支持的解释器的教程。\r\n4. 修复排名类解释器中的一些错误。","2022-09-08T14:17:21",{"id":203,"version":204,"summary_zh":205,"released_at":206},272396,"v1.1.4","1. 修复 MACE 精细化模块中的一个 bug。  \n2. 为排序任务添加若干解释器，例如 ValidityRankingExplainer、PermutationRankingExplainer 和 MACEExplainer。  \n3. 为支持的解释器添加保存和加载功能。  \n4. 为 MACE 对抗性解释器添加基于强化学习的方法，例如在创建 MACE 解释器时设置 `method = \"rl\"`。","2022-08-25T12:50:34",{"id":208,"version":209,"summary_zh":210,"released_at":211},272397,"v1.1.3","1. Allow LIME and SHAP to compute feature importance scores for a subset of features.\r\n2. Resolve an OOM issue when integrated-gradient is applied on large pretrain language models.\r\n3. Add a new interface for multimodal models.\r\n4. Add explainers for vision language tasks, e.g., GradCAM and integrated-gradient.","2022-08-05T08:07:54",{"id":213,"version":214,"summary_zh":215,"released_at":216},272398,"v1.1.2","1. Re-designed the Timeseries data class.\r\n2. Re-implemented SHAP, CE and MACE for the new Timeseries data class.\r\n3. Fixed some small issues in the dashboard.","2022-07-26T06:27:02",{"id":218,"version":219,"summary_zh":220,"released_at":221},272399,"v1.1.1","1. Support accumulated local effects (ALE).\r\n2. Revise the visualization of PDP results.\r\n3. Fixed some minor issues.","2022-07-22T04:28:29",{"id":223,"version":224,"summary_zh":225,"released_at":226},272400,"v1.1.0","1. Added PredictionAnalyzer for computing classification and regression metrics.\r\n2. Revised the interfaces of DataAnalyzer and PDP.\r\n3. Resolved some plotting issues caused by long feature names.\r\n4. Improved the visualization for regression problems.\r\n5. Redesigned the visualization dashboard, e.g., local explanation and global explanation are put into different tabs.","2022-07-11T06:23:13",{"id":228,"version":229,"summary_zh":230,"released_at":231},272401,"v1.0.0","The first version of our OmniXAI library","2022-06-10T02:13:03"]