我的函数应该返回文本文件的kappa值,如下所示:
rood rood
rood rood
rood blauw
blauw blauw
blauw blauw
geel blauw
rood rood
rood rood
rood blauw
blauw blauw
blauw blauw
geel blauw
rood rood
rood rood
rood blauw
当可能性值大于2时,如何计算机会一致性?
这是我到目前为止的代码:
def kappaValue(kappaList):
totalLines = 0
agree = 0
values = []
for line in kappaList:
line = line.strip().split("\t")
values.append(line)
totalLines += 1
for subList in values:
if subList[0] == subList[-1]:
agree += 1
A = agree / totalLines
else:
# Values are not the same
return totalLines, A
最终,该函数应该返回kappa值,但是当值不相同时,我会陷入困境。