Fleiss‘ kappa

Fleiss’ kappa is a statistical measure used to assess the reliability or agreement among multiple raters when categorizing items into multiple categories. It is an extension of Cohen’s kappa, which is used for measuring agreement between two raters.

Fleiss’ kappa takes into account the possibility of agreement occurring by chance and provides a measure of agreement that corrects for chance agreement. It is commonly used in fields such as psychology, sociology, and medical research where multiple raters are involved in the classification of items.

The formula for Fleiss’ kappa involves calculating the observed agreement among raters and comparing it to the expected agreement due to chance. The formula is as follows:

κ = (P_obs - P_exp) / (1 - P_exp)

where κ is the Fleiss’ kappa value, P_obs is the observed proportion of agreement among raters, and P_exp is the expected proportion of agreement due to chance.

Fleiss’ kappa ranges from -1 to 1, where a value of 1 indicates perfect agreement, 0 indicates agreement equivalent to chance, and negative values indicate less agreement than expected by chance.

It’s worth noting that Fleiss’ kappa assumes that the categories being rated are mutually exclusive and that each item being rated falls into only one category. Additionally, it is important to have an adequate number of raters and items to obtain reliable results when using Fleiss’ kappa.

Fleiss’ kappa can be affected by various factors, including the number of raters, the number of categories, and the distribution of ratings.

import numpy as np

def fleiss_kappa(ratings):
    num_subjects, num_categories = ratings.shape
    num_items = np.sum(ratings[0, :])  # Assuming equal number of items rated by each subject

    # Calculate the observed agreement
    p_obs = np.sum(ratings * ratings, axis=1)
    p_obs = (p_obs - num_items) / (num_items * (num_items - 1))

    # Calculate the expected agreement
    p_j = np.sum(ratings, axis=0) / (num_subjects * num_items)
    p_exp = np.sum(p_j * p_j)

    # Calculate Fleiss' kappa
    kappa = (np.mean(p_obs) - p_exp) / (1 - p_exp)

    return kappa
ratings = np.array([
    [0, 3, 1, 0],  # Subject 1's ratings
    [1, 2, 1, 0],  # Subject 2's ratings
    [0, 1, 3, 0],  # Subject 3's ratings
    [0, 0, 0, 4]   # Subject 4's ratings
])

kappa = fleiss_kappa(ratings)
print("Fleiss' kappa:", kappa)
Fleiss' Kappa(菲氏Kappa系数)是一种用于评估分类者之间的一致性的统计量,特别适用于多个独立分类者的评价系统。它适用于多个分类者对同一批观测值进行分类的情况,比如在评估研究者对某个变量的判断一致性。 **原理:** Fleiss' Kappa基于百分比协议,即所有分类者对每个观测值达成一致的比例。它考虑了分类者之间偶然的、随机的一致性,并通过比较实际一致性与纯随机一致性(即每个分类者独立作出判断)的差距来量化这种一致性。 **公式:** \[ \kappa = \frac{P_o - P_e}{1 - P_e} \] 其中: - \( P_o \) 是观察到的实际一致性百分比(也称为互评百分比,即所有分类者都同意的次数除以总样本数)。 - \( P_e \) 是预期的一致性水平,如果每个分类者都是独立做出判断,这个比例等于分类类别总数的乘积再除以观测值总数的平方。 **Python代码实现(使用scipy库):** ```python from scipy.stats import FleissKappa # 假设我们有分类结果数据,例如三个分类者对5个项目的结果 categories = [[1, 2, 2, 3, 3], [2, 2, 1, 3, 3], [2, 1, 1, 3, 3]] # 分类矩阵,行代表观测值,列表内元素表示分类者的选择 n_classifiers = len(categories) n_items = len(categories[0]) # 计算实际一致性(Po) agreement_matrix = np.zeros((n_classifiers, n_classes)) for i in range(n_classifiers): for j in range(n_items): agreement_matrix[i, categories[i][j] - 1] += 1 Po = agreement_matrix.sum() / (n_items * n_classifiers) # 计算期望一致性(Pe) Pe = 1 / (n_classes ** n_classifiers) # 计算Fleiss' Kappa kappa = FleissKappa(categories).kappa print(f"Fleiss' Kappa: {kappa:.2f}")
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bit_lin

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值