名称: 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
}
}
}
}