AI考核评估:从能力测评到训练效果量化
金融AI评估体系如何判断你的智能体够聪明方法论AI评估指标体系 | 金融场景特殊性 | 持续优化为什么需要评估体系银行上线AI系统后常见对话行长: 这个AI系统怎么样 科技: 准确率95% 行长: 那客户满意度呢 科技: ...没统计 行长: 业务效率提升多少 科技: ...应该挺多的问题没有体系化的评估无法证明价值。评估指标体系三层评估模型┌─────────────────────────────────────┐ │ 战略层 (北极星指标) │ │ ├─ 业务价值 │ │ ├─ 客户体验 │ │ └─ 风险控制 │ ├─────────────────────────────────────┤ │ 战术层 (过程指标) │ │ ├─ 系统性能 │ │ ├─ 模型效果 │ │ └─ 运营效率 │ ├─────────────────────────────────────┤ │ 执行层 (基础指标) │ │ ├─ 技术指标 │ │ ├─ 数据质量 │ │ └─ 资源消耗 │ └─────────────────────────────────────┘金融AI专用指标1. 准确性指标指标定义目标值适用场景准确率正确预测/总预测95%分类任务精确率TP/(TPFP)90%欺诈检测召回率TP/(TPFN)85%反洗钱F1分数2精确率召回率/(精确率召回率)90%综合评估AUC-ROCROC曲线下面积0.9排序任务from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, roc_auc_score class ModelEvaluator: def __init__(self): self.thresholds { accuracy: 0.95, precision: 0.90, recall: 0.85, f1: 0.90, auc: 0.90 } def evaluate(self, y_true, y_pred, y_probNone) - dict: 评估模型 results { accuracy: accuracy_score(y_true, y_pred), precision: precision_score(y_true, y_pred), recall: recall_score(y_true, y_pred), f1: f1_score(y_true, y_pred) } if y_prob is not None: results[auc] roc_auc_score(y_true, y_prob) # 检查是否达标 results[passed] all( results.get(k, 0) v for k, v in self.thresholds.items() ) return results2. 业务价值指标指标定义计算方式效率提升节省时间/原时间(T_old - T_new) / T_old成本降低节省成本/原成本(C_old - C_new) / C_old收入增加新增收入/原收入(R_new - R_old) / R_old风险降低减少损失/原损失(L_old - L_new) / L_oldclass BusinessEvaluator: def calculate_efficiency(self, old_time, new_time): 计算效率提升 return (old_time - new_time) / old_time * 100 def calculate_cost_saving(self, old_cost, new_cost): 计算成本节省 return (old_cost - new_cost) / old_cost * 100 def calculate_roi(self, investment, return_value): 计算ROI return (return_value - investment) / investment * 1003. 可解释性指标指标定义目标值决策透明度可解释决策/总决策90%特征重要性关键特征可识别是反事实解释可提供反事实案例是class ExplainabilityEvaluator: def __init__(self, model): self.model model def get_feature_importance(self) - dict: 获取特征重要性 if hasattr(self.model, feature_importances_): return dict(zip( self.model.feature_names_, self.model.feature_importances_ )) return {} def generate_counterfactual(self, instance, desired_outcome): 生成反事实解释 # 使用DiCE或其他库 pass4. 公平性指标指标定义目标值人口统计 parity不同群体通过率差异5%机会均等真正例率差异5%校准性预测概率与实际概率一致性95%class FairnessEvaluator: def demographic_parity(self, y_pred, sensitive_attr): 人口统计parity groups {} for group in sensitive_attr.unique(): mask sensitive_attr group groups[group] y_pred[mask].mean() return max(groups.values()) - min(groups.values()) def equal_opportunity(self, y_true, y_pred, sensitive_attr): 机会均等 groups {} for group in sensitive_attr.unique(): mask (sensitive_attr group) (y_true 1) groups[group] y_pred[mask].mean() return max(groups.values()) - min(groups.values())评估仪表盘class EvaluationDashboard: def __init__(self): self.metrics {} def add_metric(self, name: str, value: float, threshold: float): 添加指标 self.metrics[name] { value: value, threshold: threshold, status: pass if value threshold else fail } def generate_report(self) - str: 生成报告 report # AI系统评估报告\n\n for name, metric in self.metrics.items(): status ✅ if metric[status] pass else ❌ report f{status} {name}: {metric[value]:.2%} (目标: {metric[threshold]:.2%})\n return report def visualize(self): 可视化 import matplotlib.pyplot as plt names list(self.metrics.keys()) values [m[value] for m in self.metrics.values()] thresholds [m[threshold] for m in self.metrics.values()] fig, ax plt.subplots(figsize(10, 6)) x range(len(names)) ax.bar(x, values, label实际值, alpha0.7) ax.plot(x, thresholds, r--, label目标值, linewidth2) ax.set_xticks(x) ax.set_xticklabels(names, rotation45, haright) ax.set_ylabel(数值) ax.set_title(AI系统评估指标) ax.legend() ax.grid(True, alpha0.3) plt.tight_layout() plt.savefig(evaluation_dashboard.png)持续评估机制监控频率指标类型监控频率告警阈值技术指标实时下降5%业务指标每日下降10%风险指标实时任何异常公平性指标每周差异5%自动告警class AlertSystem: def __init__(self): self.rules [] def add_rule(self, metric: str, condition: str, threshold: float, action: str): 添加告警规则 self.rules.append({ metric: metric, condition: condition, threshold: threshold, action: action }) def check(self, metrics: dict): 检查告警 alerts [] for rule in self.rules: value metrics.get(rule[metric]) if value is None: continue triggered False if rule[condition] and value rule[threshold]: triggered True elif rule[condition] and value rule[threshold]: triggered True if triggered: alerts.append({ metric: rule[metric], value: value, threshold: rule[threshold], action: rule[action] }) return alerts评估案例信贷审批AI评估# 初始化评估器 evaluator ModelEvaluator() business BusinessEvaluator() dashboard EvaluationDashboard() # 模型效果 model_results evaluator.evaluate(y_true, y_pred, y_prob) dashboard.add_metric(准确率, model_results[accuracy], 0.95) dashboard.add_metric(精确率, model_results[precision], 0.90) dashboard.add_metric(召回率, model_results[recall], 0.85) dashboard.add_metric(F1分数, model_results[f1], 0.90) # 业务价值 efficiency business.calculate_efficiency(72, 2) # 小时 cost_saving business.calculate_cost_saving(500000, 20000) # 元/月 dashboard.add_metric(效率提升, efficiency / 100, 0.80) dashboard.add_metric(成本节省, cost_saving / 100, 0.70) # 生成报告 print(dashboard.generate_report()) dashboard.visualize()输出# AI系统评估报告 ✅ 准确率: 96.50% (目标: 95.00%) ✅ 精确率: 92.30% (目标: 90.00%) ✅ 召回率: 88.70% (目标: 85.00%) ✅ F1分数: 90.40% (目标: 90.00%) ✅ 效率提升: 97.20% (目标: 80.00%) ✅ 成本节省: 96.00% (目标: 70.00%)#AI评估 #指标体系 #金融AI #模型监控 #持续优化