LIME解释器 lime-explainer

LIME解释器是基于LIME(局部可解释模型无关解释)算法的AI模型解释工具,专门用于机器学习模型的可解释性分析。该技能能够为表格数据、文本分类和图像分类的个体预测提供局部解释,帮助用户理解黑盒模型的决策依据。通过特征重要性分析、局部替代模型和可视化输出,提升模型透明度、可信度和调试效率。适用于模型验证、合规审计和业务决策支持场景。

机器学习 0 次安装 0 次浏览 更新于 2/23/2026

名称: lime-explainer 描述: 基于LIME的局部解释技能,适用于表格、文本和图像数据的个体预测解释。 允许工具:

  • 读取
  • 写入
  • Bash
  • Glob
  • Grep

lime-explainer

概述

基于LIME(局部可解释模型无关解释)的局部解释技能,适用于表格、文本和图像数据的个体预测解释。

能力

  • 表格数据解释
  • 文本分类解释
  • 图像分类解释
  • 代表性样本的子模块选取
  • 自定义距离度量
  • 核宽度调优
  • 特征离散化
  • 局部替代模型分析

目标流程

  • 模型可解释性与可解释性分析
  • 模型评估与验证框架

工具与库

  • LIME
  • scikit-learn
  • numpy
  • PIL/Pillow(用于图像)

输入模式

{
  "type": "object",
  "required": ["modelPath", "dataType", "instancePath"],
  "properties": {
    "modelPath": {
      "type": "string",
      "description": "训练模型或预测函数的路径"
    },
    "dataType": {
      "type": "string",
      "enum": ["tabular", "text", "image"],
      "description": "要解释的数据类型"
    },
    "instancePath": {
      "type": "string",
      "description": "要解释的实例路径"
    },
    "tabularConfig": {
      "type": "object",
      "properties": {
        "trainingDataPath": { "type": "string" },
        "featureNames": { "type": "array", "items": { "type": "string" } },
        "categoricalFeatures": { "type": "array", "items": { "type": "integer" } },
        "classNames": { "type": "array", "items": { "type": "string" } }
      }
    },
    "textConfig": {
      "type": "object",
      "properties": {
        "classNames": { "type": "array", "items": { "type": "string" } },
        "splitExpression": { "type": "string" }
      }
    },
    "imageConfig": {
      "type": "object",
      "properties": {
        "segmenter": { "type": "string", "enum": ["quickshift", "slic", "felzenszwalb"] },
        "hideColor": { "type": "string" },
        "numSamples": { "type": "integer" }
      }
    },
    "explainerConfig": {
      "type": "object",
      "properties": {
        "numFeatures": { "type": "integer" },
        "numSamples": { "type": "integer" },
        "kernelWidth": { "type": "number" }
      }
    }
  }
}

输出模式

{
  "type": "object",
  "required": ["status", "explanations"],
  "properties": {
    "status": {
      "type": "string",
      "enum": ["success", "error"]
    },
    "explanations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "instanceId": { "type": "string" },
          "predictedClass": { "type": "string" },
          "predictionProbability": { "type": "number" },
          "features": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "feature": { "type": "string" },
                "weight": { "type": "number" },
                "contribution": { "type": "string" }
              }
            }
          },
          "localAccuracy": { "type": "number" }
        }
      }
    },
    "visualizations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "instanceId": { "type": "string" },
          "plotPath": { "type": "string" }
        }
      }
    }
  }
}

使用示例

{
  kind: 'skill',
  title: '为预测生成LIME解释',
  skill: {
    name: 'lime-explainer',
    context: {
      modelPath: 'models/classifier.pkl',
      dataType: 'tabular',
      instancePath: 'data/instances_to_explain.csv',
      tabularConfig: {
        trainingDataPath: 'data/train.csv',
        featureNames: ['age', 'income', 'credit_score'],
        categoricalFeatures: [0, 2],
        classNames: ['reject', 'approve']
      },
      explainerConfig: {
        numFeatures: 10,
        numSamples: 5000
      }
    }
  }
}