目录

公平度量概述

使用IBM Watson OpenScale公平监控以确定模型生产的结果是否公平或不适用于监控组。启用公平监控时,它默认情况下会每小时生成一组指标。您可以通过单击“按需生成这些指标” 立即检查公平 按钮或使用Python客户端。

Watson OpenScale自动标识模型中是否存在任何已知的受保护属性。当Watson OpenScale检测到这些属性时,它会自动建议为每个属性配置偏置监视器,以确保在生产中跟踪对这些潜在敏感属性的偏置。

目前,Watson OpenScale检测并推荐以下受保护属性的监视器:

  • 性别
  • 种族
  • 婚姻状况
  • 年龄
  • 邮政编码或邮政编码

In addition to detecting protected attributes, Watson OpenScale recommends which values within each attribute should be set as the monitored and the reference values. For example, Watson OpenScale recommends that within the Sex attribute, the bias monitor be configured such that Female and Non-Binary are the monitored values, and Male is the reference value. If you want to change any of the recommendations, you can edit them via the bias configuration panel.

推荐的偏见监视器有助于加快配置,并确保您正在检查您的AI模型以进行对敏感属性的公平性。由于监管机构开始对算法偏差进行更尖锐的眼睛,因此组织对其模型的表现明确了解,以及他们是否正在为某些群体产生不公平的结果,这变得越来越重要。

理解公平

Watson OpenScale checks your deployed model for bias at runtime. To detect bias for a deployed model, you must define fairness attributes, such as Age or Sex, as detailed in the 配置公平监视器 section.

It is mandatory to specify the output schema for a model or function in Machine Learning, for bias checking to be enabled in Watson OpenScale. The output schema can be specified using the client.repository.ModelMetaNames.OUTPUT_DATA_SCHEMA property in the metadata part of the store_model API. For more information, see the IBM. Watson Machine学习客户文档.

怎么运行的

在配置公平监视器之前,有一些关键概念对理解至关重要:

  • 公平性属性是模型可能表现出偏差的模型属性。例如,对于公平性属性 Sex, the model could be biased against specific values, such as Female or Non-binary. Another example of a fairness attribute is Age, where the model could exhibit bias against people in an age group, such as 18 to 25.

  • 引用和监控值:公平性属性的值分为两个不同的类别:引用和监控。监控值是可能被歧视的值。在公平性属性的情况下 Sex, the Monitored values could be Female and Non-binary. For a numeric fairness attribute, such as Age, the Monitored values could be [18-25]. All other values for a given fairness attribute are then considered as Reference values, for example Sex=Male or Age=[26,100].

  • Favorable and unfavorable outcomes: The output of the model is categorized as either Favorable or Unfavorable. As an example, if the model is predicting whether a person should get a loan or not, then the Favorable outcome could be Loan Granted or Loan Partially Granted, whereas the Unfavorable outcome might be Loan Denied. Thus, the Favorable outcome is one that is deemed as a positive outcome, while the Unfavorable outcome is deemed as being negative.

The Watson OpenScale algorithm computes bias on an hourly basis, using the last N records present in the payload logging table; the value of N is specified when configuring Fairness. The algorithm perturbs these last N records to generate additional data.

The perturbation is done by changing the value of the fairness attribute from Reference to Monitored, or vice-versa. The perturbed data is then sent to the model to evaluate its behavior. The algorithm looks at the last N records in the payload table, and the behavior of the model on the perturbed data, to decide if the model is acting in a biased manner.

如果在这个组合的数据集中,将被视为被监控类的有利结果的百分比的模型被视为偏见的百分比小于参考类的有利结果的百分比,通过一些阈值。配置公平性时要指定此阈值。

公平值可以超过100%。这意味着监测组比参考组接受了更有利的结果。此外,如果没有发送新的评分请求,则公平值将保持不变。

平衡数据和完美的平等

对于平衡数据设置以下概念适用:

  • 要确定完美的相邻值,请通过将每个受监视的组事务的监视特征值更改为所有引用组值来合成参考组事务。这些新的合成事务将添加到参考组事务集并由模型进行评估。

    If the monitored feature is SEX and the monitored group is FEMALE, all FEMALE transactions are duplicated as MALE transactions. Other features values remain unchanged. These new synthesized MALE transactions are added to the set of original MALE reference group transactions.

  • 从新的参考组,确定有利的结果的百分比。该百分比代表了监控组的完美公平。
  • 还通过将每个参考组事务的引用特征值更改为监视的组值来合成监视的组事务。这些新的合成事务将添加到监视组事务集并由模型进行评估。

If the monitored feature is SEX and the monitored group is FEMALE, all MALE transactions are duplicated as FEMALE transactions. Other features values remain unchanged. These new synthesized FEMALE transactions are added to the set of original FEMALE monitored group transactions.

算一算

Watson OpenScale中使用的公平度量是不同的影响,这是一种衡量非特权集团收到某些结果或结果的速率如何与特权集团收到相同结果或结果的速度进行比较。

以下数学公式用于计算不同影响:

                     (num_positives(privileged=False) / num_instances(privileged=False))
Disparate impact =   ______________________________________________________________________

                     (num_positives(privileged=True) / num_instances(privileged=True))

where num_positives is the number of individuals in the group (either privileged=False, i.e. unprivileged, or privileged=True, i.e. privileged) who received a positive outcome, and num_instances is the total number of individuals in the group.

结果数量将是一个百分比,这是非专生小组获得积极结果的率的百分比是特权集团收到积极结果的速度。例如,如果信用风险模型将“无风险”预测分配到80%的未经府潜行的申请人和100%的特权申请人,那么该模型将产生80%的差异影响(作为Watson Openscale的公平得分)。

在Watson OpenScale中,正结果被指定为有利的结果,负面结果被指定为不利的结果。特权组被指定为参考组,未经特权的组被指定为受监控组。

以下数学公式用于计算完美的平等:

Perfect equality =   Percentage of favorable outcomes for all reference transactions, 
                     including the synthesized transactions from the monitored group

For example, if the monitored feature is SEX and the monitored group is FEMALE, the following formula shows the equation for perfect equality:

Perfect equality for `SEX` =  Percentage of favorable outcomes for `MALE` transactions, 
                                 including the synthesized transactions that were initially `FEMALE` but changed to `MALE`

偏见可视化

当检测到潜在偏差时,Watson OpenScale执行若干功能以确认偏差是真实的。 Watson OpenScale通过将监视的值翻转到参考值,然后通过模型运行此新录制来erturbs erturbs。然后它将结果输出表面作为脱叠输出。 Watson OpenScale还列出了一个暗影脱结模型,然后它用于检测模型将何时进行偏见预测。

两个不同的数据集用于计算公平性和准确性。通过使用有效载荷+扰动数据来计算公平性。使用反馈数据计算精度。为了计算精度,Watson OpenScale需要手动标记的数据,该数据仅存在反馈表中。

这些测定的结果可在偏置可视化中提供,包括以下视图。 (如果有数据支持,您只能看到视图

  • 均衡 :此平衡计算包括如果未满足评估所需的最小记录数,则为选定小时加上选定小时加上其他记录的评分请求。包括用于在受监控功能的值更改时测试模型的响应的额外扰动/综合记录。

    注意以下有效载荷和扰动细节:

    • 监控群体,公平得分
    • 具有公平分数的参考群体
    • 偏见的来源
  • 有效载荷 :所选小时的模型收到的实际评分请求。

    请注意以下有效载荷详细信息:

    • 带堆叠条形图的有效载荷数据
    • 对应于模型标签的有利和不利的结果
    • 交易的日期和时间加载
  • 训练 :用于培训模型的培训数据记录。

    请注意以下培训详情:

    • Number of training data records. Training data is read one time, and distribution is stored in the subscription/fairness_configuration variable. While computing distribution, the number of training data records is also retrieved and stored in the same distribution.
    • When training data is changed, meaning if the POST /data_distribution command is run again, this value is updated in the fairness_configuration/training_data_distribution variable. While sending the metric, this value is sent as well.
  • 脱叠 :处理运行时和扰动数据后的脱叠算法的输出。选择 脱叠 单选按钮向您展示脱叠模型的更改,而不是生产模型。该图表反映了群体的改善的结果状态。

    请注意以下脱叠细节:

    • 脱叠模型的结果
    • For monitored groups, such as 年龄 and 性别 the before and after scores

例子

Consider a data point where, for Sex=Male (Reference value), the model predicts an Favorable outcome, but when the record is perturbed by changing Sex to Female (Monitored value), while keeping all other feature values the same, the model predicts an Unfavorable outcome. A model overall is said to exhibit bias if there are sufficient data points (across the last N records in the payload table, plus the perturbed data) where the model was acting in a biased manner.

支持的模型

Watson OpenScale仅支持偏置检测,仅适用于那些期望其特征向量中某种结构化数据的模型和Python函数。

根据得分有效载荷数据计算公平度量。

为适当的监控目的,应在Watson OpenScale中登录每个评分要求。有效载荷数据记录为IBM Watson Machine Engines自动化。

对于其他机器学习引擎,可以通过使用Python客户端或REST API提供有效载荷数据。

对于除IBM Watson Machine学习之外的机器学习发动机,公平监控会在监控部署中创建额外的评分请求。

您可以查看以下信息:

  • 量度值随着时间的推移
  • 相关细节,如有利和不利的结果
  • 详细的交易
  • 推荐的脱叠得分终点

支持的公平度量标准

Watson OpenScale支持以下公平度量:

Watson OpenScale支持以下受保护的属性:

支持的公平细节

Watson OpenScale支持以下公平度量的以下详细信息:

  • 每个组的有利百分比
  • 所有公平团体的公平平均值
  • 每个受监控组的数据分发
  • 有效载荷数据的分布